Merge
authorduke
Wed, 05 Jul 2017 22:46:04 +0200
changeset 43361 b580f96a38b4
parent 43360 32ea5c3ed72c (current diff)
parent 43359 269efd520e13 (diff)
child 43378 c199e27b2ae1
Merge
jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh
jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c
jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c
jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c
jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c
jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c
jdk/test/tools/jlink/CustomPluginTest.java
jdk/test/tools/jlink/customplugin/module-info.java
jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java
jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java
jdk/test/tools/jlink/customplugin/plugin/RogueAdderPlugin.java
jdk/test/tools/jlink/customplugin/plugin/RogueFilterPlugin.java
--- a/.hgtags-top-repo	Thu Jan 26 19:22:38 2017 +0000
+++ b/.hgtags-top-repo	Wed Jul 05 22:46:04 2017 +0200
@@ -396,3 +396,4 @@
 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151
 ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152
 816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153
+8d26916eaa21b689835ffc1c0dbf12470aa9be61 jdk-9+154
--- a/common/autoconf/generated-configure.sh	Thu Jan 26 19:22:38 2017 +0000
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 22:46:04 2017 +0200
@@ -5180,7 +5180,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1484571183
+DATE_WHEN_GENERATED=1485508515
 
 ###############################################################################
 #
@@ -31283,12 +31283,6 @@
   if test -d "$IMPORT_MODULES_TOPDIR/modules_src"; then
     IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src"
   fi
-  # Workaround for using different imported module-info.java in Jake due to a
-  # change in format. Remove once new format is standard in JDK 9 and javafx
-  # delivers just that.
-  if test -d "$IMPORT_MODULES_TOPDIR/modules_src_jake"; then
-    IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src_jake $IMPORT_MODULES_SRC"
-  fi
   if test -d "$IMPORT_MODULES_TOPDIR/make"; then
     IMPORT_MODULES_MAKE="$IMPORT_MODULES_TOPDIR/make"
   fi
--- a/common/autoconf/source-dirs.m4	Thu Jan 26 19:22:38 2017 +0000
+++ b/common/autoconf/source-dirs.m4	Wed Jul 05 22:46:04 2017 +0200
@@ -114,12 +114,6 @@
   if test -d "$IMPORT_MODULES_TOPDIR/modules_src"; then
     IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src"
   fi
-  # Workaround for using different imported module-info.java in Jake due to a
-  # change in format. Remove once new format is standard in JDK 9 and javafx
-  # delivers just that.
-  if test -d "$IMPORT_MODULES_TOPDIR/modules_src_jake"; then
-    IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src_jake $IMPORT_MODULES_SRC"
-  fi
   if test -d "$IMPORT_MODULES_TOPDIR/make"; then
     IMPORT_MODULES_MAKE="$IMPORT_MODULES_TOPDIR/make"
   fi
--- a/common/conf/jib-profiles.js	Thu Jan 26 19:22:38 2017 +0000
+++ b/common/conf/jib-profiles.js	Wed Jul 05 22:46:04 2017 +0200
@@ -610,6 +610,19 @@
     }
     profiles = concatObjects(profiles, testOnlyProfilesPrebuilt);
 
+    // On macosx add the devkit bin dir to the path in all the run-test profiles.
+    // This gives us a guaranteed working version of lldb for the jtreg failure handler.
+    if (input.build_os == "macosx") {
+        macosxRunTestExtra = {
+            dependencies: [ "devkit" ],
+            environment_path: input.get("devkit", "install_path")
+                + "/Xcode.app/Contents/Developer/usr/bin"
+        }
+        profiles["run-test"] = concatObjects(profiles["run-test"], macosxRunTestExtra);
+        profiles["run-test-jprt"] = concatObjects(profiles["run-test-jprt"], macosxRunTestExtra);
+        profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], macosxRunTestExtra);
+    }
+
     //
     // Define artifacts for profiles
     //
@@ -844,7 +857,7 @@
             file: boot_jdk_platform + "/jdk-" + common.boot_jdk_revision
                 + "-" + boot_jdk_platform + ".tar.gz",
             configure_args: "--with-boot-jdk=" + common.boot_jdk_home,
-            environment_path: common.boot_jdk_home
+            environment_path: common.boot_jdk_home + "/bin"
         },
 
         devkit: {
--- a/corba/.hgtags	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/.hgtags	Wed Jul 05 22:46:04 2017 +0200
@@ -396,3 +396,4 @@
 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151
 ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152
 68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153
+078ebe23b584466dc8346e620d7821d91751e5a9 jdk-9+154
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/src/java.corba/share/classes/com/sun/corba/se/spi/orb/ORB.java	Wed Jul 05 22:46:04 2017 +0200
@@ -31,9 +31,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger ;
 
-import java.security.AccessController ;
-import java.security.PrivilegedAction ;
-
 import org.omg.CORBA.TCKind ;
 
 import com.sun.corba.se.pept.broker.Broker ;
@@ -89,9 +86,6 @@
 
 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
 
-import jdk.internal.misc.JavaAWTAccess;
-import jdk.internal.misc.SharedSecrets;
-
 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
     implements Broker, TypeCodeFactory
 {
@@ -164,12 +158,9 @@
 
     static class Holder {
         static final PresentationManager defaultPresentationManager =
-            setupPresentationManager();
+                                         setupPresentationManager();
     }
 
-    private static final Map<Object, PresentationManager> pmContexts =
-            new ConcurrentHashMap<>();
-
     private static Map<StringPair, LogWrapperBase> staticWrapperMap =
             new ConcurrentHashMap<>();
 
@@ -198,23 +189,10 @@
         byteBufferPool = null;
     }
 
-    /**
-     * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
-     * AppContext to hold it. Creates and records one if needed.
+    /** Get the single instance of the PresentationManager
      */
     public static PresentationManager getPresentationManager()
     {
-        SecurityManager sm = System.getSecurityManager();
-        JavaAWTAccess javaAwtAccess = SharedSecrets.getJavaAWTAccess();
-        if (sm != null && javaAwtAccess != null) {
-            final Object appletContext = javaAwtAccess.getAppletContext();
-            if (appletContext != null) {
-                return pmContexts.computeIfAbsent(appletContext,
-                    x -> setupPresentationManager());
-            }
-        }
-
-        // No security manager or AppletAppContext
         return Holder.defaultPresentationManager;
     }
 
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java	Wed Jul 05 22:46:04 2017 +0200
@@ -36,8 +36,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import sun.reflect.misc.ReflectUtil;
-
 /**
  * A class providing APIs for the CORBA Object Request Broker
  * features.  The {@code ORB} class also provides
@@ -188,6 +186,24 @@
     private static final String ORBClassKey = "org.omg.CORBA.ORBClass";
     private static final String ORBSingletonClassKey = "org.omg.CORBA.ORBSingletonClass";
 
+    // check that access to the class is not restricted by the security manager.
+    private static void checkPackageAccess(String name) {
+        SecurityManager s = System.getSecurityManager();
+        if (s != null) {
+            String cname = name.replace('/', '.');
+            if (cname.startsWith("[")) {
+                int b = cname.lastIndexOf('[') + 2;
+                if (b > 1 && b < cname.length()) {
+                    cname = cname.substring(b);
+                }
+            }
+            int i = cname.lastIndexOf('.');
+            if (i != -1) {
+                s.checkPackageAccess(cname.substring(0, i));
+            }
+        }
+    }
+
     //
     // The global instance of the singleton ORB implementation which
     // acts as a factory for typecodes for generated Helper classes.
@@ -318,7 +334,7 @@
    private static ORB create_impl_with_systemclassloader(String className) {
 
         try {
-            ReflectUtil.checkPackageAccess(className);
+            checkPackageAccess(className);
             ClassLoader cl = ClassLoader.getSystemClassLoader();
             Class<org.omg.CORBA.ORB> orbBaseClass = org.omg.CORBA.ORB.class;
             Class<?> singletonOrbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass);
@@ -337,7 +353,7 @@
             cl = ClassLoader.getSystemClassLoader();
 
         try {
-            ReflectUtil.checkPackageAccess(className);
+            checkPackageAccess(className);
             Class<org.omg.CORBA.ORB> orbBaseClass = org.omg.CORBA.ORB.class;
             Class<?> orbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass);
             return (ORB)orbClass.newInstance();
--- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/InputStream.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/InputStream.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -75,10 +75,11 @@
     /**
      * Create a new instance of this class.
      *
-     * throw SecurityException if SecurityManager is installed and
+     * @implNote
+     * Throws SecurityException if SecurityManager is installed and
      * enableSubclassImplementation SerializablePermission
      * is not granted or jdk.corba.allowInputStreamSubclass system
-     * property is either not set or is set to 'false'
+     * property is either not set or is set to 'false'.
      */
     public InputStream() {
         this(checkPermission());
--- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -72,10 +72,11 @@
     /**
      * Create a new instance of this class.
      *
-     * throw SecurityException if SecurityManager is installed and
+     * @implNote
+     * Throws SecurityException if SecurityManager is installed and
      * enableSubclassImplementation SerializablePermission
      * is not granted or jdk.corba.allowOutputStreamSubclass system
-     * property is either not set or is set to 'false'
+     * property is either not set or is set to 'false'.
      */
     public OutputStream() {
         this(checkPermission());
--- a/corba/src/java.corba/share/classes/sun/corba/Bridge.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/corba/src/java.corba/share/classes/sun/corba/Bridge.java	Wed Jul 05 22:46:04 2017 +0200
@@ -29,6 +29,10 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.reflect.Field ;
 import java.lang.reflect.Constructor ;
+import java.lang.StackWalker;
+import java.lang.StackWalker.StackFrame;
+import java.util.Optional;
+import java.util.stream.Stream;
 
 import java.security.AccessController;
 import java.security.Permission;
@@ -58,6 +62,7 @@
  * <li>RuntimePermission "reflectionFactoryAccess"</li>
  * <li>BridgePermission "getBridge"</li>
  * <li>ReflectPermission "suppressAccessChecks"</li>
+ * <li>StackFramePermission "retainClassReference"</li>
  * </ul>
  * <p>
  * All of these permissions are required to obtain and correctly initialize
@@ -89,9 +94,12 @@
     ) ;
 
     private final ReflectionFactory reflectionFactory ;
+    private final StackWalker stackWalker;
 
     private Bridge() {
         reflectionFactory = ReflectionFactory.getReflectionFactory();
+        stackWalker  = StackWalker.getInstance(
+                            StackWalker.Option.RETAIN_CLASS_REFERENCE);
     }
 
     /** Fetch the Bridge singleton.  This requires the following
@@ -100,6 +108,7 @@
      * <li>RuntimePermission "reflectionFactoryAccess"</li>
      * <li>BridgePermission "getBridge"</li>
      * <li>ReflectPermission "suppressAccessChecks"</li>
+     * <li>StackFramePermission "retainClassReference"</li>
      * </ul>
      * @return The singleton instance of the Bridge class
      * @throws SecurityException if the caller does not have the
@@ -118,11 +127,33 @@
         return bridge ;
     }
 
+    /** Returns true if the loader that loaded the frame's declaring class
+     * is a user loader (if it is not the platform class loader or one of
+     * its ancestor).
+     */
+    private boolean isUserLoader(StackFrame sf) {
+        ClassLoader cl = sf.getDeclaringClass().getClassLoader();
+        if (cl == null) return false;
+        ClassLoader p = ClassLoader.getPlatformClassLoader();
+        while (cl != p && p != null) p = p.getParent();
+        return cl != p;
+    }
+
+    private Optional<StackFrame> getLatestUserDefinedLoaderFrame(Stream<StackFrame> stream) {
+        return stream.filter(this::isUserLoader).findFirst();
+    }
+
+
     /** Obtain the latest user defined ClassLoader from the call stack.
      * This is required by the RMI-IIOP specification.
      */
     public final ClassLoader getLatestUserDefinedLoader() {
-        return jdk.internal.misc.VM.latestUserDefinedLoader();
+        // requires getClassLoader permission => needs doPrivileged.
+        PrivilegedAction<ClassLoader> pa = () ->
+            stackWalker.walk(this::getLatestUserDefinedLoaderFrame)
+                .map(sf -> sf.getDeclaringClass().getClassLoader())
+                .orElseGet(() -> ClassLoader.getPlatformClassLoader());
+        return AccessController.doPrivileged(pa);
     }
 
     /**
--- a/hotspot/.hgtags	Thu Jan 26 19:22:38 2017 +0000
+++ b/hotspot/.hgtags	Wed Jul 05 22:46:04 2017 +0200
@@ -556,3 +556,4 @@
 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151
 31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152
 217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153
+a9fdfd55835ef9dccb7f317b07249bd66653b874 jdk-9+154
--- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Thu Jan 26 19:22:38 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Wed Jul 05 22:46:04 2017 +0200
@@ -46,7 +46,10 @@
 
 #define DEFAULT_STACK_YELLOW_PAGES (2)
 #define DEFAULT_STACK_RED_PAGES (1)
-#define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5))
+// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the
+// stack if compiled for unix and LP64. To pass stack overflow tests we need
+// 20 shadow pages.
+#define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+5))
 #define DEFAULT_STACK_RESERVED_PAGES (0)
 
 #define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES
--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Thu Jan 26 19:22:38 2017 +0000
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Wed Jul 05 22:46:04 2017 +0200
@@ -475,9 +475,9 @@
 
 // Minimum usable stack sizes required to get to user code. Space for
 // HotSpot guard pages is added later.
-size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K;
-size_t os::Posix::_java_thread_min_stack_allowed = 32 * K;
-size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
+size_t os::Posix::_compiler_thread_min_stack_allowed = 72 * K;
+size_t os::Posix::_java_thread_min_stack_allowed = 72 * K;
+size_t os::Posix::_vm_internal_thread_min_stack_allowed = 72 * K;
 
 // return default stack size for thr_type
 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
--- a/jaxp/.hgtags	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/.hgtags	Wed Jul 05 22:46:04 2017 +0200
@@ -396,3 +396,4 @@
 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151
 7e3da313b1746578da648155e37dd8526e83153d jdk-9+152
 1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153
+7fa738305436d14c0926df0f04892890cacc766b jdk-9+154
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/EventFilterSupport.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/EventFilterSupport.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -64,7 +64,7 @@
     }
 
     public XMLEvent nextEvent()throws XMLStreamException{
-        if(super.hasNext()){
+        while (super.hasNext()) {
             //get the next event by calling XMLEventReader
             XMLEvent event = super.nextEvent();
 
@@ -72,27 +72,19 @@
             if(fEventFilter.accept(event)){
                 return event;
             }
-            else{
-                return nextEvent();
-            }
-        }else{
-            throw new NoSuchElementException();
         }
+        throw new NoSuchElementException();
     }//nextEvent()
 
      public XMLEvent nextTag() throws XMLStreamException{
-         if(super.hasNext()){
+         while (super.hasNext()) {
              XMLEvent event = super.nextTag();
              //if the filter accepts this event return this event.
              if(fEventFilter.accept(event)){
                 return event;
              }
-             else{
-                return nextTag();
-             }
-         }else{
-             throw new NoSuchElementException();
          }
+         throw new NoSuchElementException();
      }
 
      public XMLEvent peek() throws XMLStreamException{
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Wed Jul 05 22:46:04 2017 +0200
@@ -149,14 +149,6 @@
             CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
                     new Object[]{uri}, null);
         }
-
-        // verify the resource exists where possible
-        if (isFileUri(uri)) {
-            if (!isFileUriExist(uri, false)) {
-                CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
-                        new Object[]{uri}, null);
-            }
-        }
     }
 
     /**
--- a/jaxp/test/ProblemList.txt	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/ProblemList.txt	Wed Jul 05 22:46:04 2017 +0200
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# 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
@@ -22,5 +22,3 @@
 # questions.
 #
 ###########################################################################
-
-javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh            8169827 generic-all
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/IsolatedJDK.sh	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/isolatedjdk/IsolatedJDK.sh	Wed Jul 05 22:46:04 2017 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# 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
@@ -21,11 +21,6 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 
-if [ $# = 0 ]; then
-  echo "The suffix of ISOLATED_JDK is mandatory"
-  exit 1
-fi
-
 checkVariable() {
   variable='$'$1
 
@@ -42,20 +37,33 @@
   done
 }
 
-# Check essential variables
-checkVariables TESTJAVA TESTSRC TESTCLASSES TESTCLASSPATH
+# Script needs parameters
+if [ $# = 0 ]; then
+  echo "Syntax: IsolatedJDK.sh <Suffix> [remove]"
+  exit 1
+fi
 
-echo "TESTJAVA=${TESTJAVA}"
-echo "TESTSRC=${TESTSRC}"
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "TESTCLASSPATH=${TESTCLASSPATH}"
+# Is it the call to remove ?
+if [ $# = 2 ]; then
+  if [ "$2" = "remove" ]; then
+    removeIsolatedJdk=1
+  fi
+fi
+
+# Check essential variables
+checkVariables TESTJAVA
+ISOLATED_JDK="./ISOLATED_JDK_$1"
+
+# Remove isolated copy
+if [ "$removeIsolatedJdk" = "1" ]; then
+  echo "Removing ${ISOLATED_JDK}..."
+  rm -rf ${ISOLATED_JDK}
+  echo "Removed."
+  exit 0
+fi
 
 # Make an isolated copy of the testing JDK
-ISOLATED_JDK="./ISOLATED_JDK_$1"
-echo "ISOLATED_JDK=${ISOLATED_JDK}"
-
-echo "Copy testing JDK started"
+echo "Copying test JDK: ${TESTJAVA} -> ${ISOLATED_JDK}..."
 cp -H -R ${TESTJAVA} ${ISOLATED_JDK} || exit 1
 chmod -R +w ${ISOLATED_JDK} || exit 1
-echo "Copy testing JDK ended"
-
+echo "Copy done."
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -37,20 +37,95 @@
 import static catalog.CatalogTestUtils.generateJAXPProps;
 import static catalog.CatalogTestUtils.getCatalogPath;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.catalog.CatalogResolver;
 
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
 /*
- * This case tests if the properties FILES, DEFER, PREFER, RESOLVE in
- * jaxp.properties and system properties could be cared.
+ * @test
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/isolatedjdk
+ * @run shell/timeout=600 ../IsolatedJDK.sh JAXP_PROPS
+ * @run testng catalog.PropertiesTest
+ * @run shell/timeout=600 ../IsolatedJDK.sh JAXP_PROPS remove
+ * @summary This test case tests if the properties FILES, DEFER, PREFER,
+ *          RESOLVE in jaxp.properties and system properties are used.
+ *          It needs to run in a copied JDK as it modifies the JDK's
+ *          jaxp.properties file.
+ * @bug 8077931
  */
 public class PropertiesTest {
 
     private static final String CATALOG_PROPERTIES = "properties.xml";
 
+    @Test
+    /*
+     * Run main in a child process as it will modify the JDK.
+     */
+    public void test() throws Exception {
+        // get required properties and do some assertions
+        String javaclasspath = System.getProperty("java.class.path");
+        Assert.assertNotNull(javaclasspath, "Test class path is null");
+        String testclasspath = System.getProperty("test.class.path");
+        Assert.assertNotNull(testclasspath, "Test class path is null");
+        String testsourcepath = System.getProperty("test.src");
+        Assert.assertNotNull(testsourcepath, "Test source path is null");
+
+        // start the child process
+        List<String> testCall = new ArrayList<>(6);
+        testCall.add(Paths.get("ISOLATED_JDK_JAXP_PROPS", "/bin", "java").toString());
+        testCall.add("-cp");
+        testCall.add(javaclasspath);
+        testCall.add("-Dtest.class.path=" + testclasspath);
+        testCall.add("-Dtest.src=" + testsourcepath);
+        testCall.add("catalog.PropertiesTest");
+        System.out.println("Starting child process: " + Arrays.toString(testCall.toArray()));
+        Process test = new ProcessBuilder(testCall).start();
+
+        // wait for it to finish
+        boolean interrupted = false;
+        do {
+            try {
+                test.waitFor();
+                interrupted = false;
+            } catch (InterruptedException ie) {
+                interrupted = true;
+            }
+        } while (interrupted);
+
+        // trace system.out of child process
+        System.out.println("Proccess Out:");
+        BufferedReader br = new BufferedReader(new InputStreamReader(test.getInputStream()));
+        String line;
+        while ((line = br.readLine()) != null) {
+            System.out.println(line);
+        }
+        br.close();
+
+        // trace system.err of child process
+        System.out.println("Proccess Err:");
+        br = new BufferedReader(new InputStreamReader(test.getErrorStream()));
+        while ((line = br.readLine()) != null) {
+            System.out.println(line);
+        }
+        br.close();
+
+        // trace exit value and assert 0
+        int exitValue = test.exitValue();
+        System.out.println("Process Exit code: " + exitValue);
+        Assert.assertEquals(exitValue, 0, "PropertiesTest returned nonzero exit code.");
+    }
+
     public static void main(String[] args) throws Exception {
         System.out.println("testJAXPProperties started");
         testJAXPProperties();
@@ -64,7 +139,8 @@
     }
 
     /*
-     * Tests how does jaxp.properties affects the resolution.
+     * Tests how jaxp.properties affects the resolution.
+     * Be careful: This test modifies jaxp.properties in the used JDK.
      */
     private static void testJAXPProperties() throws IOException {
         generateJAXPProps(createJAXPPropsContent());
@@ -73,7 +149,7 @@
     }
 
     /*
-     * Tests how does system properties affects the resolution.
+     * Tests how system properties affects the resolution.
      */
     private static void testSystemProperties() {
         setSystemProperties();
@@ -104,7 +180,7 @@
     // The properties in jaxp.properties don't use default values
     private static String createJAXPPropsContent() {
         Map<String, String> props = new HashMap<>();
-        props.put(FEATURE_FILES, getCatalogPath(CATALOG_PROPERTIES));
+        props.put(FEATURE_FILES, getCatalogPath(CATALOG_PROPERTIES).toString());
         props.put(FEATURE_DEFER, DEFER_FALSE);
         props.put(FEATURE_PREFER, PREFER_SYSTEM);
         props.put(FEATURE_RESOLVE, RESOLVE_CONTINUE);
@@ -113,7 +189,7 @@
 
     // The system properties don't use default values
     private static void setSystemProperties() {
-        System.setProperty(FEATURE_FILES, getCatalogPath(CATALOG_PROPERTIES));
+        System.setProperty(FEATURE_FILES, getCatalogPath(CATALOG_PROPERTIES).toString());
         System.setProperty(FEATURE_DEFER, DEFER_FALSE);
         System.setProperty(FEATURE_PREFER, PREFER_SYSTEM);
         System.setProperty(FEATURE_RESOLVE, RESOLVE_CONTINUE);
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-
-# @test
-# @bug 8077931
-# @summary This case tests if the properties FILES, DEFER, PREFER, RESOLVE in
-#          jaxp.properties and system properties could be used.
-# @key intermittent
-# @library ../../libs/
-# @build catalog.CatalogTestUtils
-# @build PropertiesTest
-# @run shell/timeout=600 ../IsolatedJDK.sh JAXP_PROPS
-# @run shell/timeout=600 PropertiesTest.sh
-
-echo "Copies properties.xml to class path"
-TEST_CATALOG_PATH=${TESTCLASSES}/catalog/catalogFiles
-echo "TEST_CATALOG_PATH=${TEST_CATALOG_PATH}"
-mkdir -p ${TEST_CATALOG_PATH}
-cp ${TESTSRC}/catalogFiles/properties.xml ${TEST_CATALOG_PATH}/properties.xml
-
-# Execute test
-ISOLATED_JDK=./ISOLATED_JDK_JAXP_PROPS
-echo "Executes PropertiesTest"
-${ISOLATED_JDK}/bin/java -Dtest.src="${TESTSRC}/.." ${TESTVMOPTS} -cp "${TESTCLASSPATH}" catalog.PropertiesTest
-exitCode=$?
-
-# Cleanup ISOLATED_JDK
-rm -rf ${ISOLATED_JDK}
-
-# Results
-echo ''
-if [ $exitCode -gt 0 ]; then
-  echo "PropertiesTest failed";
-else
-  echo "PropertiesTest passed";
-fi
-exit $exitCode
-
--- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java	Wed Jul 05 22:46:04 2017 +0200
@@ -69,12 +69,6 @@
     private static final String JAXP_PROPS = "jaxp.properties";
     private static final String JAXP_PROPS_BAK = JAXP_PROPS + ".bak";
 
-    /*
-     * Force using slash as File separator as we always use cygwin to test in
-     * Windows platform.
-     */
-    private static final String FILE_SEP = "/";
-
     private CatalogTestUtils() { }
 
     /* ********** create resolver ********** */
@@ -133,11 +127,14 @@
     /* ********** jaxp.properties ********** */
 
     /*
-     * Generates the jaxp.properties with the specified content.
+     * Generates jaxp.properties with the specified content,
+     * takes a backup if possible.
      */
     static void generateJAXPProps(String content) throws IOException {
         Path filePath = getJAXPPropsPath();
         Path bakPath = filePath.resolveSibling(JAXP_PROPS_BAK);
+        System.out.println("Creating new file " + filePath +
+            ", saving old version to " + bakPath + ".");
         if (Files.exists(filePath) && !Files.exists(bakPath)) {
             Files.move(filePath, bakPath);
         }
@@ -146,14 +143,16 @@
     }
 
     /*
-     * Deletes the jaxp.properties.
+     * Deletes jaxp.properties, restoring backup if possible.
      */
     static void deleteJAXPProps() throws IOException {
         Path filePath = getJAXPPropsPath();
+        Path bakPath = filePath.resolveSibling(JAXP_PROPS_BAK);
+        System.out.println("Removing file " + filePath +
+                ", restoring old version from " + bakPath + ".");
         Files.delete(filePath);
-        Path bakFilePath = filePath.resolveSibling(JAXP_PROPS_BAK);
-        if (Files.exists(bakFilePath)) {
-            Files.move(bakFilePath, filePath);
+        if (Files.exists(bakPath)) {
+            Files.move(bakPath, filePath);
         }
     }
 
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -85,13 +85,13 @@
      * A map storing every test's current test file pointer. File number should
      * be incremental and it's a thread-safe reading on this file number.
      */
-    private static final ConcurrentHashMap<Class, Integer> currentFileNumber
+    private static final ConcurrentHashMap<Class<?>, Integer> currentFileNumber
                 = new ConcurrentHashMap<>();
 
     /**
      * BOM table for storing BOM header.
      */
-    private final static Map<String, byte[]> bom = new HashMap();
+    private final static Map<String, byte[]> bom = new HashMap<>();
 
     /**
      * Initialize all BOM headers.
@@ -313,7 +313,7 @@
      * @param clazz test class.
      * @return next test output file name.
      */
-    public static String getNextFile(Class clazz) {
+    public static String getNextFile(Class<?> clazz) {
         int nextNumber = currentFileNumber.contains(clazz)
                 ? currentFileNumber.get(clazz) + 1 : 1;
         Integer i = currentFileNumber.putIfAbsent(clazz, nextNumber);
@@ -332,7 +332,7 @@
      *        path.
      * @return a string represents the full path of accessing path.
      */
-    public static String getPathByClassName(Class clazz, String relativeDir) {
+    public static String getPathByClassName(Class<?> clazz, String relativeDir) {
         String javaSourcePath = System.getProperty("test.src").replaceAll("\\" + File.separator, FILE_SEP);
         String normalizedPath = Paths.get(javaSourcePath, relativeDir).normalize().
                 toAbsolutePath().toString();
@@ -435,7 +435,7 @@
      */
     public static void runWithTmpPermission(Runnable r, Permission... ps) {
         JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
-        List<Integer> tmpPermissionIndexes = new ArrayList();
+        List<Integer> tmpPermissionIndexes = new ArrayList<>();
         if (policyManager != null) {
             for (Permission p : ps)
                 tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
@@ -459,7 +459,7 @@
      */
     public static <T> T runWithTmpPermission(Supplier<T> s, Permission... ps) {
         JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
-        List<Integer> tmpPermissionIndexes = new ArrayList();
+        List<Integer> tmpPermissionIndexes = new ArrayList<>();
         if (policyManager != null) {
             for (Permission p : ps)
                 tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
@@ -483,7 +483,7 @@
      */
     public static void tryRunWithTmpPermission(RunnableWithException r, Permission... ps) throws Exception {
         JAXPPolicyManager policyManager = JAXPPolicyManager.getJAXPPolicyManager(false);
-        List<Integer> tmpPermissionIndexes = new ArrayList();
+        List<Integer> tmpPermissionIndexes = new ArrayList<>();
         if (policyManager != null) {
             for (Permission p : ps)
                 tmpPermissionIndexes.add(policyManager.addTmpPermission(p));
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogFileInputTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -222,6 +222,8 @@
         String catalogUri = getClass().getResource("catalog_invalid.xml").toExternalForm();
         return new Object[][]{
             {catalogUri, "-//W3C//DTD XHTML 1.0 Strict//EN",
+                "The catalog is invalid, attempting to match the public entry shall return null."},
+            {"file:/../../..", "-//W3C//DTD XHTML 1.0 Strict//EN",
                 "The catalog is invalid, attempting to match the public entry shall return null."}
         };
     }
@@ -239,7 +241,6 @@
         return new Object[][]{
             {""},
             {"file:a/b\\c"},
-            {"file:/../../.."},
             {"c:/te:t"},
             {"c:/te?t"},
             {"c/te*t"},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/stream/EventsTest/EventFilterSupportTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package stream.EventsTest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @test
+ * @bug 8173111
+ * @summary tests that filtering out nested elements doesn't end up in
+ *          a StackOverflowException
+ * @run testng/othervm stream.EventsTest.EventFilterSupportTest
+ * @author danielfuchs
+ */
+public class EventFilterSupportTest {
+    static final String ROOT = "xml";
+    static final String NEXT = "foo";
+    static final String SMOKE = "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"
+            + "<xml><foo><foo><foo></foo></foo></foo></xml>";
+    // A number high enough to trigger StackOverflowException before the fix.
+    static final int MAX = 100_000;
+
+    public static void main(String[] args)
+            throws XMLStreamException, IOException {
+        smokeTest();
+        testNextEvent(MAX);
+        testNextTag(MAX);
+        System.out.println("Tests passed...");
+    }
+
+    // The smoke test just verifies that our TestInputStream works as
+    // expected and produces the expected stream of characters.
+    // Here we test it with 4 nested elements.
+    @Test
+    public static void smokeTest() throws IOException {
+        System.out.println("\nSmoke test...");
+        StringBuilder sb = new StringBuilder();
+        try (InputStream ts = new TestInputStream(4)) {
+            int c;
+            while ((c = ts.read()) != -1) {
+                System.out.print((char)c);
+                sb.append((char)c);
+            }
+        }
+        assertEquals(sb.toString(), SMOKE, "Smoke test failed");
+        System.out.println("\nSmoke test passed\n");
+    }
+
+    // Test calling XMLEventReader.nextEvent()
+    @Test
+    public static void testNextEvent() throws IOException, XMLStreamException {
+        testNextEvent(MAX);
+    }
+
+    // Without the fix, will cause a StackOverflowException if 'max' is high
+    // enough
+    private static void testNextEvent(int max)
+            throws IOException, XMLStreamException {
+        System.out.println("\nTest nextEvent (" + max + ")...");
+        XMLEventReader reader = createXmlReader(max);
+        XMLEvent event;
+        do {
+            event = reader.nextEvent();
+            System.out.println(event);
+        } while (event.getEventType() != XMLEvent.END_DOCUMENT);
+        System.out.println("nextEvent passed\n");
+    }
+
+    // Test calling XMLEventReader.nextTag()
+    @Test
+    public static void testNextTag() throws IOException, XMLStreamException {
+        testNextTag(MAX);
+    }
+
+    // Without the fix, will cause a StackOverflowException if 'max' is high
+    // enough
+    private static void testNextTag(int max)
+            throws IOException, XMLStreamException {
+        System.out.println("\nTest nextTag (" + max + ")...");
+        XMLEventReader reader = createXmlReader(max);
+        XMLEvent event;
+        do {
+            event = reader.nextTag();
+            System.out.println(event);
+            if (event.getEventType() == XMLEvent.END_ELEMENT
+                && event.asEndElement().getName().getLocalPart().equals(ROOT)) {
+                break;
+            }
+        } while (true);
+        System.out.println("nextTag passed\n");
+    }
+
+    private static XMLEventReader createXmlReader(int max)
+            throws XMLStreamException {
+        TestInputStream ts = new TestInputStream(max);
+        XMLInputFactory xif = XMLInputFactory.newInstance();
+        XMLEventReader reader = xif.createXMLEventReader(ts);
+        return xif.createFilteredReader(reader, new TagFilter(max));
+    }
+
+    // An input stream that pretends to contain 'max - 1' nested NEXT tags
+    // within a ROOT element:
+    // <?xml version="1.0" encoding="US-ASCII"?>
+    // <ROOT><NEXT><NEXT>...</NEXT></NEXT></ROOT>
+    // (1 ROOT element + max-1 nested NEXT elements)
+    public static class TestInputStream extends InputStream {
+
+        int open = 0;
+        int i = 0;
+        int n = 0;
+        final int max;
+
+        public TestInputStream(int max) {
+            this.max = max;
+        }
+
+        String tag() {
+            if (n == 0) {
+                // opening first element - includes the XML processing instruction.
+                return "?xml version=\"1.0\" encoding=\"US-ASCII\"?><" + ROOT;
+            }
+            if (n == 2 * max -1) {
+                // closing the first element
+                // we have 'max' opening tags (0..max-1) followed by
+                // 'max' closing tags (max..2*max-1)
+                // for n in [0..max-1] we open the tags,
+                // for n in [max..2*max-1] we close them (in reverse order)
+                return ROOT;
+            }
+            // everything between [1..max-2] is a NEXT element tag (opening
+            // or closing)
+            return NEXT;
+        }
+
+        @Override
+        public int read() throws IOException {
+            if (n >= 2 * max) return -1;
+            if (open == 0) {
+                open = 1;
+                return '<';
+            }
+            if (open == 1 && n >= max) {
+                // we have opened the ROOT element + n-1 nested NEXT elements,
+                // so now we need to start closing them all in reverse order.
+                open = 2;
+                return '/';
+            }
+            String tag = tag();
+            if (open > 0 && i < tag.length()) {
+                return tag.charAt(i++);
+            }
+            if (open > 0 && i == tag.length()) {
+                open = 0; i = 0; n++;
+                return '>';
+            }
+            return -1;
+        }
+    }
+
+    public static final class TagFilter implements EventFilter {
+        int count;
+        final int max;
+
+        public TagFilter(int max) {
+            this.max = max;
+        }
+
+        // Filters everything except the ROOT element.
+        @Override
+        public boolean accept(XMLEvent event) {
+            int type = event.getEventType();
+            if (type == XMLEvent.START_ELEMENT) {
+                String loc = event.asStartElement().getName().getLocalPart();
+                if (count == 0 || count == 1) System.out.println("<" + loc + ">");
+                count++;
+                return ROOT.equals(loc);
+            }
+            if (type == XMLEvent.END_ELEMENT) {
+                if (count == max) System.out.println("Got " + count + " elements");
+                String loc = event.asEndElement().getName().getLocalPart();
+                count--;
+                if (count == 0 || count == 1) System.out.println("</" + loc + ">");
+                return ROOT.equals(loc);
+            }
+            if (type == XMLEvent.PROCESSING_INSTRUCTION) return true;
+            if (type == XMLEvent.START_DOCUMENT) return true;
+            if (type == XMLEvent.END_DOCUMENT) return true;
+            return false;
+        }
+    }
+
+}
--- a/jdk/.hgtags	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/.hgtags	Wed Jul 05 22:46:04 2017 +0200
@@ -396,3 +396,4 @@
 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151
 a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152
 1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153
+c97e7a8b8da062b9070df442f9cf308e10845fb7 jdk-9+154
--- a/jdk/make/gensrc/GensrcLocaleData.gmk	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/make/gensrc/GensrcLocaleData.gmk	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -89,8 +89,8 @@
   $1_NON_BASE_LOCALES := $$(subst zh-MO,zh-MO$$(SPACE)zh-Hant-MO, $$($1_NON_BASE_LOCALES))
   $1_NON_BASE_LOCALES := $$(subst zh-TW,zh-TW$$(SPACE)zh-Hant-TW, $$($1_NON_BASE_LOCALES))
 
-# Adding implict locales nn-NO and nb-NO
-  $1_NON_BASE_LOCALES += nn-NO  nb-NO
+# Adding implict locales nb nn-NO and nb-NO
+  $1_NON_BASE_LOCALES += nb  nn-NO  nb-NO
   $1_NON_BASE_LOCALES := $$(sort $$($1_NON_BASE_LOCALES))
 
   ALL_BASE_LOCALES += $$($1_BASE_LOCALES)
--- a/jdk/make/lib/CoreLibraries.gmk	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/make/lib/CoreLibraries.gmk	Wed Jul 05 22:46:04 2017 +0200
@@ -387,6 +387,7 @@
         -export:JLI_MemFree \
         -export:JLI_InitArgProcessing \
         -export:JLI_PreprocessArg \
+        -export:JLI_AddArgsFromEnvVar \
         -export:JLI_GetAppArgIndex, \
     LIBS_unix := $(LIBZ), \
     LIBS_linux := $(LIBDL) -lc -lpthread, \
--- a/jdk/make/lib/Lib-jdk.sctp.gmk	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/make/lib/Lib-jdk.sctp.gmk	Wed Jul 05 22:46:04 2017 +0200
@@ -30,9 +30,6 @@
 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
 
   ifeq (, $(filter $(OPENJDK_TARGET_OS), macosx aix))
-    # DISABLED_WARNINGS_gcc := unused-parameter needed to
-    # suppress unused parameters required by exported JNI functions.
-
     $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP, \
         LIBRARY := sctp, \
         OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
@@ -45,7 +42,6 @@
             $(LIBJAVA_HEADER_FLAGS) \
             -I$(SUPPORT_OUTPUTDIR)/headers/jdk.sctp \
             -I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
-        DISABLED_WARNINGS_gcc := unused-parameter, \
         MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libsctp/mapfile-vers, \
         LDFLAGS := $(LDFLAGS_JDKLIB) \
             $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/jdk/make/mapfiles/libjli/mapfile-vers	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/make/mapfiles/libjli/mapfile-vers	Wed Jul 05 22:46:04 2017 +0200
@@ -42,6 +42,7 @@
 		JLI_MemFree;
 		JLI_InitArgProcessing;
 		JLI_PreprocessArg;
+		JLI_AddArgsFromEnvVar;
 		JLI_GetAppArgIndex;
 
 	local:
--- a/jdk/make/src/classes/build/tools/cldrconverter/Bundle.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/make/src/classes/build/tools/cldrconverter/Bundle.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -389,6 +389,18 @@
                 }
             }
         }
+        // replace empty era names with parentMap era names
+        for (String key : ERA_KEYS) {
+            Object value = myMap.get(key);
+            if (value != null && value instanceof String[]) {
+                String[] eraStrings = (String[]) value;
+                for (String eraString : eraStrings) {
+                    if (eraString == null || eraString.isEmpty()) {
+                        fillInElements(parentsMap, key, value);
+                    }
+                }
+            }
+        }
 
         // Remove all duplicates
         if (Objects.nonNull(parentsMap)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/src/classes/build/tools/taglet/Incubating.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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 build.tools.taglet;
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.doclet.taglet.Taglet;
+import static jdk.javadoc.doclet.taglet.Taglet.Location.*;
+
+/**
+ * An inline tag to conveniently insert a standard Incubating warning.  For
+ * use by members in Incubator Modules.
+ */
+public class Incubating implements Taglet {
+
+    /** Returns the set of locations in which a taglet may be used. */
+    @Override
+    public Set<Location> getAllowedLocations() {
+        return EnumSet.of(OVERVIEW, MODULE, PACKAGE, TYPE);
+    }
+
+    @Override
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    @Override
+    public String getName() {
+        return "Incubating";
+    }
+
+    private static final String MESSAGE =
+        "<BR><b><a href=\"http://openjdk.java.net/jeps/11\">Incubating Feature.</a>"
+                + " Will be removed in a future release.</b>";
+
+    @Override
+    public String toString(DocTree tag) {
+        return MESSAGE;
+    }
+
+    @Override
+    public String toString(List<? extends DocTree> tags) {
+        return MESSAGE;
+    }
+}
+
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/OutputFeedback.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/OutputFeedback.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -162,11 +162,11 @@
             for (int i = 0; i < numBytes; i++) {
                 cipher[i + cipherOffset] =
                     (byte)(k[i] ^ plain[i + plainOffset]);
-                if (nShift != 0) {
-                    System.arraycopy(register, numBytes, register, 0, nShift);
-                }
-                System.arraycopy(k, 0, register, nShift, numBytes);
             }
+            if (nShift != 0) {
+                System.arraycopy(register, numBytes, register, 0, nShift);
+            }
+            System.arraycopy(k, 0, register, nShift, numBytes);
         }
         return plainLen;
     }
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -66,16 +66,16 @@
  * refer to a directory. Otherwise, the URL is assumed to refer to a JAR file
  * which will be opened as needed.
  * <p>
+ * This class loader supports the loading of classes and resources from the
+ * contents of a <a href="../util/jar/JarFile.html#multirelease">multi-release</a>
+ * JAR file that is referred to by a given URL.
+ * <p>
  * The AccessControlContext of the thread that created the instance of
  * URLClassLoader will be used when subsequently loading classes and
  * resources.
  * <p>
  * The classes that are loaded are by default granted permission only to
  * access the URLs specified when the URLClassLoader was created.
- * <p>
- * This class loader supports the loading of classes from the contents of a
- * <a href="../util/jar/JarFile.html#multirelease">multi-release</a> JAR file
- * that is referred to by a given URL.
  *
  * @author  David Connelly
  * @since   1.2
--- a/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -71,7 +71,7 @@
  * following standard {@code AlgorithmParameterGenerator} algorithms and
  * keysizes in parentheses:
  * <ul>
- * <li>{@code DiffieHellman} (1024, 2048, 4096)</li>
+ * <li>{@code DiffieHellman} (1024, 2048)</li>
  * <li>{@code DSA} (1024, 2048)</li>
  * </ul>
  * These algorithms are described in the <a href=
--- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java	Wed Jul 05 22:46:04 2017 +0200
@@ -61,7 +61,10 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.jar.JarEntry;
+import java.util.spi.ResourceBundleControlProvider;
 import java.util.spi.ResourceBundleProvider;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import jdk.internal.loader.BootLoader;
 import jdk.internal.misc.JavaUtilResourceBundleAccess;
@@ -232,6 +235,8 @@
  * <li>{@code ResourceBundle.Control} is <em>not</em> supported in named modules.
  * If the {@code getBundle} method with a {@code ResourceBundle.Control} is called
  * in a named module, the method will throw an {@code UnsupportedOperationException}.
+ * Any service providers of {@link ResourceBundleControlProvider} are ignored in
+ * named modules.
  * </li>
  * </ul>
  *
@@ -262,6 +267,18 @@
  * {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
  * factory method for details.
  *
+ * <p><a name="modify_default_behavior">For the {@code getBundle} factory</a>
+ * methods that take no {@link Control} instance, their <a
+ * href="#default_behavior"> default behavior</a> of resource bundle loading
+ * can be modified with custom {@link
+ * ResourceBundleControlProvider} implementations.
+ * If any of the
+ * providers provides a {@link Control} for the given base name, that {@link
+ * Control} will be used instead of the default {@link Control}. If there is
+ * more than one service provider for supporting the same base name,
+ * the first one returned from {@link ServiceLoader} will be used.
+ * A custom {@link Control} implementation is ignored by named modules.
+ *
  * <h3>Cache Management</h3>
  *
  * Resource bundle instances created by the <code>getBundle</code> factory
@@ -367,7 +384,8 @@
                 public ResourceBundle getBundle(String baseName, Locale locale, Module module) {
                     // use the given module as the caller to bypass the access check
                     return getBundleImpl(module, module,
-                                         baseName, locale, Control.INSTANCE);
+                                         baseName, locale,
+                                         getDefaultControl(module, baseName));
                 }
 
                 @Override
@@ -815,7 +833,7 @@
     {
         Class<?> caller = Reflection.getCallerClass();
         return getBundleImpl(baseName, Locale.getDefault(),
-                             caller, Control.INSTANCE);
+                             caller, getDefaultControl(caller, baseName));
     }
 
     /**
@@ -889,7 +907,7 @@
     {
         Class<?> caller = Reflection.getCallerClass();
         return getBundleImpl(baseName, locale,
-                             caller, Control.INSTANCE);
+                             caller, getDefaultControl(caller, baseName));
     }
 
     /**
@@ -925,7 +943,8 @@
     @CallerSensitive
     public static ResourceBundle getBundle(String baseName, Module module) {
         return getBundleFromModule(Reflection.getCallerClass(), module, baseName,
-                                   Locale.getDefault(), Control.INSTANCE);
+                                   Locale.getDefault(),
+                                   getDefaultControl(module, baseName));
     }
 
     /**
@@ -953,7 +972,9 @@
      * equivalent to calling {@link #getBundle(String, Locale, ClassLoader)
      * getBundle(baseName, targetLocale, module.getClassLoader()} to load
      * resource bundles that are visible to the class loader of the given
-     * unnamed module.
+     * unnamed module. Custom {@link java.util.spi.ResourceBundleControlProvider}
+     * implementations, if present, will only be invoked if the specified
+     * module is an unnamed module.
      *
      * @param baseName the base name of the resource bundle,
      *                 a fully qualified class name
@@ -974,7 +995,7 @@
     @CallerSensitive
     public static ResourceBundle getBundle(String baseName, Locale targetLocale, Module module) {
         return getBundleFromModule(Reflection.getCallerClass(), module, baseName, targetLocale,
-                                   Control.INSTANCE);
+                                   getDefaultControl(module, baseName));
     }
 
     /**
@@ -1030,7 +1051,10 @@
      *
      * <p>This method behaves the same as calling
      * {@link #getBundle(String, Locale, ClassLoader, Control)} passing a
-     * default instance of {@link Control}.
+     * default instance of {@link Control} unless another {@link Control} is
+     * provided with the {@link ResourceBundleControlProvider} SPI. Refer to the
+     * description of <a href="#modify_default_behavior">modifying the default
+     * behavior</a>.
      *
      * <p><a name="default_behavior">The following describes the default
      * behavior</a>.
@@ -1228,7 +1252,7 @@
             throw new NullPointerException();
         }
         Class<?> caller = Reflection.getCallerClass();
-        return getBundleImpl(baseName, locale, caller, loader, Control.INSTANCE);
+        return getBundleImpl(baseName, locale, caller, loader, getDefaultControl(caller, baseName));
     }
 
     /**
@@ -1453,6 +1477,39 @@
         return getBundleImpl(baseName, targetLocale, caller, loader, control);
     }
 
+    private static Control getDefaultControl(Class<?> caller, String baseName) {
+        return getDefaultControl(caller.getModule(), baseName);
+    }
+
+    private static Control getDefaultControl(Module targetModule, String baseName) {
+        return targetModule.isNamed() ?
+            Control.INSTANCE :
+            ResourceBundleControlProviderHolder.getControl(baseName);
+    }
+
+    private static class ResourceBundleControlProviderHolder {
+        private static final PrivilegedAction<List<ResourceBundleControlProvider>> pa =
+            () -> {
+                return Collections.unmodifiableList(
+                    ServiceLoader.load(ResourceBundleControlProvider.class,
+                                       ClassLoader.getSystemClassLoader()).stream()
+                        .map(ServiceLoader.Provider::get)
+                        .collect(Collectors.toList()));
+            };
+
+        private static final List<ResourceBundleControlProvider> CONTROL_PROVIDERS =
+            AccessController.doPrivileged(pa);
+
+        private static Control getControl(String baseName) {
+            return CONTROL_PROVIDERS.isEmpty() ?
+                Control.INSTANCE :
+                CONTROL_PROVIDERS.stream()
+                    .flatMap(provider -> Stream.ofNullable(provider.getControl(baseName)))
+                    .findFirst()
+                    .orElse(Control.INSTANCE);
+        }
+    }
+
     private static void checkNamedModule(Class<?> caller) {
         if (caller.getModule().isNamed()) {
             throw new UnsupportedOperationException(
@@ -2414,7 +2471,8 @@
      * @apiNote <a name="note">{@code ResourceBundle.Control} is not supported
      * in named modules.</a> If the {@code ResourceBundle.getBundle} method with
      * a {@code ResourceBundle.Control} is called in a named module, the method
-     * will throw an {@link UnsupportedOperationException}.
+     * will throw an {@link UnsupportedOperationException}. Any service providers
+     * of {@link ResourceBundleControlProvider} are ignored in named modules.
      *
      * @since 1.6
      * @see java.util.spi.ResourceBundleProvider
--- a/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/spi/ResourceBundleControlProvider.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -35,19 +35,19 @@
  * no {@link java.util.ResourceBundle.Control} instance can be modified with {@code
  * ResourceBundleControlProvider} implementations.
  *
+ * <p>Provider implementations are loaded from the application's class path
+ * using {@link java.util.ServiceLoader} at the first invocation of the
+ * {@code ResourceBundle.getBundle} factory method that takes no
+ * {@link java.util.ResourceBundle.Control} instance.
+ *
+ * <p>All {@code ResourceBundleControlProvider}s are ignored in named modules.
+ *
  * @author Masayoshi Okutsu
  * @since 1.8
  * @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control)
  *      ResourceBundle.getBundle
- * @see java.util.ServiceLoader#loadInstalled(Class)
- * @deprecated There is no longer any mechanism to install a custom
- * {@code ResourceBundleControlProvider} implementation defined
- * by the platform class loader or its ancestor. The recommended
- * way to use a custom {@code Control} implementation to load resource bundle
- * is to use {@link java.util.ResourceBundle#getBundle(String, Control)}
- * or other factory methods that take custom {@link java.util.ResourceBundle.Control}.
+ * @see java.util.ServiceLoader#load(Class)
  */
-@Deprecated(since="9", forRemoval=true)
 public interface ResourceBundleControlProvider {
     /**
      * Returns a {@code ResourceBundle.Control} instance that is used
--- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurityManager.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 package javax.crypto;
 
+import java.lang.reflect.Module;
 import java.security.*;
 import java.net.*;
 import java.util.*;
@@ -227,38 +228,55 @@
         return (CryptoPermission)enum_.nextElement();
     }
 
-    // See  bug 4341369 & 4334690 for more info.
+    // Only used by javax.crypto.Cipher constructor to disallow Cipher
+    // objects being constructed by untrusted code (See bug 4341369 &
+    // 4334690 for more info).
     boolean isCallerTrusted(Provider provider) {
-        if (ProviderVerifier.isTrustedCryptoProvider(provider)) {
-            // fast path
-            return true;
-        }
-
         // Get the caller and its codebase.
         Class<?>[] context = getClassContext();
-        URL callerCodeBase = null;
-        int i;
-        for (i=0; i<context.length; i++) {
-            callerCodeBase = JceSecurity.getCodeBase(context[i]);
-            if (callerCodeBase != null) {
-                break;
+        if (context.length >= 3) {
+            // context[0]: class javax.crypto.JceSecurityManager
+            // context[1]: class javax.crypto.Cipher (or other JCE API class)
+            // context[2]: this is what we are gonna check
+            Class<?> caller = context[2];
+            URL callerCodeBase = JceSecurity.getCodeBase(caller);
+            if (callerCodeBase == null) {
+                return true;
+            }
+            // The caller has been verified.
+            if (TrustedCallersCache.contains(caller)) {
+                return true;
             }
-        }
-        // The caller is in the JCE framework.
-        if (i == context.length) {
+
+            // Check the association between caller and provider
+            Class<?> pCls = provider.getClass();
+            Module pMod = pCls.getModule();
+            // If they are in the same named module or share
+            // the same codebase, then they are associated
+            boolean sameOrigin = (pMod.isNamed()?
+                caller.getModule().equals(pMod) :
+                callerCodeBase.equals(JceSecurity.getCodeBase(pCls)));
+            if (sameOrigin) {
+                // The caller is from trusted provider
+                if (ProviderVerifier.isTrustedCryptoProvider(provider)) {
+                    TrustedCallersCache.addElement(caller);
+                    return true;
+                }
+            } else {
+                // Don't include the provider in the subsequent
+                // JceSecurity.verifyProvider(...) call
+                provider = null;
+            }
+
+            // Check whether the caller is a trusted provider.
+            try {
+                JceSecurity.verifyProvider(callerCodeBase, provider);
+            } catch (Exception e2) {
+                return false;
+            }
+            TrustedCallersCache.addElement(caller);
             return true;
         }
-        //The caller has been verified.
-        if (TrustedCallersCache.contains(context[i])) {
-            return true;
-        }
-        // Check whether the caller is a trusted provider.
-        try {
-            JceSecurity.verifyProvider(callerCodeBase, provider);
-        } catch (Exception e2) {
-            return false;
-        }
-        TrustedCallersCache.addElement(context[i]);
-        return true;
+        return false;
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Wed Jul 05 22:46:04 2017 +0200
@@ -53,21 +53,21 @@
     // the input stream to read the original module-info.class
     private final InputStream in;
 
-    // the packages in the Packages attribute
+    // the packages in the ModulePackages attribute
     private Set<String> packages;
 
-    // the value of the Version attribute
+    // the value of the module_version in Module attribute
     private Version version;
 
-    // the value of the MainClass attribute
+    // the value of the ModuleMainClass attribute
     private String mainClass;
 
-    // the values for the TargetPlatform attribute
+    // the values for the ModuleTarget attribute
     private String osName;
     private String osArch;
     private String osVersion;
 
-    // the hashes for the Hashes attribute
+    // the hashes for the ModuleHashes attribute
     private ModuleHashes hashes;
 
     // the value of the ModuleResolution attribute
@@ -78,7 +78,7 @@
     }
 
     /**
-     * Sets the set of packages for the Packages attribute
+     * Sets the set of packages for the ModulePackages attribute
      */
     public ModuleInfoExtender packages(Set<String> packages) {
         this.packages = Collections.unmodifiableSet(packages);
@@ -86,7 +86,7 @@
     }
 
     /**
-     * Sets the value of the Version attribute.
+     * Sets the value of the module_version in Module attribute.
      */
     public ModuleInfoExtender version(Version version) {
         this.version = version;
@@ -94,7 +94,7 @@
     }
 
     /**
-     * Sets the value of the MainClass attribute.
+     * Sets the value of the ModuleMainClass attribute.
      */
     public ModuleInfoExtender mainClass(String mainClass) {
         this.mainClass = mainClass;
@@ -102,7 +102,7 @@
     }
 
     /**
-     * Sets the values for the TargetPlatform attribute.
+     * Sets the values for the ModuleTarget attribute.
      */
     public ModuleInfoExtender targetPlatform(String osName,
                                              String osArch,
@@ -114,7 +114,7 @@
     }
 
     /**
-     * The Hashes attribute will be emitted to the module-info with
+     * The ModuleHashes attribute will be emitted to the module-info with
      * the hashes encapsulated in the given {@code ModuleHashes}
      * object.
      */
--- a/jdk/src/java.base/share/classes/module-info.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/module-info.java	Wed Jul 05 22:46:04 2017 +0200
@@ -154,7 +154,6 @@
         jdk.jartool,
         jdk.jlink;
     exports jdk.internal.misc to
-        java.corba,
         java.desktop,
         jdk.incubator.httpclient,
         java.logging,
@@ -183,7 +182,6 @@
         java.desktop,
         jdk.unsupported;
     exports jdk.internal.reflect to
-        java.corba,
         java.logging,
         java.sql,
         java.sql.rowset,
@@ -232,7 +230,6 @@
     exports sun.reflect.generics.reflectiveObjects to
         java.desktop;
     exports sun.reflect.misc to
-        java.corba,
         java.desktop,
         java.datatransfer,
         java.management,
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -117,7 +117,6 @@
 \    -Xdebug           provided for backward compatibility\n\
 \    -Xdiag            show additional diagnostic messages\n\
 \    -Xdiag:resolver   show resolver diagnostic messages\n\
-\    -Xdisable-@files  disable further argument file expansion\n\
 \    -Xfuture          enable strictest checks, anticipating future default\n\
 \    -Xint             interpreted mode execution only\n\
 \    -Xinternalversion\n\
@@ -158,6 +157,7 @@
 \    --add-opens <module>/<package>=<target-module>(,<target-module>)*\n\
 \                      updates <module> to open <package> to\n\
 \                      <target-module>, regardless of module declaration.\n\
+\    --disable-@files  disable further argument file expansion\n\
 \    --patch-module <module>=<file>({0}<file>)*\n\
 \                      Override or augment a module with classes and resources\n\
 \                      in JAR files or directories.\n\n\
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_de.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -38,7 +38,7 @@
 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:<Verzeichnisse und ZIP-/JAR-Dateien durch {0} getrennt>\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    -Xdisable-@files  Deaktiviert das weitere Einblenden der Argumentdatei\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:<file>    Protokolliert GC-Status in einer Datei mit Zeitstempeln\n    -Xmixed           Ausf\u00FChrung im gemischten Modus (Standard)\n    -Xmn<size>        Setzt die anf\u00E4ngliche und maximale Gr\u00F6\u00DFe (in Byte) des Heaps\n                      f\u00FCr die junge Generation (Nursery)\n    -Xms<size>        Setzt die anf\u00E4ngliche Java-Heap-Gr\u00F6\u00DFe\n    -Xmx<size>        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<size>        Setzt Stackgr\u00F6\u00DFe des Java-Threads\n    -Xverify          Setzt den Modus der Bytecodeverifizierung\n    --add-reads <Modul>=<Zielmodul>(,<Zielmodul>)*\n                      Aktualisiert <Modul>, damit <Zielmodul> gelesen wird, ungeachtet \n                      der Moduldeklaration. \n                      <Zielmodul> kann ALL-UNNAMED sein, um alle unbenannten\n                      Module zu lesen.\n    --add-exports <Modul>/<Package>=<Zielmodul>(,<Zielmodul>)*\n                      Aktualisiert <Modul>, um <Package> in <Zielmodul> zu exportieren,\n                      ungeachtet der Moduldeklaration.\n                      <Zielmodul> kann ALL-UNNAMED sein, um in alle \n                      unbenannten Module zu exportieren.\n    --patch-module <Modul>=<Datei>({0}<Datei>)*\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=\    -Xbatch           Deaktiviert Hintergrundkompilierung\n    -Xbootclasspath/a:<Verzeichnisse und ZIP-/JAR-Dateien durch {0} getrennt>\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:<file>    Protokolliert GC-Status in einer Datei mit Zeitstempeln\n    -Xmixed           Ausf\u00FChrung im gemischten Modus (Standard)\n    -Xmn<size>        Setzt die anf\u00E4ngliche und maximale Gr\u00F6\u00DFe (in Byte) des Heaps\n                      f\u00FCr die junge Generation (Nursery)\n    -Xms<size>        Setzt die anf\u00E4ngliche Java-Heap-Gr\u00F6\u00DFe\n    -Xmx<size>        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<size>        Setzt Stackgr\u00F6\u00DFe des Java-Threads\n    -Xverify          Setzt den Modus der Bytecodeverifizierung\n    --add-reads <Modul>=<Zielmodul>(,<Zielmodul>)*\n                      Aktualisiert <Modul>, damit <Zielmodul> gelesen wird, ungeachtet \n                      der Moduldeklaration. \n                      <Zielmodul> kann ALL-UNNAMED sein, um alle unbenannten\n                      Module zu lesen.\n    --add-exports <Modul>/<Package>=<Zielmodul>(,<Zielmodul>)*\n                      Aktualisiert <Modul>, um <Package> in <Zielmodul> zu exportieren,\n                      ungeachtet der Moduldeklaration.\n                      <Zielmodul> kann ALL-UNNAMED sein, um in alle \n                      unbenannten Module zu exportieren.\n    --disable-@files  Deaktiviert das weitere Einblenden der Argumentdatei\n    --patch-module <Modul>=<Datei>({0}<Datei>)*\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
 
 # 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=<application name>\n                      Den im Dock angezeigten Standardanwendungsnamen \u00FCberschreiben\n    -Xdock:icon=<Pfad zu Symboldatei>\n                      Das im Dock angezeigte Standardsymbol \u00FCberschreiben\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_es.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<directorios y archivos zip/jar separados por {0}>\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    -Xdisable-@files  desactivar la ampliaci\u00F3n de archivos de m\u00E1s argumentos\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:<archivo>    registrar el estado de GC en un archivo con registros de hora\n    -Xmixed           ejecuci\u00F3n de modo mixto (por defecto)\n    -Xmn<tama\u00F1o>        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<size>        define el tama\u00F1o inicial de la pila de Java\n    -Xmx<size>        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<tama\u00F1o>        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 <m\u00F3dulo>=<m\u00F3dulo-destino>(,<m\u00F3dulo-destino>)*\n                      actualiza <m\u00F3dulo> para leer <m\u00F3dulo-destino>, independientemente\n                      de la declaraci\u00F3n del m\u00F3dulo. \n                      <m\u00F3dulo-destino> puede ser ALL-UNNAMED para leer todos los\n                      m\u00F3dulos sin nombre.\n    --add-exports <m\u00F3dulo>/<paquete>=<m\u00F3dulo-destino>(,<m\u00F3dulo-destino>)*\n                      actualiza <m\u00F3dulo> para exportar <paquete> en <m\u00F3dulo-destino>,\n                      independientemente de la declaraci\u00F3n del m\u00F3dulo.\n                      <m\u00F3dulo-destino> puede ser ALL-UNNAMED para exportar a todos los\n                      m\u00F3dulos sin nombre.\n    --patch-module <m\u00F3dulo>=<archivo>({0}<archivo>)*\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:<directorios y archivos zip/jar separados por {0}>\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:<archivo>    registrar el estado de GC en un archivo con registros de hora\n    -Xmixed           ejecuci\u00F3n de modo mixto (por defecto)\n    -Xmn<tama\u00F1o>        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<size>        define el tama\u00F1o inicial de la pila de Java\n    -Xmx<size>        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<tama\u00F1o>        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 <m\u00F3dulo>=<m\u00F3dulo-destino>(,<m\u00F3dulo-destino>)*\n                      actualiza <m\u00F3dulo> para leer <m\u00F3dulo-destino>, independientemente\n                      de la declaraci\u00F3n del m\u00F3dulo. \n                      <m\u00F3dulo-destino> puede ser ALL-UNNAMED para leer todos los\n                      m\u00F3dulos sin nombre.\n    --add-exports <m\u00F3dulo>/<paquete>=<m\u00F3dulo-destino>(,<m\u00F3dulo-destino>)*\n                      actualiza <m\u00F3dulo> para exportar <paquete> en <m\u00F3dulo-destino>,\n                      independientemente de la declaraci\u00F3n del m\u00F3dulo.\n                      <m\u00F3dulo-destino> 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 <m\u00F3dulo>=<archivo>({0}<archivo>)*\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
 
 # 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=<application name>\n                      sustituir al nombre por defecto de la aplicaci\u00F3n que se muestra en el Dock\n    -Xdock:icon=<ruta de acceso a archivo de icono>\n                      sustituir al icono por defecto que se muestra en el Dock\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_fr.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<r\u00E9pertoires et fichiers ZIP/JAR s\u00E9par\u00E9s par des {0}>\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    -Xdisable-@files  d\u00E9sactivation d''autres d\u00E9veloppements de fichier d''argument\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:<file>    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<size>        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<size>        d\u00E9finition de la taille initiale des portions de m\u00E9moire Java\n    -Xmx<size>        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<size>        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 <module>=<target-module>(,<target-module>)*\n                      met \u00E0 jour <module> pour lire <target-module>, sans tenir compte\n                      de la d\u00E9claration de module. \n                      <target-module> peut \u00EAtre ALL-UNNAMED pour lire tous les modules\n                      sans nom.\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      met \u00E0 jour <module> pour exporter <package> vers <target-module>,\n                      sans tenir compte de la d\u00E9claration de module.\n                      <target-module> peut \u00EAtre ALL-UNNAMED pour effectuer un export vers tous\n                      les modules sans nom.\n    --patch-module <module>=<file>({0}<file>)*\n                      Remplacement ou augmentation d''un module avec des classes et des ressources\n                      dans des \
+java.launcher.X.usage=\    -Xbatch           d\u00E9sactivation de la compilation en arri\u00E8re-plan\n    -Xbootclasspath/a:<r\u00E9pertoires et fichiers ZIP/JAR s\u00E9par\u00E9s par des {0}>\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:<file>    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<size>        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<size>        d\u00E9finition de la taille initiale des portions de m\u00E9moire Java\n    -Xmx<size>        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<size>        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 <module>=<target-module>(,<target-module>)*\n                      met \u00E0 jour <module> pour lire <target-module>, sans tenir compte\n                      de la d\u00E9claration de module. \n                      <target-module> peut \u00EAtre ALL-UNNAMED pour lire tous les modules\n                      sans nom.\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      met \u00E0 jour <module> pour exporter <package> vers <target-module>,\n                      sans tenir compte de la d\u00E9claration de module.\n                      <target-module> 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 <module>=<file>({0}<file>)*\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
 
 # Translators please note do not translate the options themselves
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_it.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<directory e file zip/jar separati da {0}>\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    -Xdisable-@files  disabilita l''ulteriore espansione del file di argomenti\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:<file>    registra lo stato GC in un file con indicatori orari\n    -Xmixed           esecuzione in modalit\u00E0 mista (impostazione predefinita)\n    -Xmn<size>        imposta le dimensioni iniziale e massima (in byte) dell''heap\n                      per la young generation (nursery)\n    -Xms<size>        imposta la dimensione heap Java iniziale\n    -Xmx<size>        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<size>        imposta la dimensione dello stack di thread Java\n     -Xverify          imposta la modalit\u00E0 del verificatore bytecode\n    --add-reads:<module>=<target-module>(,<target-module>)*\n                      aggiorna <module> per leggere <target-module>, indipendentemente\n                      dalla dichiarazione del modulo.\n                      <target-module> pu\u00F2 essere ALL-UNNAMED per leggere tutti i\n                      moduli senza nome.\n   -add-exports:<module>/<package>=<target-module>(,<target-module>)*\n                      aggiorna <module> per esportare <package> in <target-module>,\n                      indipendentemente dalla dichiarazione del modulo.\n                      <target-module> pu\u00F2 essere ALL-UNNAMED per esportare tutti i\n                      moduli senza nome.\n    -patch-module <module>=<file>({0}<file>)*\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=\    -Xbatch           disabilita la compilazione in background\n    -Xbootclasspath/a:<directory e file zip/jar separati da {0}>\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:<file>    registra lo stato GC in un file con indicatori orari\n    -Xmixed           esecuzione in modalit\u00E0 mista (impostazione predefinita)\n    -Xmn<size>        imposta le dimensioni iniziale e massima (in byte) dell''heap\n                      per la young generation (nursery)\n    -Xms<size>        imposta la dimensione heap Java iniziale\n    -Xmx<size>        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<size>        imposta la dimensione dello stack di thread Java\n     -Xverify          imposta la modalit\u00E0 del verificatore bytecode\n    --add-reads:<module>=<target-module>(,<target-module>)*\n                      aggiorna <module> per leggere <target-module>, indipendentemente\n                      dalla dichiarazione del modulo.\n                      <target-module> pu\u00F2 essere ALL-UNNAMED per leggere tutti i\n                      moduli senza nome.\n   -add-exports:<module>/<package>=<target-module>(,<target-module>)*\n                      aggiorna <module> per esportare <package> in <target-module>,\n                      indipendentemente dalla dichiarazione del modulo.\n                      <target-module> 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 <module>=<file>({0}<file>)*\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=<nome applicazione>\n                      Sostituisce il nome applicazione predefinito visualizzato nel dock\n    -Xdock:icon=<percorso file icona>\n                      Sostituisce l'icona predefinita visualizzata nel dock\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ja.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,8 +39,8 @@
 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    -Xdisable-@files  \u3055\u3089\u306A\u308B\u5F15\u6570\u30D5\u30A1\u30A4\u30EB\u62E1\u5F35\u3092\u7121\u52B9\u306B\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:<file>    \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<size>        \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<size>        Java\u306E\u521D\u671F\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n    -Xmx<size>        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<size>        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 <module>=<target-module>(,<target-module>)*\n                      \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001<module>\u3092\u66F4\u65B0\u3057\u3066<target-module>\n                      \u3092\u8AAD\u307F\u53D6\u308A\u307E\u3059\u3002 \n                      <target-module>\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 <module>/<package>=<target-module>(,<target-module>)*\n                      \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001<module>\u3092\u66F4\u65B0\u3057\u3066<package>\u3092<target-module>\u306B\n                      \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\n                      <target-module>\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    --patch-module <module>=<file>({0}<file>)*\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=\    -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:<file>    \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<size>        \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<size>        Java\u306E\u521D\u671F\u30D2\u30FC\u30D7\u30FB\u30B5\u30A4\u30BA\u3092\u8A2D\u5B9A\u3059\u308B\n    -Xmx<size>        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<size>        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 <module>=<target-module>(,<target-module>)*\n                      \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001<module>\u3092\u66F4\u65B0\u3057\u3066<target-module>\n                      \u3092\u8AAD\u307F\u53D6\u308A\u307E\u3059\u3002 \n                      <target-module>\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 <module>/<package>=<target-module>(,<target-module>)*\n                      \u30E2\u30B8\u30E5\u30FC\u30EB\u5BA3\u8A00\u306B\u95A2\u4FC2\u306A\u304F\u3001<module>\u3092\u66F4\u65B0\u3057\u3066<package>\u3092<target-module>\u306B\n                      \u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\n                      <target-module>\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 <module>=<file>({0}<file>)*\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
 
 # 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=<application 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=<path to icon file>\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
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_ko.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,8 +39,8 @@
 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    -Xdisable-@files  \uCD94\uAC00 \uC778\uC218 \uD30C\uC77C \uD655\uC7A5\uC744 \uC0AC\uC6A9 \uC548\uD568\uC73C\uB85C \uC124\uC815\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:<file>    \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<size>        \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<size>        \uCD08\uAE30 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n    -Xmx<size>        \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<size>        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 <module>=<target-module>(,<target-module>)*\n                      \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 <target-module>\uC744 \uC77D\uB3C4\uB85D\n                      <module>\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n                      <target-module>\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 <module>/<package>=<target-module>(,<target-module>)*\n                      \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 <package>\uB97C <target-module>\uB85C \uC775\uC2A4\uD3EC\uD2B8\uD558\uB3C4\uB85D\n                      <module>\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n                      <target-module>\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    --patch-module <module>=<file>({0}<file>)*\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=\    -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:<file>    \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<size>        \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<size>        \uCD08\uAE30 Java \uD799 \uD06C\uAE30\uB97C \uC124\uC815\uD569\uB2C8\uB2E4.\n    -Xmx<size>        \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<size>        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 <module>=<target-module>(,<target-module>)*\n                      \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 <target-module>\uC744 \uC77D\uB3C4\uB85D\n                      <module>\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n                      <target-module>\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 <module>/<package>=<target-module>(,<target-module>)*\n                      \uBAA8\uB4C8 \uC120\uC5B8\uC5D0 \uAD00\uACC4\uC5C6\uC774 <package>\uB97C <target-module>\uB85C \uC775\uC2A4\uD3EC\uD2B8\uD558\uB3C4\uB85D\n                      <module>\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4.\n                      <target-module>\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 <module>=<file>({0}<file>)*\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
 
 # 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=<application 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=<path to icon file>\n                      \uACE0\uC815\uC73C\uB85C \uD45C\uC2DC\uB41C \uAE30\uBCF8 \uC544\uC774\uCF58\uC744 \uBB34\uD6A8\uD654\uD569\uB2C8\uB2E4.\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_pt_BR.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<diret\u00F3rios e arquivos zip/jar separados por {0}>\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    -Xdisable-@files  desativar expans\u00E3o de arquivo de argumento adicional\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:<file>    registrar status de GC em um arquivo com time-stamps\n    -Xmixed           execu\u00E7\u00E3o em modo misto (padr\u00E3o)\n    -Xmn<size>        define o tamanho inicial e m\u00E1ximo (em bytes) do heap\n                      para a gera\u00E7\u00E3o jovem (infantil)\n    -Xms<size>        definir tamanho do heap Java inicial\n    -Xmx<size>        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<size>        definir tamanho de pilha de thread java\n    -Xverify          define o modo do verificador de c\u00F3digo de byte\n    --add-reads <module>=<target-module>(,<target-module>)*\n                      atualiza <module> para ler <target-module>, independentemente\n                      da declara\u00E7\u00E3o do m\u00F3dulo. \n                      <target-module> pode ser ALL-UNNAMED para ler todos os m\u00F3dulos\n                      sem nome.\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      atualiza <module> para exportar <package> para <target-module>,\n                      independentemente da declara\u00E7\u00E3o do m\u00F3dulo.\n                      <target-module> pode ser ALL-UNNAMED para exportar para todos\n                      os m\u00F3dulos sem nome.\n    --patch-module <module>=<file>({0}<file>)*\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=\    -Xbatch           desativar compila\u00E7\u00E3o em segundo plano\n    -Xbootclasspath/a:<diret\u00F3rios e arquivos zip/jar separados por {0}>\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:<file>    registrar status de GC em um arquivo com time-stamps\n    -Xmixed           execu\u00E7\u00E3o em modo misto (padr\u00E3o)\n    -Xmn<size>        define o tamanho inicial e m\u00E1ximo (em bytes) do heap\n                      para a gera\u00E7\u00E3o jovem (infantil)\n    -Xms<size>        definir tamanho do heap Java inicial\n    -Xmx<size>        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<size>        definir tamanho de pilha de thread java\n    -Xverify          define o modo do verificador de c\u00F3digo de byte\n    --add-reads <module>=<target-module>(,<target-module>)*\n                      atualiza <module> para ler <target-module>, independentemente\n                      da declara\u00E7\u00E3o do m\u00F3dulo. \n                      <target-module> pode ser ALL-UNNAMED para ler todos os m\u00F3dulos\n                      sem nome.\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      atualiza <module> para exportar <package> para <target-module>,\n                      independentemente da declara\u00E7\u00E3o do m\u00F3dulo.\n                      <target-module> 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 <module>=<file>({0}<file>)*\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
 
 # 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=<nome do aplicativo>\n                      substitui o nome do aplicativo padr\u00E3o exibido no encaixe\n    -Xdock:icon=<caminho para o arquivo do \u00EDcone>\n                      substitui o \u00EDcone exibido no encaixe\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_sv.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<kataloger och zip-/jar-filer avgr\u00E4nsade med {0}>\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    -Xdisable-@files  avaktivera ytterligare argumentfilsut\u00F6kning\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:<fil>    logga GC-status till en fil med tidsst\u00E4mplar\n    -Xmixed           exekvering i blandat l\u00E4ge (standard)\n    -Xmn<storlek>     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<storlek>     ange ursprunglig storlek f\u00F6r Java-heap-utrymmet\n    -Xmx<storlek>     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<storlek>     ange storlek f\u00F6r java-tr\u00E5dsstacken\n    -Xverify          anger l\u00E4ge f\u00F6r bytekodverifieraren\n    --add-reads <modul>=<m\u00E5lmodul>(,<m\u00E5lmodul>)*\n                      uppdaterar <modul> att l\u00E4sa <m\u00E5lmodul>, oavsett\n                      moduldeklarationen. \n                      <m\u00E5lmodul> kan vara ALL-UNNAMED f\u00F6r att l\u00E4sa alla\n                      ej namngivna moduler.\n    --add-exports <modul>/<paket>=<m\u00E5lmodul>(,<m\u00E5lmodul>)*\n                      uppdaterar <modul> att exportera <paket> till <m\u00E5lmodul>,\n                      oavsett moduldeklarationen.\n                      <m\u00E5lmodul> kan vara ALL-UNNAMED f\u00F6r att exportera till alla\n                      ej namngivna moduler.\n    --patch-module <modul>=<fil>({0}<fil>)*\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=\    -Xbatch           avaktivera bakgrundskompilering\n    -Xbootclasspath/a:<kataloger och zip-/jar-filer avgr\u00E4nsade med {0}>\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:<fil>    logga GC-status till en fil med tidsst\u00E4mplar\n    -Xmixed           exekvering i blandat l\u00E4ge (standard)\n    -Xmn<storlek>     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<storlek>     ange ursprunglig storlek f\u00F6r Java-heap-utrymmet\n    -Xmx<storlek>     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<storlek>     ange storlek f\u00F6r java-tr\u00E5dsstacken\n    -Xverify          anger l\u00E4ge f\u00F6r bytekodverifieraren\n    --add-reads <modul>=<m\u00E5lmodul>(,<m\u00E5lmodul>)*\n                      uppdaterar <modul> att l\u00E4sa <m\u00E5lmodul>, oavsett\n                      moduldeklarationen. \n                      <m\u00E5lmodul> kan vara ALL-UNNAMED f\u00F6r att l\u00E4sa alla\n                      ej namngivna moduler.\n    --add-exports <modul>/<paket>=<m\u00E5lmodul>(,<m\u00E5lmodul>)*\n                      uppdaterar <modul> att exportera <paket> till <m\u00E5lmodul>,\n                      oavsett moduldeklarationen.\n                      <m\u00E5lmodul> kan vara ALL-UNNAMED f\u00F6r att exportera till alla\n                      ej namngivna moduler.\n    --disable-@files  avaktivera ytterligare argumentfilsut\u00F6kning\n    --patch-module <modul>=<fil>({0}<fil>)*\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
 
 # 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=<applikationsnamn>\n                      \u00E5sidos\u00E4tt det standardapplikationsnamn som visas i dockan\n    -Xdock:icon=<s\u00F6kv\u00E4g till ikonfil>\n                      \u00E5sidos\u00E4tt den standardikon som visas i dockan\n\n
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_CN.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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    -Xdisable-@files  \u7981\u6B62\u8FDB\u4E00\u6B65\u6269\u5C55\u53C2\u6570\u6587\u4EF6\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    --patch-module \
+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
 
 # Translators please note do not translate the options themselves
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher_zh_TW.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -39,7 +39,7 @@
 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:<directories and zip/jar files separated by {0}>\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    -Xdisable-@files  \u505C\u7528\u9032\u4E00\u6B65\u7684\u5F15\u6578\u6A94\u6848\u64F4\u5145\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:<file>    \u5C07 GC \u72C0\u614B\u548C\u6642\u6233\u8A18\u9304\u81F3\u6A94\u6848\n    -Xmixed           \u6DF7\u5408\u6A21\u5F0F\u57F7\u884C (\u9810\u8A2D)\n    -Xmn<size>        \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<size>        \u8A2D\u5B9A\u8D77\u59CB Java \u5806\u96C6\u5927\u5C0F\n    -Xmx<size>        \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<size>        \u8A2D\u5B9A Java \u57F7\u884C\u7DD2\u5806\u758A\u5927\u5C0F\n    -Xverify          \u8A2D\u5B9A Bytecode \u9A57\u8B49\u7A0B\u5F0F\u6A21\u5F0F\n    --add-reads <module>=<target-module>(,<target-module>)*\n                      \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 <module> \u4EE5\n                      \u8B80\u53D6 <target-module>\u3002\n                      \u53EF\u5C07 <target-module> \u8A2D\u70BA ALL-UNNAMED \u4EE5\u8B80\u53D6\u6240\u6709\u672A\u547D\u540D\u7684\n                      \u6A21\u7D44\u3002\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 <module> \u4EE5\u4FBF\u5C07 <package>\n                      \u532F\u51FA\u81F3 <target-module>\u3002\n                      \u53EF\u5C07 <target-module> \u8A2D\u70BA ALL-UNNAMED \u4EE5\u532F\u51FA\u81F3\u6240\u6709\n                      \u672A\u547D\u540D\u7684\u6A21\u7D44\u3002\n    --patch-module <module>=<file>({0}<file>)*\n                      \u8986\u5BEB\u6216\u52A0\u5F37 JAR \u6A94\u6848\u6216\u76EE\u9304\u4E2D\n                      \
+java.launcher.X.usage=\    -Xbatch           \u505C\u7528\u80CC\u666F\u7DE8\u8B6F\n    -Xbootclasspath/a:<directories and zip/jar files separated by {0}>\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:<file>    \u5C07 GC \u72C0\u614B\u548C\u6642\u6233\u8A18\u9304\u81F3\u6A94\u6848\n    -Xmixed           \u6DF7\u5408\u6A21\u5F0F\u57F7\u884C (\u9810\u8A2D)\n    -Xmn<size>        \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<size>        \u8A2D\u5B9A\u8D77\u59CB Java \u5806\u96C6\u5927\u5C0F\n    -Xmx<size>        \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<size>        \u8A2D\u5B9A Java \u57F7\u884C\u7DD2\u5806\u758A\u5927\u5C0F\n    -Xverify          \u8A2D\u5B9A Bytecode \u9A57\u8B49\u7A0B\u5F0F\u6A21\u5F0F\n    --add-reads <module>=<target-module>(,<target-module>)*\n                      \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 <module> \u4EE5\n                      \u8B80\u53D6 <target-module>\u3002\n                      \u53EF\u5C07 <target-module> \u8A2D\u70BA ALL-UNNAMED \u4EE5\u8B80\u53D6\u6240\u6709\u672A\u547D\u540D\u7684\n                      \u6A21\u7D44\u3002\n    --add-exports <module>/<package>=<target-module>(,<target-module>)*\n                      \u7121\u8AD6\u6A21\u7D44\u5BA3\u544A\u70BA\u4F55\uFF0C\u66F4\u65B0 <module> \u4EE5\u4FBF\u5C07 <package>\n                      \u532F\u51FA\u81F3 <target-module>\u3002\n                      \u53EF\u5C07 <target-module> \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 <module>=<file>({0}<file>)*\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
 
 # Translators please note do not translate the options themselves
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -32,7 +32,6 @@
 import java.net.URI;
 import java.nio.file.Paths;
 import java.util.*;
-import java.text.MessageFormat;
 import java.security.*;
 import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
@@ -579,10 +578,9 @@
                 k.add(policy);
                 return k;
             });
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
-                (POLICY + ".error.parsing.policy.message"));
             Object[] source = {policy, pe.getLocalizedMessage()};
-            System.err.println(form.format(source));
+            System.err.println(LocalizedMessage.getMessage
+                (POLICY + ".error.parsing.policy.message", source));
             if (debug != null) {
                 pe.printStackTrace();
             }
@@ -805,32 +803,30 @@
                         }
                     }
                 } catch (java.lang.reflect.InvocationTargetException ite) {
-                    MessageFormat form = new MessageFormat
-                        (ResourcesMgr.getString
-                         (POLICY +
-                          ".error.adding.Permission.perm.message"));
                     Object[] source = {pe.permission,
                                        ite.getTargetException().toString()};
-                    System.err.println(form.format(source));
+                    System.err.println(
+                        LocalizedMessage.getMessage(
+                            POLICY + ".error.adding.Permission.perm.message",
+                            source));
                 } catch (Exception e) {
-                    MessageFormat form = new MessageFormat
-                        (ResourcesMgr.getString
-                         (POLICY +
-                          ".error.adding.Permission.perm.message"));
                     Object[] source = {pe.permission,
                                        e.toString()};
-                    System.err.println(form.format(source));
+                    System.err.println(
+                        LocalizedMessage.getMessage(
+                            POLICY + ".error.adding.Permission.perm.message",
+                            source));
                 }
             }
 
             // No need to sync because noone has access to newInfo yet
             newInfo.policyEntries.add(entry);
         } catch (Exception e) {
-            MessageFormat form = new MessageFormat(ResourcesMgr.getString
-                                         (POLICY
-                                         + ".error.adding.Entry.message"));
             Object[] source = {e.toString()};
-            System.err.println(form.format(source));
+            System.err.println(
+                LocalizedMessage.getMessage(
+                    POLICY + ".error.adding.Entry.message",
+                    source));
         }
         if (debug != null)
             debug.println();
@@ -1803,29 +1799,29 @@
             } else if (prefix.equalsIgnoreCase("alias")) {
                 // get the suffix and perform keystore alias replacement
                 if (colonIndex == -1) {
-                    MessageFormat form = new MessageFormat
-                        (ResourcesMgr.getString
-                        ("alias.name.not.provided.pe.name."));
                     Object[] source = {pe.name};
-                    throw new Exception(form.format(source));
+                    throw new Exception(
+                        LocalizedMessage.getMessage(
+                            "alias.name.not.provided.pe.name.",
+                            source));
                 }
                 suffix = value.substring(colonIndex+1);
                 if ((suffix = getDN(suffix, keystore)) == null) {
-                    MessageFormat form = new MessageFormat
-                        (ResourcesMgr.getString
-                        ("unable.to.perform.substitution.on.alias.suffix"));
                     Object[] source = {value.substring(colonIndex+1)};
-                    throw new Exception(form.format(source));
+                    throw new Exception(
+                        LocalizedMessage.getMessage(
+                            "unable.to.perform.substitution.on.alias.suffix",
+                            source));
                 }
 
                 sb.append(X500PRINCIPAL + " \"" + suffix + "\"");
                 startIndex = e+2;
             } else {
-                MessageFormat form = new MessageFormat
-                        (ResourcesMgr.getString
-                        ("substitution.value.prefix.unsupported"));
                 Object[] source = {prefix};
-                throw new Exception(form.format(source));
+                throw new Exception(
+                    LocalizedMessage.getMessage(
+                        "substitution.value.prefix.unsupported",
+                        source));
             }
         }
 
@@ -2039,7 +2035,7 @@
             super(type);
             if (type == null) {
                 throw new NullPointerException
-                    (ResourcesMgr.getString("type.can.t.be.null"));
+                    (LocalizedMessage.getMessage("type.can.t.be.null"));
             }
             this.type = type;
             this.name = name;
--- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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,18 +26,14 @@
 package sun.security.provider;
 
 import java.io.*;
-import java.lang.RuntimePermission;
-import java.net.SocketPermission;
-import java.net.URL;
 import java.security.GeneralSecurityException;
 import java.security.Principal;
-import java.text.MessageFormat;
 import java.util.*;
 import javax.security.auth.x500.X500Principal;
 
 import sun.security.util.Debug;
 import sun.security.util.PropertyExpander;
-import sun.security.util.ResourcesMgr;
+import sun.security.util.LocalizedMessage;
 
 /**
  * The policy for a Java runtime (specifying
@@ -209,13 +205,12 @@
                     if (!domainEntries.containsKey(domainName)) {
                         domainEntries.put(domainName, de);
                     } else {
-                        MessageFormat form =
-                            new MessageFormat(ResourcesMgr.getString(
-                                "duplicate.keystore.domain.name"));
+                        LocalizedMessage localizedMsg =
+                            new LocalizedMessage("duplicate.keystore.domain.name");
                         Object[] source = {domainName};
                         String msg = "duplicate keystore domain name: " +
                                      domainName;
-                        throw new ParsingException(msg, form, source);
+                        throw new ParsingException(msg, localizedMsg, source);
                     }
                 }
             } else {
@@ -225,7 +220,7 @@
         }
 
         if (keyStoreUrlString == null && storePassURL != null) {
-            throw new ParsingException(ResourcesMgr.getString
+            throw new ParsingException(LocalizedMessage.getMessage
                 ("keystorePasswordURL.can.not.be.specified.without.also.specifying.keystore"));
         }
     }
@@ -367,7 +362,7 @@
             keyStoreType = match("quoted string");
         } else {
             throw new ParsingException(st.lineno(),
-                        ResourcesMgr.getString("expected.keystore.type"));
+                LocalizedMessage.getMessage("expected.keystore.type"));
         }
 
         // parse keystore provider
@@ -380,7 +375,7 @@
             keyStoreProvider = match("quoted string");
         } else {
             throw new ParsingException(st.lineno(),
-                        ResourcesMgr.getString("expected.keystore.provider"));
+                LocalizedMessage.getMessage("expected.keystore.provider"));
         }
     }
 
@@ -430,7 +425,7 @@
                 if (e.codeBase != null)
                     throw new ParsingException(
                             st.lineno(),
-                            ResourcesMgr.getString
+                            LocalizedMessage.getMessage
                                 ("multiple.Codebase.expressions"));
                 e.codeBase = match("quoted string");
                 peekAndMatch(",");
@@ -438,8 +433,8 @@
                 if (e.signedBy != null)
                     throw new ParsingException(
                             st.lineno(),
-                            ResourcesMgr.getString(
-                                "multiple.SignedBy.expressions"));
+                            LocalizedMessage.getMessage
+                                ("multiple.SignedBy.expressions"));
                 e.signedBy = match("quoted string");
 
                 // verify syntax of the aliases
@@ -457,8 +452,8 @@
                 if (actr <= cctr)
                     throw new ParsingException(
                             st.lineno(),
-                            ResourcesMgr.getString(
-                                "SignedBy.has.empty.alias"));
+                            LocalizedMessage.getMessage
+                                ("SignedBy.has.empty.alias"));
 
                 peekAndMatch(",");
             } else if (peekAndMatch("Principal")) {
@@ -500,7 +495,7 @@
                         }
                         throw new ParsingException
                                 (st.lineno(),
-                                 ResourcesMgr.getString
+                                LocalizedMessage.getMessage
                                     ("can.not.specify.Principal.with.a.wildcard.class.without.a.wildcard.name"));
                     }
                 }
@@ -537,8 +532,8 @@
 
             } else {
                 throw new ParsingException(st.lineno(),
-                                  ResourcesMgr.getString(
-                                      "expected.codeBase.or.SignedBy.or.Principal"));
+                    LocalizedMessage.getMessage
+                        ("expected.codeBase.or.SignedBy.or.Principal"));
             }
         }
 
@@ -561,8 +556,8 @@
             } else {
                 throw new
                     ParsingException(st.lineno(),
-                                     ResourcesMgr.getString(
-                                        "expected.permission.entry"));
+                        LocalizedMessage.getMessage
+                            ("expected.permission.entry"));
             }
         }
         match("}");
@@ -738,15 +733,14 @@
         switch (lookahead) {
         case StreamTokenizer.TT_NUMBER:
             throw new ParsingException(st.lineno(), expect,
-                                       ResourcesMgr.getString("number.") +
-                                       String.valueOf(st.nval));
+                LocalizedMessage.getMessage("number.") +
+                    String.valueOf(st.nval));
         case StreamTokenizer.TT_EOF:
-            MessageFormat form = new MessageFormat(
-                    ResourcesMgr.getString
-                            ("expected.expect.read.end.of.file."));
+            LocalizedMessage localizedMsg = new LocalizedMessage
+                ("expected.expect.read.end.of.file.");
             Object[] source = {expect};
             String msg = "expected [" + expect + "], read [end of file]";
-            throw new ParsingException(msg, form, source);
+            throw new ParsingException(msg, localizedMsg, source);
         case StreamTokenizer.TT_WORD:
             if (expect.equalsIgnoreCase(st.sval)) {
                 lookahead = st.nextToken();
@@ -832,10 +826,10 @@
             switch (lookahead) {
             case StreamTokenizer.TT_NUMBER:
                 throw new ParsingException(st.lineno(), ";",
-                                          ResourcesMgr.getString("number.") +
-                                          String.valueOf(st.nval));
+                        LocalizedMessage.getMessage("number.") +
+                            String.valueOf(st.nval));
             case StreamTokenizer.TT_EOF:
-                throw new ParsingException(ResourcesMgr.getString
+                throw new ParsingException(LocalizedMessage.getMessage
                         ("expected.read.end.of.file."));
             default:
                 lookahead = st.nextToken();
@@ -993,8 +987,8 @@
          */
         public PrincipalEntry(String principalClass, String principalName) {
             if (principalClass == null || principalName == null)
-                throw new NullPointerException(ResourcesMgr.getString(
-                                  "null.principalClass.or.principalName"));
+                throw new NullPointerException(LocalizedMessage.getMessage
+                    ("null.principalClass.or.principalName"));
             this.principalClass = principalClass;
             this.principalName = principalName;
         }
@@ -1244,11 +1238,11 @@
             if (!entries.containsKey(keystoreName)) {
                 entries.put(keystoreName, entry);
             } else {
-                MessageFormat form = new MessageFormat(ResourcesMgr.getString(
-                    "duplicate.keystore.name"));
+                LocalizedMessage localizedMsg = new LocalizedMessage
+                    ("duplicate.keystore.name");
                 Object[] source = {keystoreName};
                 String msg = "duplicate keystore name: " + keystoreName;
-                throw new ParsingException(msg, form, source);
+                throw new ParsingException(msg, localizedMsg, source);
             }
         }
 
@@ -1320,7 +1314,7 @@
         private static final long serialVersionUID = -4330692689482574072L;
 
         private String i18nMessage;
-        private MessageFormat form;
+        private LocalizedMessage localizedMsg;
         private Object[] source;
 
         /**
@@ -1336,10 +1330,10 @@
             i18nMessage = msg;
         }
 
-        public ParsingException(String msg, MessageFormat form,
+        public ParsingException(String msg, LocalizedMessage localizedMsg,
                                 Object[] source) {
             super(msg);
-            this.form = form;
+            this.localizedMsg = localizedMsg;
             this.source = source;
         }
 
@@ -1347,7 +1341,7 @@
             super("line " + line + ": " + msg);
             // don't call form.format unless getLocalizedMessage is called
             // to avoid unnecessary permission checks
-            form = new MessageFormat(ResourcesMgr.getString("line.number.msg"));
+            localizedMsg = new LocalizedMessage("line.number.msg");
             source = new Object[] {line, msg};
         }
 
@@ -1356,14 +1350,14 @@
                 "], found [" + actual + "]");
             // don't call form.format unless getLocalizedMessage is called
             // to avoid unnecessary permission checks
-            form = new MessageFormat(ResourcesMgr.getString
-                ("line.number.expected.expect.found.actual."));
+            localizedMsg = new LocalizedMessage
+                ("line.number.expected.expect.found.actual.");
             source = new Object[] {line, expect, actual};
         }
 
         @Override
         public String getLocalizedMessage() {
-            return i18nMessage != null ? i18nMessage : form.format(source);
+            return i18nMessage != null ? i18nMessage : localizedMsg.format(source);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/LocalizedMessage.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,151 @@
+/*
+ * 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;
+
+/**
+ * This class produces formatted and localized messages describing security
+ * issues. Some messages may be required when the VM is not fully booted. In
+ * this case, localization resources and classes used for message formatting
+ * may not be available. When the VM is not booted, the message will not be
+ * localized, and it will be formatted using simplified message formatting
+ * code that is contained in this class.
+ */
+
+/*
+ * Some of this code is executed before the VM is fully booted. Some import
+ * statements have been omitted to help prevent accidental use of classes that
+ * may not be available during boot.
+ */
+
+public class LocalizedMessage {
+
+    private static final Resources resources = new Resources();
+
+    private final String key;
+
+    /**
+     * A LocalizedMessage can be instantiated with a key and formatted with
+     * arguments later in the style of MessageFormat. This organization
+     * allows the actual formatting (and associated permission checks) to be
+     * avoided unless the resulting string is needed.
+     * @param key
+     */
+    public LocalizedMessage(String key) {
+        this.key = key;
+    }
+
+    /**
+     * Return a localized string corresponding to the key stored in this
+     * object, formatted with the provided arguments. When the VM is booted,
+     * this method will obtain the correct localized message and format it
+     * using java.text.MessageFormat. Otherwise, a non-localized string is
+     * returned, and the formatting is performed by simplified formatting code.
+     *
+     * @param arguments The arguments that should be placed in the message
+     * @return A formatted message string
+     */
+    public String format(Object... arguments) {
+        return getMessage(key, arguments);
+    }
+
+    /**
+     * Return a non-localized string corresponding to the provided key, and
+     * formatted with the provided arguments. All strings are obtained from
+     * sun.security.util.Resources, and the formatting only supports
+     * simple positional argument replacement (e.g. {1}).
+     *
+     * @param key The key of the desired string in Resources
+     * @param arguments The arguments that should be placed in the message
+     * @return A formatted message string
+     */
+    public static String getMessageUnbooted(String key,
+                                            Object... arguments) {
+
+        String value = resources.getString(key);
+        if (arguments == null || arguments.length == 0) {
+            return value;
+        }
+        // Classes like StringTokenizer may not be loaded, so parsing
+        //   is performed with String methods
+        StringBuilder sb = new StringBuilder();
+        int nextBraceIndex;
+        while ((nextBraceIndex = value.indexOf('{')) >= 0) {
+
+            String firstPart = value.substring(0, nextBraceIndex);
+            sb.append(firstPart);
+            value = value.substring(nextBraceIndex + 1);
+
+            // look for closing brace and argument index
+            nextBraceIndex = value.indexOf('}');
+            if (nextBraceIndex < 0) {
+                // no closing brace
+                // MessageFormat would throw IllegalArgumentException, but
+                //   that exception class may not be loaded yet
+                throw new RuntimeException("Unmatched braces");
+            }
+            String indexStr = value.substring(0, nextBraceIndex);
+            try {
+                int index = Integer.parseInt(indexStr);
+                sb.append(arguments[index]);
+            }
+            catch(NumberFormatException e) {
+                // argument index is not an integer
+                throw new RuntimeException("not an integer: " + indexStr);
+            }
+            value = value.substring(nextBraceIndex + 1);
+        }
+        sb.append(value);
+        return sb.toString();
+    }
+
+    /**
+     * Return a localized string corresponding to the provided key, and
+     * formatted with the provided arguments. When the VM is booted, this
+     * method will obtain the correct localized message and format it using
+     * java.text.MessageFormat. Otherwise, a non-localized string is returned,
+     * and the formatting is performed by simplified formatting code.
+     *
+     * @param key The key of the desired string in the security resource bundle
+     * @param arguments The arguments that should be placed in the message
+     * @return A formatted message string
+     */
+    public static String getMessage(String key,
+                                    Object... arguments) {
+
+        if (jdk.internal.misc.VM.isBooted()) {
+            // Localization and formatting resources are available
+            String value = ResourcesMgr.getString(key);
+            if (arguments == null) {
+                return value;
+            }
+            java.text.MessageFormat form = new java.text.MessageFormat(value);
+            return form.format(arguments);
+        } else {
+            return getMessageUnbooted(key, arguments);
+        }
+    }
+
+}
--- a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,37 +34,24 @@
  */
 public class ResourcesMgr {
     // intended for java.security, javax.security and sun.security resources
-    private final static String RESOURCES = "sun.security.util.Resources";
-    private final static String AUTH_RESOURCES = "sun.security.util.AuthResources";
-
     private final static Map<String, ResourceBundle> bundles = new ConcurrentHashMap<>();
 
     public static String getString(String s) {
-        ResourceBundle bundle = bundles.get(RESOURCES);
-        if (bundle == null) {
-
-            // only load if/when needed
-            bundle = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<java.util.ResourceBundle>() {
-                public java.util.ResourceBundle run() {
-                    return (java.util.ResourceBundle.getBundle
-                                ("sun.security.util.Resources"));
-                }
-            });
-        }
-
-        return bundle.getString(s);
+        return getBundle("sun.security.util.Resources").getString(s);
     }
 
     public static String getAuthResourceString(String s) {
-        if (VM.initLevel() == 3) {
-            // cannot trigger loading of any resource bundle as
-            // it depends on the system class loader fully initialized.
-            throw new InternalError("system class loader is being initialized");
+        return getBundle("sun.security.util.AuthResources").getString(s);
+    }
+
+    private static ResourceBundle getBundle(String bundleName) {
+        if (!VM.isBooted()) {
+            // don't expect this be called before the system is fully initialized.
+            // This triggers loading of any resource bundle that should be
+            // be done during initialization of system class loader.
+            throw new InternalError("Expected to use ResourceBundle only after booted");
         }
-
-        return bundles.computeIfAbsent(AUTH_RESOURCES, ResourceBundle::getBundle)
-                      .getString(s);
+        return bundles.computeIfAbsent(bundleName, ResourceBundle::getBundle);
     }
 
 }
--- a/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -195,9 +195,26 @@
         return parent;
     }
 
+    /**
+     * This method returns equivalent CLDR supported locale for zh-HK,
+     * no, no-NO locales so that COMPAT locales do not precede
+     * those locales during ResourceBundle search path.
+     */
+    private static Locale getEquivalentLoc(Locale locale) {
+        switch (locale.toString()) {
+            case "zh_HK":
+                return Locale.forLanguageTag("zh-Hant-HK");
+            case "no":
+            case "no_NO":
+                return Locale.forLanguageTag("nb");
+        }
+        return locale;
+    }
+
     @Override
     public boolean isSupportedProviderLocale(Locale locale, Set<String> langtags) {
-        return Locale.ROOT.equals(locale) ||
-            langtags.contains(locale.stripExtensions().toLanguageTag());
+        return Locale.ROOT.equals(locale)
+                || langtags.contains(locale.stripExtensions().toLanguageTag())
+                || langtags.contains(getEquivalentLoc(locale).toLanguageTag());
     }
 }
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -31,6 +31,8 @@
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.spi.CalendarNameProvider;
+import sun.util.calendar.CalendarSystem;
+import sun.util.calendar.Era;
 
 /**
  * Concrete implementation of the  {@link java.util.spi.CalendarDataProvider
@@ -75,7 +77,21 @@
                 if (field == DAY_OF_WEEK || field == YEAR) {
                     --value;
                 }
-                if (value < 0 || value >= strings.length) {
+                if (value < 0 || value > strings.length) {
+                    return null;
+                } else if (value == strings.length) {
+                    if (field == ERA && "japanese".equals(calendarType)) {
+                        // get the supplemental era, if any, specified through
+                        // the property "jdk.calendar.japanese.supplemental.era"
+                        // which is always the last element.
+                        Era[] jeras = CalendarSystem.forName("japanese").getEras();
+                        if (jeras.length == value) {
+                            Era supEra = jeras[value - 1]; // 0-based index
+                            return style == LONG ?
+                                supEra.getName() :
+                                supEra.getAbbreviation();
+                        }
+                    }
                     return null;
                 }
                 name = strings[value];
--- a/jdk/src/java.base/share/native/launcher/main.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/launcher/main.c	Wed Jul 05 22:46:04 2017 +0200
@@ -127,7 +127,22 @@
         // accommodate the NULL at the end
         JLI_List args = JLI_List_new(argc + 1);
         int i = 0;
-        for (i = 0; i < argc; i++) {
+
+        // 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)) {
+            // JLI_SetTraceLauncher is not called yet
+            // Show _JAVA_OPTIONS content along with JAVA_OPTIONS to aid diagnosis
+            if (getenv(JLDEBUG_ENV_ENTRY)) {
+                char *tmp = getenv("_JAVA_OPTIONS");
+                if (NULL != tmp) {
+                    JLI_ReportMessage(ARG_INFO_ENVVAR, "_JAVA_OPTIONS", tmp);
+                }
+            }
+        }
+        // Iterate the rest of command line
+        for (i = 1; i < argc; i++) {
             JLI_List argsInFile = JLI_PreprocessArg(argv[i]);
             if (NULL == argsInFile) {
                 JLI_List_add(args, JLI_StringDup(argv[i]));
--- a/jdk/src/java.base/share/native/libjli/args.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/args.c	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,19 @@
  * questions.
  */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
 #include <sys/stat.h>
+#include <ctype.h>
 
 #ifdef DEBUG_ARGFILE
   #ifndef NO_JNI
     #define NO_JNI
   #endif
-  #define JLI_ReportMessage(p1, p2) printf((p1), (p2))
+  #define JLI_ReportMessage(...) printf(__VA_ARGS__)
+  #define JAVA_OPTIONS "JAVA_OPTIONS"
+  int IsWhiteSpaceOption(const char* name) { return 1; }
 #else
   #include "java.h"
 #endif
@@ -69,14 +73,17 @@
 static int firstAppArgIndex = NOT_FOUND;
 
 static jboolean expectingNoDashArg = JNI_FALSE;
-static size_t argsCount = 0;
+// Initialize to 1, as the first argument is the app name and not preprocessed
+static size_t argsCount = 1;
 static jboolean stopExpansion = JNI_FALSE;
+static jboolean relaunch = JNI_FALSE;
 
 void JLI_InitArgProcessing(jboolean isJava, jboolean disableArgFile) {
     // No expansion for relaunch
-    if (argsCount != 0) {
+    if (argsCount != 1) {
+        relaunch = JNI_TRUE;
         stopExpansion = JNI_TRUE;
-        argsCount = 0;
+        argsCount = 1;
     } else {
         stopExpansion = disableArgFile;
     }
@@ -95,10 +102,6 @@
 static void checkArg(const char *arg) {
     size_t idx = 0;
     argsCount++;
-    if (argsCount == 1) {
-        // ignore first argument, the application name
-        return;
-    }
 
     // All arguments arrive here must be a launcher argument,
     // ie. by now, all argfile expansions must have been performed.
@@ -109,6 +112,7 @@
             expectingNoDashArg = JNI_TRUE;
 
             if (JLI_StrCmp(arg, "-jar") == 0 ||
+                JLI_StrCmp(arg, "--module") == 0 ||
                 JLI_StrCmp(arg, "-m") == 0) {
                 // This is tricky, we do expect NoDashArg
                 // But that is considered main class to stop expansion
@@ -116,7 +120,7 @@
                 // We can not just update the idx here because if -jar @file
                 // still need expansion of @file to get the argument for -jar
             }
-        } else if (JLI_StrCmp(arg, "-Xdisable-@files") == 0) {
+        } else if (JLI_StrCmp(arg, "--disable-@files") == 0) {
             stopExpansion = JNI_TRUE;
         }
     } else {
@@ -407,6 +411,117 @@
     return rv;
 }
 
+int isTerminalOpt(char *arg) {
+    return JLI_StrCmp(arg, "-jar") == 0 ||
+           JLI_StrCmp(arg, "-m") == 0 ||
+           JLI_StrCmp(arg, "--module") == 0 ||
+           JLI_StrCmp(arg, "--dry-run") == 0 ||
+           JLI_StrCmp(arg, "-h") == 0 ||
+           JLI_StrCmp(arg, "-?") == 0 ||
+           JLI_StrCmp(arg, "-help") == 0 ||
+           JLI_StrCmp(arg, "--help") == 0 ||
+           JLI_StrCmp(arg, "-X") == 0 ||
+           JLI_StrCmp(arg, "--help-extra") == 0 ||
+           JLI_StrCmp(arg, "-version") == 0 ||
+           JLI_StrCmp(arg, "--version") == 0 ||
+           JLI_StrCmp(arg, "-fullversion") == 0 ||
+           JLI_StrCmp(arg, "--full-version") == 0;
+}
+
+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;
+    JLI_List argsInFile;
+
+    if (firstAppArgIndex == 0) {
+        // Not 'java', return
+        return JNI_FALSE;
+    }
+
+    if (relaunch) {
+        return JNI_FALSE;
+    }
+
+    if (NULL == env) {
+        return JNI_FALSE;
+    }
+
+    JLI_ReportMessage(ARG_INFO_ENVVAR, var_name, env);
+
+    // This is retained until the process terminates as it is saved as the args
+    p = JLI_MemAlloc(JLI_StrLen(env) + 1);
+    while (*env != '\0') {
+        while (*env != '\0' && isspace(*env)) {
+            env++;
+        }
+
+        arg = p;
+        while (*env != '\0' && !isspace(*env)) {
+            if (*env == '"' || *env == '\'') {
+                quote = *env++;
+                while (*env != quote && *env != '\0') {
+                    *p++ = *env++;
+                }
+
+                if (*env == '\0') {
+                    JLI_ReportMessage(ARG_ERROR8, var_name);
+                    exit(1);
+                }
+                env++;
+            } else {
+                *p++ = *env++;
+            }
+        }
+
+        *p++ = '\0';
+
+        argsInFile = JLI_PreprocessArg(arg);
+
+        if (NULL == argsInFile) {
+            if (isTerminalOpt(arg)) {
+                JLI_ReportMessage(ARG_ERROR9, arg, var_name);
+                exit(1);
+            }
+            JLI_List_add(args, arg);
+        } else {
+            size_t cnt, idx;
+            char *argFile = arg;
+            cnt = argsInFile->size;
+            for (idx = 0; idx < cnt; idx++) {
+                arg = argsInFile->elements[idx];
+                if (isTerminalOpt(arg)) {
+                    JLI_ReportMessage(ARG_ERROR10, arg, argFile, var_name);
+                    exit(1);
+                }
+                JLI_List_add(args, arg);
+            }
+            // Shallow free, we reuse the string to avoid copy
+            JLI_MemFree(argsInFile->elements);
+            JLI_MemFree(argsInFile);
+        }
+        /*
+         * Check if main-class is specified after argument being checked. It
+         * must always appear after expansion, as a main-class could be specified
+         * indirectly into environment variable via an @argfile, and it must be
+         * caught now.
+         */
+        if (firstAppArgIndex != NOT_FOUND) {
+            JLI_ReportMessage(ARG_ERROR11, var_name);
+            exit(1);
+        }
+
+        assert (*env == '\0' || isspace(*env));
+    }
+
+    return JNI_TRUE;
+#endif
+}
+
 #ifdef DEBUG_ARGFILE
 /*
  * Stand-alone sanity test, build with following command line
--- a/jdk/src/java.base/share/native/libjli/emessages.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/emessages.h	Wed Jul 05 22:46:04 2017 +0200
@@ -36,6 +36,7 @@
 #define JNI_ERROR       "Error: A JNI error has occurred, please check your installation and try again"
 #define JNI_ERROR1      "Error: can't find JNI interfaces in: %s"
 
+#define ARG_INFO_ENVVAR "NOTE: Picked up the following options via %s:\n  %s"
 #define ARG_WARN        "Warning: %s option is no longer supported."
 
 #define ARG_ERROR1      "Error: %s requires class path specification"
@@ -45,6 +46,10 @@
 #define ARG_ERROR5      "Error: %s requires module id"
 #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 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
--- a/jdk/src/java.base/share/native/libjli/java.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.c	Wed Jul 05 22:46:04 2017 +0200
@@ -769,17 +769,7 @@
                 continue;
             }
 
-            if (*arg != '-'
-                    || JLI_StrCmp(arg, "-version") == 0
-                    || JLI_StrCmp(arg, "--version") == 0
-                    || JLI_StrCmp(arg, "-fullversion") == 0
-                    || JLI_StrCmp(arg, "--full-version") == 0
-                    || JLI_StrCmp(arg, "-help") == 0
-                    || JLI_StrCmp(arg, "--help") == 0
-                    || JLI_StrCmp(arg, "-?") == 0
-                    || JLI_StrCmp(arg, "-jar") == 0
-                    || JLI_StrCmp(arg, "-X") == 0
-                    || JLI_StrCmp(arg, "--help-extra") == 0) {
+            if (*arg != '-' || isTerminalOpt(arg)) {
                 return;
             }
         }
@@ -1576,6 +1566,31 @@
     return (*env)->CallStaticObjectMethod(env, cls, mid);
 }
 
+static char* expandWildcardOnLongOpt(char* arg) {
+    char *p, *value;
+    size_t optLen, valueLen;
+    p = JLI_StrChr(arg, '=');
+
+    if (p == NULL || p[1] == '\0') {
+        JLI_ReportErrorMessage(ARG_ERROR1, arg);
+        exit(1);
+    }
+    p++;
+    value = (char *) JLI_WildcardExpandClasspath(p);
+    if (p == value) {
+        // no wildcard
+        return arg;
+    }
+
+    optLen = p - arg;
+    valueLen = JLI_StrLen(value);
+    p = JLI_MemAlloc(optLen + valueLen + 1);
+    memcpy(p, arg, optLen);
+    memcpy(p + optLen, value, valueLen);
+    p[optLen + valueLen + 1] = '\0';
+    return p;
+}
+
 /*
  * For tools, convert command line args thus:
  *   javac -cp foo:foo/"*" -J-ms32m ...
@@ -1626,14 +1641,17 @@
         if (arg[0] == '-') {
             if (arg[1] == 'J')
                 continue;
-            if (IsWildCardEnabled() && arg[1] == 'c'
-                && (JLI_StrCmp(arg, "-cp") == 0 ||
-                    JLI_StrCmp(arg, "-classpath") == 0)
-                && i < argc - 1) {
-                *nargv++ = arg;
-                *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
-                i++;
-                continue;
+            if (IsWildCardEnabled()) {
+                if (IsClassPathOption(arg) && i < argc - 1) {
+                    *nargv++ = arg;
+                    *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
+                    i++;
+                    continue;
+                }
+                if (JLI_StrCCmp(arg, "--class-path=") == 0) {
+                    *nargv++ = expandWildcardOnLongOpt(arg);
+                    continue;
+                }
             }
         }
         *nargv++ = arg;
--- a/jdk/src/java.base/share/native/libjli/java.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.h	Wed Jul 05 22:46:04 2017 +0200
@@ -71,6 +71,7 @@
 
 #define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
 #define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
+#define JAVA_OPTIONS "JAVA_OPTIONS"
 
 /*
  * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
@@ -169,6 +170,9 @@
 void AddOption(char *str, void *info);
 jboolean IsWhiteSpaceOption(const char* name);
 
+// Utility function defined in args.c
+int isTerminalOpt(char *arg);
+
 const char* GetProgramName();
 const char* GetFullVersion();
 jboolean IsJavaArgs();
--- a/jdk/src/java.base/share/native/libjli/jli_util.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/jli_util.h	Wed Jul 05 22:46:04 2017 +0200
@@ -135,5 +135,6 @@
 
 void JLI_InitArgProcessing(jboolean isJava, jboolean disableArgFile);
 JLI_List JLI_PreprocessArg(const char *arg);
+jboolean JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name);
 
 #endif  /* _JLI_UTIL_H */
--- a/jdk/src/java.base/share/native/libjli/wildcard.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/wildcard.c	Wed Jul 05 22:46:04 2017 +0200
@@ -272,14 +272,16 @@
         (! exists(filename));
 }
 
-static void
+static int
 FileList_expandWildcards(JLI_List fl)
 {
     size_t i, j;
+    int expandedCnt = 0;
     for (i = 0; i < fl->size; i++) {
         if (isWildcard(fl->elements[i])) {
             JLI_List expanded = wildcardFileList(fl->elements[i]);
             if (expanded != NULL && expanded->size > 0) {
+                expandedCnt++;
                 JLI_MemFree(fl->elements[i]);
                 JLI_List_ensureCapacity(fl, fl->size + expanded->size);
                 for (j = fl->size - 1; j >= i+1; j--)
@@ -294,19 +296,20 @@
             JLI_List_free(expanded);
         }
     }
+    return expandedCnt;
 }
 
 const char *
 JLI_WildcardExpandClasspath(const char *classpath)
 {
-    char *expanded;
+    const char *expanded;
     JLI_List fl;
 
     if (JLI_StrChr(classpath, '*') == NULL)
         return classpath;
     fl = JLI_List_split(classpath, PATH_SEPARATOR);
-    FileList_expandWildcards(fl);
-    expanded = JLI_List_join(fl, PATH_SEPARATOR);
+    expanded = FileList_expandWildcards(fl) ?
+        JLI_List_join(fl, PATH_SEPARATOR) : classpath;
     JLI_List_free(fl);
     if (getenv(JLDEBUG_ENV_ENTRY) != 0)
         printf("Expanded wildcards:\n"
--- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -31,6 +31,8 @@
  * in the jdk regression tests.
  */
 
+#include <assert.h>
+
 #ifndef IDE_STANDALONE
 #include "java.h"
 #include "jli_util.h"
@@ -198,17 +200,50 @@
     int nargs = 0;
     StdArg* argv = NULL;
     jboolean wildcard = JNI_FALSE;
-    char* src = cmdline;
+    char* src = cmdline, *arg = NULL;
     JLI_List argsInFile;
+    size_t i, cnt;
+
+    JLI_List envArgs = JLI_List_new(1);
+    if (JLI_AddArgsFromEnvVar(envArgs, JAVA_OPTIONS)) {
+        // JLI_SetTraceLauncher is not called yet
+        // Show _JAVA_OPTIONS content along with JAVA_OPTIONS to aid diagnosis
+        if (getenv(JLDEBUG_ENV_ENTRY)) {
+            char *tmp = getenv("_JAVA_OPTIONS");
+            if (NULL != tmp) {
+                JLI_ReportMessage(ARG_INFO_ENVVAR, "_JAVA_OPTIONS", tmp);
+            }
+        }
+    }
+    cnt = envArgs->size + 1;
+    argv = JLI_MemAlloc(cnt * sizeof(StdArg));
 
     // allocate arg buffer with sufficient space to receive the largest arg
-    char* arg = JLI_StringDup(cmdline);
+    arg = JLI_StringDup(cmdline);
+
+    src = next_arg(src, arg, &wildcard);
+    // first argument is the app name, do not preprocess and make sure remains first
+    argv[0].arg = JLI_StringDup(arg);
+    argv[0].has_wildcard = wildcard;
+    nargs++;
 
-    do {
+    for (i = 1; i < cnt; i++) {
+        argv[i].arg = envArgs->elements[i - 1];
+        // wildcard is not supported in argfile
+        argv[i].has_wildcard = JNI_FALSE;
+        nargs++;
+    }
+    JLI_MemFree(envArgs->elements);
+    JLI_MemFree(envArgs);
+
+    assert ((size_t) nargs == cnt);
+    *arg = '\0';
+
+    // iterate through rest of command line
+    while (src != NULL) {
         src = next_arg(src, arg, &wildcard);
         argsInFile = JLI_PreprocessArg(arg);
         if (argsInFile != NULL) {
-            size_t cnt, i;
             // resize to accommodate another Arg
             cnt = argsInFile->size;
             argv = (StdArg*) JLI_MemRealloc(argv, (nargs + cnt) * sizeof(StdArg));
@@ -230,7 +265,7 @@
             nargs++;
         }
         *arg = '\0';
-    } while (src != NULL);
+    }
 
     JLI_MemFree(arg);
 
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -248,7 +248,8 @@
      */
     private void initResourceBundle(final UIDefaults table) {
         table.setDefaultLocale(Locale.getDefault());
-        table.addResourceBundle(PKG_PREFIX + "resources.aqua");
+        SwingAccessor.getUIDefaultsAccessor().addInternalBundle(table,
+                PKG_PREFIX + "resources.aqua");
         try {
             final ResourceBundle aquaProperties = ResourceBundle.getBundle(PKG_PREFIX + "resources.aqua");
             final Enumeration<String> propertyKeys = aquaProperties.getKeys();
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDecompressor.java	Wed Jul 05 22:46:04 2017 +0200
@@ -156,6 +156,11 @@
     protected boolean planar;
 
     /**
+     * The planar band to decode; ignored for chunky (interleaved) images.
+     */
+    protected int planarBand = 0;
+
+    /**
      * The value of the {@code SamplesPerPixel} tag.
      */
     protected int samplesPerPixel;
@@ -446,24 +451,19 @@
      * Create a {@code ComponentColorModel} for use in creating
      * an {@code ImageTypeSpecifier}.
      */
-    // This code was copied from javax.imageio.ImageTypeSpecifier.
+    // This code was inspired by the method of the same name in
+    // javax.imageio.ImageTypeSpecifier
     static ColorModel createComponentCM(ColorSpace colorSpace,
                                         int numBands,
+                                        int[] bitsPerSample,
                                         int dataType,
                                         boolean hasAlpha,
                                         boolean isAlphaPremultiplied) {
         int transparency =
             hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
 
-        int[] numBits = new int[numBands];
-        int bits = DataBuffer.getDataTypeSize(dataType);
-
-        for (int i = 0; i < numBands; i++) {
-            numBits[i] = bits;
-        }
-
         return new ComponentColorModel(colorSpace,
-                                       numBits,
+                                       bitsPerSample,
                                        hasAlpha,
                                        isAlphaPremultiplied,
                                        transparency,
@@ -581,14 +581,15 @@
      * Determines whether the {@code DataBuffer} is filled without
      * any interspersed padding bits.
      */
-    private static boolean isDataBufferBitContiguous(SampleModel sm)
+    private static boolean isDataBufferBitContiguous(SampleModel sm,
+        int[] bitsPerSample)
         throws IIOException {
         int dataTypeSize = getDataTypeSize(sm.getDataType());
 
         if(sm instanceof ComponentSampleModel) {
             int numBands = sm.getNumBands();
             for(int i = 0; i < numBands; i++) {
-                if(sm.getSampleSize(i) != dataTypeSize) {
+                if(bitsPerSample[i] != dataTypeSize) {
                     // Sample does not fill data element.
                     return false;
                 }
@@ -682,6 +683,7 @@
      * of the supplied {@code WritableRaster}.
      */
     private static void reformatDiscontiguousData(byte[] buf,
+                                                  int[] bitsPerSample,
                                                   int stride,
                                                   int w,
                                                   int h,
@@ -691,7 +693,6 @@
         // Get SampleModel info.
         SampleModel sm = raster.getSampleModel();
         int numBands = sm.getNumBands();
-        int[] sampleSize = sm.getSampleSize();
 
         // Initialize input stream.
         ByteArrayInputStream is = new ByteArrayInputStream(buf);
@@ -705,7 +706,7 @@
             int x = raster.getMinX();
             for(int i = 0; i < w; i++, x++) {
                 for(int b = 0; b < numBands; b++) {
-                    long bits = iis.readBits(sampleSize[b]);
+                    long bits = iis.readBits(bitsPerSample[b]);
                     raster.setSample(x, y, b, (int)bits);
                 }
             }
@@ -806,8 +807,15 @@
                     blueLut[i] = (byte)((colorMap[2*mapSize + i]*255)/65535);
                 }
 
-                int dataType = bitsPerSample[0] == 8 ?
-                    DataBuffer.TYPE_BYTE : DataBuffer.TYPE_USHORT;
+                int dataType;
+                if (bitsPerSample[0] <= 8) {
+                    dataType = DataBuffer.TYPE_BYTE;
+                } else if (sampleFormat[0] ==
+                    BaselineTIFFTagSet.SAMPLE_FORMAT_SIGNED_INTEGER) {
+                    dataType = DataBuffer.TYPE_SHORT;
+                } else {
+                    dataType = DataBuffer.TYPE_USHORT;
+                }
                 return ImageTypeSpecifier.createIndexed(redLut,
                                                         greenLut,
                                                         blueLut,
@@ -1082,6 +1090,7 @@
 
                         cm = createComponentCM(cs,
                                                samplesPerPixel,
+                                               bitsPerSample,
                                                dataType,
                                                hasAlpha,
                                                alphaPremultiplied);
@@ -1089,6 +1098,7 @@
                         ColorSpace cs = new BogusColorSpace(samplesPerPixel);
                         cm = createComponentCM(cs,
                                                samplesPerPixel,
+                                               bitsPerSample,
                                                dataType,
                                                false, // hasAlpha
                                                false); // alphaPremultiplied
@@ -1119,17 +1129,23 @@
                  BaselineTIFFTagSet.SAMPLE_FORMAT_SIGNED_INTEGER);
 
             // Grayscale
-            if(samplesPerPixel == 1) {
-                int dataType =
-                    getDataTypeFromNumBits(maxBitsPerSample, isSigned);
+            if(samplesPerPixel == 1 &&
+                (bitsPerSample[0] == 1 || bitsPerSample[0] == 2 ||
+                 bitsPerSample[0] == 4 || bitsPerSample[0] == 8 ||
+                 bitsPerSample[0] == 16)) {
+                int dataType = getDataTypeFromNumBits(maxBitsPerSample, isSigned);
 
-                return ImageTypeSpecifier.createGrayscale(maxBitsPerSample,
+                return ImageTypeSpecifier.createGrayscale(bitsPerSample[0],
                                                           dataType,
                                                           isSigned);
             }
 
             // Gray-alpha
-            if (samplesPerPixel == 2) {
+            if (samplesPerPixel == 2 &&
+                bitsPerSample[0] == bitsPerSample[1] &&
+                (bitsPerSample[0] == 1 || bitsPerSample[0] == 2 ||
+                 bitsPerSample[0] == 4 || bitsPerSample[0] == 8 ||
+                 bitsPerSample[0] == 16)) {
                 boolean alphaPremultiplied = false;
                 if (extraSamples != null &&
                     extraSamples[0] ==
@@ -1147,6 +1163,13 @@
             }
 
             if (samplesPerPixel == 3 || samplesPerPixel == 4) {
+                int dataType = getDataTypeFromNumBits(maxBitsPerSample, isSigned);
+                int dataTypeSize;
+                try {
+                    dataTypeSize = getDataTypeSize(dataType);
+                } catch (IIOException ignored) {
+                    dataTypeSize = maxBitsPerSample;
+                }
                 if(totalBits <= 32 && !isSigned) {
                     // Packed RGB or RGBA
                     int redMask = createMask(bitsPerSample, 0);
@@ -1169,21 +1192,24 @@
                                                            alphaMask,
                                                            transferType,
                                                            alphaPremultiplied);
-                } else if(samplesPerPixel == 3) {
+                } else if(samplesPerPixel == 3 &&
+                    dataTypeSize == bitsPerSample[0] &&
+                    bitsPerSample[0] == bitsPerSample[1] &&
+                    bitsPerSample[1] == bitsPerSample[2]) {
                     // Interleaved RGB
                     int[] bandOffsets = new int[] {0, 1, 2};
-                    int dataType =
-                        getDataTypeFromNumBits(maxBitsPerSample, isSigned);
                     return ImageTypeSpecifier.createInterleaved(rgb,
                                                                 bandOffsets,
                                                                 dataType,
                                                                 false,
                                                                 false);
-                } else if(samplesPerPixel == 4) {
+                } else if(samplesPerPixel == 4 &&
+                    dataTypeSize == bitsPerSample[0] &&
+                    bitsPerSample[0] == bitsPerSample[1] &&
+                    bitsPerSample[1] == bitsPerSample[2] &&
+                    bitsPerSample[2] == bitsPerSample[3]) {
                     // Interleaved RGBA
                     int[] bandOffsets = new int[] {0, 1, 2, 3};
-                    int dataType =
-                        getDataTypeFromNumBits(maxBitsPerSample, isSigned);
                     boolean alphaPremultiplied = false;
                     if (extraSamples != null &&
                         extraSamples[0] ==
@@ -1196,20 +1222,28 @@
                                                                 true,
                                                                 alphaPremultiplied);
                 }
+            }
+
+            // Arbitrary Interleaved.
+            int dataType =
+                getDataTypeFromNumBits(maxBitsPerSample, isSigned);
+            SampleModel sm = createInterleavedSM(dataType,
+                                                 samplesPerPixel);
+            ColorSpace cs;
+            if (samplesPerPixel <= 2) {
+                cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+            } else if (samplesPerPixel <= 4) {
+                cs = rgb;
             } else {
-                // Arbitrary Interleaved.
-                int dataType =
-                    getDataTypeFromNumBits(maxBitsPerSample, isSigned);
-                SampleModel sm = createInterleavedSM(dataType,
-                                                     samplesPerPixel);
-                ColorSpace cs = new BogusColorSpace(samplesPerPixel);
-                ColorModel cm = createComponentCM(cs,
-                                                  samplesPerPixel,
-                                                  dataType,
-                                                  false, // hasAlpha
-                                                  false); // alphaPremultiplied
-                return new ImageTypeSpecifier(cm, sm);
+                cs = new BogusColorSpace(samplesPerPixel);
             }
+            ColorModel cm = createComponentCM(cs,
+                                              samplesPerPixel,
+                                              bitsPerSample,
+                                              dataType,
+                                              false, // hasAlpha
+                                              false); // alphaPremultiplied
+            return new ImageTypeSpecifier(cm, sm);
         }
 
         return null;
@@ -1285,6 +1319,14 @@
     }
 
     /**
+     * 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
+     */
+    public void setPlanarBand(int planarBand) { this.planarBand = planarBand; }
+
+    /**
      * Sets the value of the {@code samplesPerPixel} field.
      *
      * <p> If this method is called, the {@code beginDecoding}
@@ -2488,7 +2530,7 @@
             // Branch based on whether data are bit-contiguous, i.e.,
             // data are packaed as tightly as possible leaving no unused
             // bits except at the end of a row.
-            if(isDataBufferBitContiguous(sm)) {
+            if(isDataBufferBitContiguous(sm, bitsPerSample)) {
                 // Use byte or float data directly.
                 if (byteData != null) {
                     decodeRaw(byteData, dstOffset,
@@ -2537,11 +2579,19 @@
             } else {
                 // Read discontiguous data into bytes and set the samples
                 // into the Raster.
-                int bpp = getBitsPerPixel(sm);
+                int bpp;
+                if (planar) {
+                    bpp = bitsPerSample[planarBand];
+                } else {
+                    bpp = 0;
+                    for (int bps : bitsPerSample) {
+                        bpp += bps;
+                    }
+                }
                 int bytesPerRow = (bpp*srcWidth + 7)/8;
                 byte[] buf = new byte[bytesPerRow*srcHeight];
                 decodeRaw(buf, 0, bpp, bytesPerRow);
-                reformatDiscontiguousData(buf, bytesPerRow,
+                reformatDiscontiguousData(buf, bitsPerSample, bytesPerRow,
                                           srcWidth, srcHeight,
                                           ras);
             }
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Wed Jul 05 22:46:04 2017 +0200
@@ -414,6 +414,133 @@
     }
 
     //
+    // Retrieve the value of a baseline field as a long.
+    //
+    private long getFieldAsLong(int tagNumber) {
+        TIFFField f = getTIFFField(tagNumber);
+        return f == null ? -1 : f.getAsLong(0);
+    }
+
+    //
+    // Retrieve the value of a baseline field as an int.
+    //
+    private int getFieldAsInt(int tagNumber) {
+        TIFFField f = getTIFFField(tagNumber);
+        return f == null ? -1 : f.getAsInt(0);
+    }
+
+    //
+    // Calculate the number of bytes in each strip or tile. This method
+    // is to be used if and only if no fields exist which provide this
+    // information. The parameter must be empty and if the method succeeds
+    // will contain a single element.
+    //
+    private boolean calculateByteCounts(int expectedSize,
+        List<TIFFField> byteCounts) {
+        if (!byteCounts.isEmpty()) {
+            throw new IllegalArgumentException("byteCounts is not empty");
+        }
+
+        // must be interleaved
+        if (getFieldAsInt(BaselineTIFFTagSet.TAG_PLANAR_CONFIGURATION) ==
+            BaselineTIFFTagSet.PLANAR_CONFIGURATION_PLANAR) {
+            return false;
+        }
+
+        // must be uncompressed
+        if (getFieldAsInt(BaselineTIFFTagSet.TAG_COMPRESSION) !=
+            BaselineTIFFTagSet.COMPRESSION_NONE) {
+            return false;
+        }
+
+        // must have image dimensions
+        long w = getFieldAsLong(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
+        if (w < 0) {
+            return false;
+        }
+        long h = getFieldAsLong(BaselineTIFFTagSet.TAG_IMAGE_LENGTH);
+        if (h < 0) {
+            return false;
+        }
+
+        long tw = getFieldAsLong(BaselineTIFFTagSet.TAG_TILE_WIDTH);
+        if (tw < 0) {
+            tw = w;
+        }
+        long th = getFieldAsLong(BaselineTIFFTagSet.TAG_TILE_LENGTH);
+        if (th < 0) {
+            th = getFieldAsLong(BaselineTIFFTagSet.TAG_ROWS_PER_STRIP);
+            if (th < 0) {
+                th = h;
+            }
+        }
+
+        int[] bitsPerSample = null;
+        TIFFField f = getTIFFField(BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE);
+        if (f != null) {
+            bitsPerSample = f.getAsInts();
+        } else {
+            int samplesPerPixel =
+                getFieldAsInt(BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL);
+            if (samplesPerPixel < 0) {
+                samplesPerPixel = 1;
+            }
+            bitsPerSample = new int[samplesPerPixel];
+            Arrays.fill(bitsPerSample, 8);
+        }
+
+        int bitsPerPixel = 0;
+        for (int bps : bitsPerSample) {
+            bitsPerPixel += bps;
+        }
+
+        int bytesPerRow = (int)(tw*bitsPerPixel + 7)/8;
+        int bytesPerPacket = (int)th*bytesPerRow;
+
+        long nx = (w + tw - 1)/tw;
+        long ny = (h + th - 1)/th;
+
+        if (nx*ny != expectedSize) {
+            return false;
+        }
+
+        boolean isTiled =
+            getTIFFField(BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS) != null;
+
+        int tagNumber;
+        if (isTiled) {
+            tagNumber = BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS;
+        } else {
+            tagNumber = BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS;
+        }
+
+        TIFFTag t = BaselineTIFFTagSet.getInstance().getTag(tagNumber);
+        f = getTIFFField(tagNumber);
+        if (f != null) {
+            removeTIFFField(tagNumber);
+        }
+
+        int numPackets = (int)(nx*ny);
+        long[] packetByteCounts = new long[numPackets];
+        Arrays.fill(packetByteCounts, bytesPerPacket);
+
+        // if the strip or tile width does not exceed the image width and the
+        // image height is not a multiple of the strip or tile height, then
+        // truncate the estimate of the byte count of the last strip to avoid
+        // reading past the end of the data
+        if (tw <= w && h % th != 0) {
+            int numRowsInLastStrip = (int)(h - (ny - 1)*th);
+            packetByteCounts[numPackets - 1] = numRowsInLastStrip*bytesPerRow;
+        }
+
+        f = new TIFFField(t, TIFFTag.TIFF_LONG, numPackets, packetByteCounts);
+        addTIFFField(f);
+        byteCounts.add(f);
+
+        return true;
+    }
+
+    //
     // Verify that data pointed to outside of the IFD itself are within the
     // stream. To be called after all fields have been read and populated.
     //
@@ -502,8 +629,19 @@
 
         // Ensure there is at least a data pointer for JPEG interchange format or
         // both data offsets and byte counts for other compression types.
-        if (jpegOffset == null && (offsets.size() == 0 || byteCounts.size() == 0)) {
-            throw new IIOException("Insufficient data offsets or byte counts");
+        if (jpegOffset == null
+            && (offsets.size() == 0 || byteCounts.size() == 0)) {
+            boolean throwException = true;
+            if (offsets.size() != 0 && byteCounts.size() == 0) {
+                // Attempt to calculate missing byte counts
+                int expectedSize = offsets.get(0).getCount();
+                throwException =
+                    !calculateByteCounts(expectedSize, byteCounts);
+            }
+            if (throwException) {
+                throw new IIOException
+                    ("Insufficient data offsets or byte counts");
+            }
         }
 
         // JPEGQTables - one 64-byte table for each offset.
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1113,6 +1113,7 @@
         long offset = getTileOrStripOffset(tileIndex);
         long byteCount = getTileOrStripByteCount(tileIndex);
 
+        decompressor.setPlanarBand(band);
         decompressor.setStream(stream);
         decompressor.setOffset(offset);
         decompressor.setByteCount((int) byteCount);
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -47,6 +47,7 @@
 import sun.awt.OSInfo;
 import sun.security.action.GetPropertyAction;
 import sun.swing.DefaultLayoutStyle;
+import sun.swing.SwingAccessor;
 import sun.swing.SwingUtilities2;
 
 /**
@@ -288,7 +289,9 @@
     }
 
     private void initResourceBundle(UIDefaults table) {
-        table.addResourceBundle("com.sun.java.swing.plaf.gtk.resources.gtk");
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.java.swing.plaf.gtk.resources.gtk");
     }
 
     protected void initComponentDefaults(UIDefaults table) {
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -43,6 +43,7 @@
 import javax.swing.plaf.basic.BasicComboBoxRenderer;
 import javax.swing.plaf.basic.BasicComboBoxEditor;
 
+import sun.swing.SwingAccessor;
 import sun.swing.SwingUtilities2;
 import sun.awt.OSInfo;
 
@@ -179,7 +180,9 @@
      * used for getting localized defaults.
      */
     private void initResourceBundle(UIDefaults table) {
-        table.addResourceBundle( "com.sun.java.swing.plaf.motif.resources.motif" );
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.java.swing.plaf.motif.resources.motif");
     }
 
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -68,6 +68,7 @@
 
 import sun.swing.DefaultLayoutStyle;
 import sun.swing.ImageIconUIResource;
+import sun.swing.SwingAccessor;
 import sun.swing.icon.SortArrowIcon;
 import sun.swing.SwingUtilities2;
 import sun.swing.StringUIClientPropertyKey;
@@ -287,7 +288,9 @@
      * used for getting localized defaults.
      */
     private void initResourceBundle(UIDefaults table) {
-        table.addResourceBundle( "com.sun.java.swing.plaf.windows.resources.windows" );
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.java.swing.plaf.windows.resources.windows");
     }
 
     // XXX - there are probably a lot of redundant values that could be removed.
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1005,15 +1005,15 @@
     private static final class DirectClip extends DirectDL
             implements Clip, Runnable, AutoClosingClip {
 
-        private Thread thread;
-        private byte[] audioData = null;
-        private int frameSize;         // size of one frame in bytes
-        private int m_lengthInFrames;
-        private int loopCount;
-        private int clipBytePosition;   // index in the audioData array at current playback
-        private int newFramePosition;   // set in setFramePosition()
-        private int loopStartFrame;
-        private int loopEndFrame;      // the last sample included in the loop
+        private volatile Thread thread;
+        private volatile byte[] audioData = null;
+        private volatile int frameSize;         // size of one frame in bytes
+        private volatile int m_lengthInFrames;
+        private volatile int loopCount;
+        private volatile int clipBytePosition;   // index in the audioData array at current playback
+        private volatile int newFramePosition;   // set in setFramePosition()
+        private volatile int loopStartFrame;
+        private volatile int loopEndFrame;      // the last sample included in the loop
 
         // auto closing clip support
         private boolean autoclosing = false;
@@ -1345,7 +1345,8 @@
         @Override
         public void run() {
             if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
-            while (thread != null) {
+            Thread curThread = Thread.currentThread();
+            while (thread == curThread) {
                 // doIO is volatile, but we could check it, then get
                 // pre-empted while another thread changes doIO and notifies,
                 // before we wait (so we sleep in wait forever).
@@ -1353,7 +1354,12 @@
                     if (!doIO) {
                         try {
                             lock.wait();
-                        } catch(InterruptedException ie) {}
+                        } catch(InterruptedException ie) {
+                        } finally {
+                            if (thread != curThread) {
+                                break;
+                            }
+                        }
                     }
                 }
                 while (doIO) {
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/package.html	Wed Jul 05 22:46:04 2017 +0200
@@ -28,8 +28,6 @@
 </head>
 
 <body bgcolor="white">
-
-<body>
 Public classes used by the built-in TIFF plug-ins.
 
 <p>
--- a/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java	Wed Jul 05 22:46:04 2017 +0200
@@ -487,7 +487,7 @@
             = "An array of different chooser types.")
     public void setChooserPanels( AbstractColorChooserPanel[] panels) {
         AbstractColorChooserPanel[] oldValue = chooserPanels;
-        chooserPanels = panels;
+        chooserPanels = Arrays.copyOf(panels, panels.length);
         firePropertyChange(CHOOSER_PANELS_PROPERTY, oldValue, panels);
     }
 
@@ -497,7 +497,7 @@
      * @return an array of <code>AbstractColorChooserPanel</code> objects
      */
     public AbstractColorChooserPanel[] getChooserPanels() {
-        return chooserPanels;
+        return Arrays.copyOf(chooserPanels, chooserPanels.length);
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Wed Jul 05 22:46:04 2017 +0200
@@ -48,6 +48,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
+import java.util.Arrays;
 import java.util.Vector;
 import javax.swing.plaf.OptionPaneUI;
 import javax.swing.event.InternalFrameEvent;
@@ -1812,7 +1813,7 @@
                        Icon icon, Object[] options, Object initialValue) {
 
         this.message = message;
-        this.options = options;
+        this.options = options == null ? null : Arrays.copyOf(options, options.length);
         this.initialValue = initialValue;
         this.icon = icon;
         setMessageType(messageType);
@@ -1972,7 +1973,9 @@
     public void setOptions(Object[] newOptions) {
         Object[]           oldOptions = options;
 
-        options = newOptions;
+        options = newOptions == null
+                ? null
+                : Arrays.copyOf(newOptions, newOptions.length);
         firePropertyChange(OPTIONS_PROPERTY, oldOptions, options);
     }
 
@@ -1983,14 +1986,7 @@
      * @see #setOptions
      */
     public Object[] getOptions() {
-        if(options != null) {
-            int             optionCount = options.length;
-            Object[]        retOptions = new Object[optionCount];
-
-            System.arraycopy(options, 0, retOptions, 0, optionCount);
-            return retOptions;
-        }
-        return options;
+        return options == null ? null : Arrays.copyOf(options, options.length);
     }
 
     /**
@@ -2139,7 +2135,9 @@
     public void setSelectionValues(Object[] newValues) {
         Object[]           oldValues = selectionValues;
 
-        selectionValues = newValues;
+        selectionValues = newValues == null
+                ? null
+                : Arrays.copyOf(newValues, newValues.length);
         firePropertyChange(SELECTION_VALUES_PROPERTY, oldValues, newValues);
         if(selectionValues != null)
             setWantsInput(true);
@@ -2152,7 +2150,9 @@
      * @see #setSelectionValues
      */
     public Object[] getSelectionValues() {
-        return selectionValues;
+        return selectionValues == null
+                ? null
+                : Arrays.copyOf(selectionValues, selectionValues.length);
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -53,6 +53,7 @@
 
 import sun.reflect.misc.MethodUtil;
 import sun.reflect.misc.ReflectUtil;
+import sun.swing.SwingAccessor;
 import sun.swing.SwingUtilities2;
 
 /**
@@ -91,6 +92,10 @@
      */
     private Map<Locale, Map<String, Object>> resourceCache;
 
+    static {
+        SwingAccessor.setUIDefaultsAccessor(UIDefaults::addInternalBundle);
+    }
+
     /**
      * Creates an empty defaults table.
      */
@@ -881,29 +886,49 @@
 
     /**
      * Adds a resource bundle to the list of resource bundles that are
-     * searched for localized values.  Resource bundles are searched in the
-     * reverse order they were added.  In other words, the most recently added
-     * bundle is searched first.
+     * searched for localized values. Resource bundles are searched in
+     * the reverse order they were added, using the
+     * {@linkplain ClassLoader#getSystemClassLoader application class loader}.
+     * In other words, the most recently added bundle is searched first.
      *
      * @param bundleName  the base name of the resource bundle to be added
      * @see java.util.ResourceBundle
      * @see #removeResourceBundle
+     * @see ResourceBundle#getBundle(String, Locale, ClassLoader)
      * @since 1.4
      */
-    public synchronized void addResourceBundle( String bundleName ) {
-        if( bundleName == null ) {
+    public synchronized void addResourceBundle(final String bundleName) {
+        if (bundleName == null) {
+            return;
+        }
+        if (isDesktopResourceBundle(bundleName)) {
+            // Only the java.desktop itself can register resource bundles from
+            // java.desktop module
             return;
         }
-        if( resourceBundles == null ) {
+        addInternalBundle(bundleName);
+    }
+
+    /**
+     * This methods should be used to register internal resource bundles from
+     * the java.desktop module.
+     *
+     * @param bundleName  the base name of the resource bundle to be added
+     * @since 9
+     */
+    private synchronized void addInternalBundle(final String bundleName) {
+        if (bundleName == null) {
+            return;
+        }
+        if (resourceBundles == null) {
             resourceBundles = new Vector<String>(5);
         }
         if (!resourceBundles.contains(bundleName)) {
-            resourceBundles.add( bundleName );
+            resourceBundles.add(bundleName);
             resourceCache.clear();
         }
     }
 
-
     /**
      * Removes a resource bundle from the list of resource bundles that are
      * searched for localized defaults.
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -48,7 +48,7 @@
 
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
-
+import sun.swing.SwingAccessor;
 import sun.swing.SwingUtilities2;
 import sun.swing.icon.SortArrowIcon;
 
@@ -439,7 +439,9 @@
      */
     private void initResourceBundle(UIDefaults table) {
         table.setDefaultLocale( Locale.getDefault() );
-        table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" );
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.swing.internal.plaf.basic.resources.basic");
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, 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
@@ -43,6 +43,8 @@
 import sun.security.action.GetPropertyAction;
 import sun.swing.DefaultLayoutStyle;
 import static javax.swing.UIDefaults.LazyValue;
+
+import sun.swing.SwingAccessor;
 import sun.swing.SwingUtilities2;
 
 /**
@@ -418,7 +420,9 @@
      * used for getting localized defaults.
      */
     private void initResourceBundle(UIDefaults table) {
-        table.addResourceBundle( "com.sun.swing.internal.plaf.metal.resources.metal" );
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.swing.internal.plaf.metal.resources.metal");
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -647,9 +647,12 @@
 
         Region.registerUIs(table);
         table.setDefaultLocale(Locale.getDefault());
-        table.addResourceBundle(
-              "com.sun.swing.internal.plaf.basic.resources.basic" );
-        table.addResourceBundle("com.sun.swing.internal.plaf.synth.resources.synth");
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.swing.internal.plaf.basic.resources.basic");
+        SwingAccessor.getUIDefaultsAccessor()
+                     .addInternalBundle(table,
+                             "com.sun.swing.internal.plaf.synth.resources.synth");
 
         // SynthTabbedPaneUI supports rollover on tabs, GTK does not
         table.put("TabbedPane.isTabRollover", Boolean.TRUE);
--- a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java	Wed Jul 05 22:46:04 2017 +0200
@@ -32,7 +32,7 @@
 import java.io.FileNotFoundException;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
-import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.concurrent.Callable;
 
@@ -244,7 +244,7 @@
             return (ShellFolder)file;
         }
 
-        if (!Files.exists(file.toPath(), LinkOption.NOFOLLOW_LINKS)) {
+        if (!Files.exists(Paths.get(file.getPath()), LinkOption.NOFOLLOW_LINKS)) {
             throw new FileNotFoundException();
         }
         return shellFolderManager.createShellFolder(file);
--- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeFont.java	Wed Jul 05 22:46:04 2017 +0200
@@ -99,6 +99,10 @@
     public static final int ottoTag = 0x4f54544f; // 'otto' - OpenType font
 
     /* -- ID's used in the 'name' table */
+    public static final int MAC_PLATFORM_ID = 1;
+    public static final int MACROMAN_SPECIFIC_ID = 0;
+    public static final int MACROMAN_ENGLISH_LANG = 0;
+
     public static final int MS_PLATFORM_ID = 3;
     /* MS locale id for US English is the "default" */
     public static final short ENGLISH_LOCALE_ID = 0x0409; // 1033 decimal
@@ -1108,7 +1112,12 @@
         metrics[offset+3] = ulSize * pointSize;
     }
 
-    private String makeString(byte[] bytes, int len, short encoding) {
+    private String makeString(byte[] bytes, int len,
+                             short platformID, short encoding) {
+
+        if (platformID == MAC_PLATFORM_ID) {
+            encoding = -1; // hack so we can re-use the code below.
+        }
 
         /* Check for fonts using encodings 2->6 is just for
          * some old DBCS fonts, apparently mostly on Solaris.
@@ -1130,6 +1139,7 @@
 
         String charset;
         switch (encoding) {
+            case -1: charset = "US-ASCII";break;
             case 1:  charset = "UTF-16";  break; // most common case first.
             case 0:  charset = "UTF-16";  break; // symbol uses this
             case 2:  charset = "SJIS";    break;
@@ -1175,7 +1185,8 @@
 
             for (int i=0; i<numRecords; i++) {
                 short platformID = sbuffer.get();
-                if (platformID != MS_PLATFORM_ID) {
+                if (platformID != MS_PLATFORM_ID &&
+                    platformID != MAC_PLATFORM_ID) {
                     sbuffer.position(sbuffer.position()+5);
                     continue; // skip over this record.
                 }
@@ -1185,6 +1196,14 @@
                 int nameLen    = ((int) sbuffer.get()) & 0xffff;
                 int namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
                 String tmpName = null;
+
+                // only want MacRoman encoding and English name on Mac.
+                if ((platformID == MAC_PLATFORM_ID) &&
+                    (encodingID != MACROMAN_SPECIFIC_ID ||
+                     langID != MACROMAN_ENGLISH_LANG)) {
+                    continue;
+                }
+
                 switch (nameID) {
 
                 case FAMILY_NAME_ID:
@@ -1196,7 +1215,7 @@
                     {
                         buffer.position(namePtr);
                         buffer.get(name, 0, nameLen);
-                        tmpName = makeString(name, nameLen, encodingID);
+                        tmpName = makeString(name, nameLen, platformID, encodingID);
                         if (familyName == null || langID == ENGLISH_LOCALE_ID){
                             familyName = tmpName;
                         }
@@ -1229,7 +1248,7 @@
                     {
                         buffer.position(namePtr);
                         buffer.get(name, 0, nameLen);
-                        tmpName = makeString(name, nameLen, encodingID);
+                        tmpName = makeString(name, nameLen, platformID, encodingID);
 
                         if (fullName == null || langID == ENGLISH_LOCALE_ID) {
                             fullName = tmpName;
@@ -1290,7 +1309,7 @@
                      || langID == findLocaleID)) {
                     buffer.position(namePtr);
                     buffer.get(name, 0, nameLen);
-                    foundName = makeString(name, nameLen, encodingID);
+                    foundName = makeString(name, nameLen, platformID, encodingID);
                     if (langID == findLocaleID) {
                         return foundName;
                     }
@@ -1627,7 +1646,7 @@
                 if (nameID == requestedID) {
                     buffer.position(namePtr);
                     buffer.get(name, 0, nameLen);
-                    names.add(makeString(name, nameLen, encodingID));
+                    names.add(makeString(name, nameLen, platformID, encodingID));
                 }
             }
         }
--- a/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Wed Jul 05 22:46:04 2017 +0200
@@ -548,7 +548,7 @@
             actions = actionList.toArray(new Action[actionList.size()]);
         }
 
-        return actions;
+        return Arrays.copyOf(actions, actions.length);
     }
 
     protected void createActionMap() {
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,6 +92,16 @@
     }
 
     /**
+     * An accessor for the UIDefaults class.
+     */
+    public interface UIDefaultsAccessor {
+        /**
+         * Adds a resource bundle to the list of resource bundles.
+         */
+        void addInternalBundle(UIDefaults uiDefaults, String bundleName);
+    }
+
+    /**
      * An accessor for the RepaintManager class.
      */
     public interface RepaintManagerAccessor {
@@ -184,6 +194,28 @@
     }
 
     /**
+     * The UIDefaults class accessor object
+     */
+    private static UIDefaultsAccessor uiDefaultsAccessor;
+
+    /**
+     * Set an accessor object for the UIDefaults class.
+     */
+    public static void setUIDefaultsAccessor(UIDefaultsAccessor accessor) {
+        uiDefaultsAccessor = accessor;
+    }
+
+    /**
+     * Retrieve the accessor object for the JLightweightFrame class
+     */
+    public static UIDefaultsAccessor getUIDefaultsAccessor() {
+        if (uiDefaultsAccessor == null) {
+            unsafe.ensureClassInitialized(UIDefaults.class);
+        }
+        return uiDefaultsAccessor;
+    }
+
+    /**
      * The RepaintManager class accessor object.
      */
     private static RepaintManagerAccessor repaintManagerAccessor;
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES	Wed Jul 05 22:46:04 2017 +0200
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
 #if 0
 CHANGES - changes for libpng
 
@@ -618,7 +593,7 @@
     with trailing compressed parts easier in the future, and added new functions
     png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
     png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
-  NOTE: Applications that write text chunks MUST define png_text->lang
+    NOTE: Applications that write text chunks MUST define png_text->lang
     before calling png_set_text(). It must be set to NULL if you want to
     write tEXt or zTXt chunks.  If you want your application to be able to
     run with older versions of libpng, use
@@ -5621,6 +5596,204 @@
 Version 1.6.23 [June 9, 2016]
   Fixed bad link to RFC2083 in png.5 (Nikola Forro).
 
+Version 1.6.24beta01 [June 11, 2016]
+  Avoid potential overflow of the PNG_IMAGE_SIZE macro.  This macro
+    is not used within libpng, but is used in some of the examples.
+
+Version 1.6.24beta02 [June 23, 2016]
+  Correct filter heuristic overflow handling. This was broken when the
+    write filter code was moved out-of-line; if there is a single filter and
+    the heuristic sum overflows the calculation of the filtered line is not
+    completed.  In versions prior to 1.6 the code was duplicated in-line
+    and the check not performed, so the filter operation completed; however,
+    in the multi-filter case where the sum is performed the 'none' filter would
+    be selected if all the sums overflowed, even if it wasn't in the filter
+    list.  The fix to the first problem is simply to provide PNG_SIZE_MAX as
+    the current lmins sum value; this means the sum can never exceed it and
+    overflows silently.  A reasonable compiler that does choose to inline
+    the code will simply eliminate the sum check.
+  The fix to the second problem is to use high precision arithmetic (this is
+    implemented in 1.7), however a simple safe fix here is to chose the lowest
+    numbered filter in the list from png_set_filter (this only works if the
+    first problem is also fixed) (John Bowler).
+  Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois).
+  Fixed the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application
+    as a result of the application using an increased 'row_stride'; previously
+    png_image_finish_read only checked for overflow on the base calculation of
+    components.  (I.e. it checked for overflow of a 32-bit number on the total
+    number of pixel components in the output format, not the possibly padded row
+    length and not the number of bytes, which for linear formats is twice the
+    number of components.)
+  MSVC does not like '-(unsigned)', so replaced it with 0U-(unsigned)
+  MSVC does not like (uInt) = -(unsigned) (i.e. as an initializer), unless
+    the conversion is explicitly invoked by a cast.
+  Put the SKIP definition in the correct place. It needs to come after the
+    png.h include (see all the other .c files in contrib/libtests) because it
+    depends on PNG_LIBPNG_VER.
+  Removed the three compile warning options from the individual project
+    files into the zlib.props globals.  It increases the warning level from 4
+    to All and adds a list of the warnings that need to be turned off.  This is
+    semi-documentary; the intent is to tell libpng users which warnings have
+    been examined and judged non-fixable at present.  The warning about
+    structure padding is fixable, but it would be a signficant change (moving
+    structure members around).
+
+Version 1.6.24beta03 [July 4, 2016]
+  Optimized absolute value calculation in filter selection, similar to
+    code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to
+    use this.
+  Added pngcp to the build together with a pngcp.dfa configuration test.
+  Added high resolution timing to pngcp.
+  Added "Common linking failures" section to INSTALL.
+  Relocated misplaced #endif in png.c sRGB profile checking.
+  Fixed two Coverity issues in pngcp.c.
+
+Version 1.6.24beta04 [July 8, 2016]
+  Avoid filter-selection heuristic sum calculations in cases where only one
+    filter is a candidate for selection. This trades off code size (added
+    private png_setup_*_row_only() functions) for speed.
+
+Version 1.6.24beta05 [July 13, 2016]
+  Fixed some indentation to comply with our coding style.
+  Added contrib/tools/reindent.
+
+Version 1.6.24beta06 [July 18, 2016]
+  Fixed more indentation to comply with our coding style.
+  Eliminated unnecessary tests of boolean png_isaligned() vs 0.
+
+Version 1.6.24rc01 [July 25, 2016]
+  No changes.
+
+Version 1.6.24rc02 [August 1, 2016]
+  Conditionally compile SSE2 headers in contrib/intel/intel_sse.patch
+  Conditionally compile png_decompress_chunk().
+
+Version 1.6.24rc03 [August 2, 2016]
+  Conditionally compile ARM_NEON headers in pngpriv.h
+  Updated contrib/intel/intel_sse.patch
+
+Version 1.6.24[August 4, 2016]
+  No changes.
+
+Version 1.6.25beta01 [August 12, 2016]
+  Reject oversized iCCP profile immediately.
+  Cleaned up PNG_DEBUG compile of pngtest.c.
+  Conditionally compile png_inflate().
+
+Version 1.6.25beta02 [August 18, 2016]
+  Don't install pngcp; it conflicts with pngcp in the pngtools package.
+  Minor editing of INSTALL, (whitespace, added copyright line)
+
+Version 1.6.25rc01 [August 24, 2016]
+  No changes.
+
+Version 1.6.25rc02 [August 29, 2016]
+  Added MIPS support (Mandar Sahastrabuddhe <Mandar.Sahastrabuddhe@imgtec.com>).
+  Only the UP filter is currently implemented.
+
+Version 1.6.25rc03 [August 29, 2016]
+  Rebased contrib/intel/intel_sse.patch after the MIPS implementation.
+
+Version 1.6.25rc04 [August 30, 2016]
+  Added MIPS support for SUB, AVG, and PAETH filters (Mandar Sahastrabuddhe).
+
+Version 1.6.25rc05 [August 30, 2016]
+  Rebased contrib/intel/intel_sse.patch after the MIPS implementation update..
+
+Version 1.6.25 [September 1, 2016]
+  No changes.
+
+Version 1.6.26beta01 [September 26, 2016]
+  Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
+    bugfix by John Bowler).
+  Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL
+    has allocated memory that libpng needs to free.
+  Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
+  Issue a png_benign_error instead of a png_error on ADLER32 mismatch
+    while decoding compressed data chunks.
+  Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngpriv.h, pngstruct.h, and
+    pngrutil.c.
+  If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
+    ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
+  Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error().
+  Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
+  Merged pngtest.c with libpng-1.7.0beta84/pngtest.c
+
+Version 1.6.26beta02 [October 1, 2016]
+  Updated the documentation about CRC and ADLER32 handling.
+  Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c,
+     pngwrite.c, pngunknown.c, and pngvalid.c.
+  Quieted 58 (out of 144) -Wconversion compiler warnings by changing
+    flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes
+    in png.c, pngread.c, and pngwutil.c.
+
+Version 1.6.26beta03 [October 2, 2016]
+  Removed contrib/libtests/*.orig and *.rej that slipped into the tarballs.
+  Quieted the 86 remaining -Wconversion compiler warnings by
+    revising the png_isaligned() macro and trivial changes in png.c,
+    pngerror.c, pngget.c, pngmem.c, pngset.c, pngrtran.c, pngrutil.c,
+    pngwtran.c, pngwrite.c, and pngwutil.c.
+
+Version 1.6.26beta04 [October 3, 2016]
+  Quieted (bogus?) clang warnings about "absolute value has no effect"
+    when PNG_USE_ABS is defined.
+  Fixed offsets in contrib/intel/intel_sse.patch
+
+Version 1.6.26beta05 [October 6, 2016]
+  Changed integer constant 4294967294 to unsigned 4294967294U in pngconf.h
+    to avoid a signed/unsigned compare in the preprocessor.
+
+Version 1.6.26beta06 [October 7, 2016]
+  Use zlib-1.2.8.1 inflateValidate() instead of inflateReset2() to
+    optionally avoid ADLER32 evaluation.
+
+Version 1.6.26rc01 [October 12, 2016]
+  No changes.
+
+Version 1.6.26 [October 20, 2016]
+  Cosmetic change, "ptr != 0" to "ptr != NULL" in png.c and pngrutil.c
+  Despammed email addresses (replaced "@" with " at ").
+
+Version 1.6.27beta01 [November 2, 2016]
+  Restrict the new ADLER32-skipping to IDAT chunks.  It broke iCCP chunk
+    handling: an erroneous iCCP chunk would throw a png_error and reject the
+    entire PNG image instead of rejecting just the iCCP chunk with a warning,
+    if built with zlib-1.2.8.1.
+
+Version 1.6.27rc01 [December 27, 2016]
+  Control ADLER32 checking with new PNG_IGNORE_ADLER32 option.
+  Removed the use of a macro containing the pre-processor 'defined'
+    operator.  It is unclear whether this is valid; a macro that
+    "generates" 'defined' is not permitted, but the use of the word
+    "generates" within the C90 standard seems to imply more than simple
+    substitution of an expression itself containing a well-formed defined
+    operation.
+  Added ARM support to CMakeLists.txt (Andreas Franek).
+
+Version 1.6.27 [December 29, 2016]
+  Fixed a potential null pointer dereference in png_set_text_2() (bug report
+    and patch by Patrick Keshishian, CVE-2016-10087).
+
+Version 1.6.28rc01 [January 3, 2017]
+  Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna).
+  Added option to Cmake build allowing a custom location of zlib to be
+    specified in a scenario where libpng is being built as a subproject
+    alongside zlib by another project (Sam Serrels).
+  Changed png_ptr->options from a png_byte to png_uint_32, to accomodate
+    up to 16 options.
+
+Version 1.6.28rc02 [January 4, 2017]
+  Added "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna).
+  Moved SSE2 optimization code into the main libpng source directory.
+    Configure libpng with "configure --enable-intel-sse" or compile
+    libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it.
+
+Version 1.6.28rc03 [January 4, 2017]
+  Backed out the SSE optimization and last CMakeLists.txt to allow time for QA.
+
+Version 1.6.28 [January 5, 2017]
+  No changes.
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE	Wed Jul 05 22:46:04 2017 +0200
@@ -10,8 +10,8 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
-Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
+libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
+Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
 derived from libpng-1.0.6, and are distributed according to the same
 disclaimer and license as libpng-1.0.6 with the following individuals
 added to the list of Contributing Authors:
@@ -22,6 +22,7 @@
    Cosmin Truta
    Gilles Vollant
    James Yu
+   Mandar Sahastrabuddhe
 
 and with the following additions to the disclaimer:
 
@@ -127,4 +128,4 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-June 9, 2016
+January 5, 2017
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/README	Wed Jul 05 22:46:04 2017 +0200
@@ -1,4 +1,4 @@
-README for libpng version 1.6.23 - June 9, 2016 (shared library 16.0)
+README for libpng version 1.6.28 - January 5, 2017 (shared library 16.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -180,15 +180,18 @@
       pngwutil.c    =>  Write utility functions
       arm           =>  Contains optimized code for the ARM platform
       contrib       =>  Contributions
+       arm-neon         =>  Optimized code for ARM-NEON platform
        examples         =>  Example programs
        gregbook         =>  source code for PNG reading and writing, from
                             Greg Roelofs' "PNG: The Definitive Guide",
                             O'Reilly, 1999
+       intel            =>  Optimized code for INTEL-SSE2 platform
        libtests         =>  Test programs
        pngminim         =>  Minimal decoder, encoder, and progressive decoder
                             programs demonstrating use of pngusr.dfa
        pngminus         =>  Simple pnm2png and png2pnm programs
        pngsuite         =>  Test images
+       testpngs
        tools            =>  Various tools
        visupng          =>  Contains a MSVC workspace for VisualPng
       projects      =>  Contains project files and workspaces for
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.19 [November 12, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.28 [January 5, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -42,7 +42,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;
+typedef png_libpng_version_1_6_28 Your_png_h_is_not_version_1_6_28;
 
 /* Tells libpng that we have already handled the first "num_bytes" bytes
  * of the PNG file signature.  If the PNG data is embedded into another
@@ -113,7 +113,7 @@
    if (items >= (~(png_alloc_size_t)0)/size)
    {
       png_warning (png_voidcast(png_structrp, png_ptr),
-         "Potential overflow in png_zalloc()");
+          "Potential overflow in png_zalloc()");
       return NULL;
    }
 
@@ -200,10 +200,10 @@
 int
 png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
 {
-     /* Libpng versions 1.0.0 and later are binary compatible if the version
-      * string matches through the second '.'; we must recompile any
-      * applications that use any older library version.
-      */
+   /* Libpng versions 1.0.0 and later are binary compatible if the version
+    * string matches through the second '.'; we must recompile any
+    * applications that use any older library version.
+    */
 
    if (user_png_ver != NULL)
    {
@@ -325,7 +325,7 @@
          if (png_user_version_check(&create_struct, user_png_ver) != 0)
          {
             png_structrp png_ptr = png_voidcast(png_structrp,
-               png_malloc_warn(&create_struct, (sizeof *png_ptr)));
+                png_malloc_warn(&create_struct, (sizeof *png_ptr)));
 
             if (png_ptr != NULL)
             {
@@ -374,7 +374,7 @@
     * has always been done in 'example.c'.
     */
    info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
-      (sizeof *info_ptr)));
+       (sizeof *info_ptr)));
 
    if (info_ptr != NULL)
       memset(info_ptr, 0, (sizeof *info_ptr));
@@ -430,7 +430,7 @@
  */
 PNG_FUNCTION(void,PNGAPI
 png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
-   PNG_DEPRECATED)
+    PNG_DEPRECATED)
 {
    png_inforp info_ptr = *ptr_ptr;
 
@@ -445,7 +445,7 @@
       /* The following line is why this API should not be used: */
       free(info_ptr);
       info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
-         (sizeof *info_ptr)));
+          (sizeof *info_ptr)));
       if (info_ptr == NULL)
          return;
       *ptr_ptr = info_ptr;
@@ -458,7 +458,7 @@
 /* The following API is not called internally */
 void PNGAPI
 png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
-   int freer, png_uint_32 mask)
+    int freer, png_uint_32 mask)
 {
    png_debug(1, "in png_data_freer");
 
@@ -477,7 +477,7 @@
 
 void PNGAPI
 png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
-   int num)
+    int num)
 {
    png_debug(1, "in png_free_data");
 
@@ -486,7 +486,7 @@
 
 #ifdef PNG_TEXT_SUPPORTED
    /* Free text item num or (if num == -1) all text items */
-   if (info_ptr->text != 0 &&
+   if (info_ptr->text != NULL &&
        ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
    {
       if (num != -1)
@@ -505,6 +505,7 @@
          png_free(png_ptr, info_ptr->text);
          info_ptr->text = NULL;
          info_ptr->num_text = 0;
+         info_ptr->max_text = 0;
       }
    }
 #endif
@@ -569,7 +570,7 @@
 
 #ifdef PNG_sPLT_SUPPORTED
    /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
-   if (info_ptr->splt_palettes != 0 &&
+   if (info_ptr->splt_palettes != NULL &&
        ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
    {
       if (num != -1)
@@ -599,7 +600,7 @@
 #endif
 
 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-   if (info_ptr->unknown_chunks != 0 &&
+   if (info_ptr->unknown_chunks != NULL &&
        ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
    {
       if (num != -1)
@@ -645,7 +646,7 @@
    /* Free any image bits attached to the info structure */
    if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
    {
-      if (info_ptr->row_pointers != 0)
+      if (info_ptr->row_pointers != NULL)
       {
          png_uint_32 row;
          for (row = 0; row < info_ptr->height; row++)
@@ -712,7 +713,7 @@
 void PNGAPI
 png_save_int_32(png_bytep buf, png_int_32 i)
 {
-   png_save_uint_32(buf, i);
+   png_save_uint_32(buf, (png_uint_32)i);
 }
 #  endif
 
@@ -803,15 +804,15 @@
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-      "libpng version 1.6.23 - June 9, 2016" PNG_STRING_NEWLINE \
-      "Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
+      "libpng version 1.6.28 - January 5, 2017" PNG_STRING_NEWLINE \
+      "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
       PNG_STRING_NEWLINE \
       "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
       "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
       PNG_STRING_NEWLINE;
 #  else
-   return "libpng version 1.6.23 - June 9, 2016\
-      Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
+   return "libpng version 1.6.28 - January 5, 2017\
+      Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
 #  endif
@@ -1061,7 +1062,7 @@
 #ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */
 static int
 png_colorspace_check_gamma(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, png_fixed_point gAMA, int from)
+    png_colorspacerp colorspace, png_fixed_point gAMA, int from)
    /* This is called to check a new gamma value against an existing one.  The
     * routine returns false if the new gamma value should not be written.
     *
@@ -1075,7 +1076,7 @@
    png_fixed_point gtest;
 
    if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
-      (png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) == 0  ||
+       (png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) == 0  ||
       png_gamma_significant(gtest) != 0))
    {
       /* Either this is an sRGB image, in which case the calculated gamma
@@ -1087,7 +1088,7 @@
       if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)
       {
          png_chunk_report(png_ptr, "gamma value does not match sRGB",
-            PNG_CHUNK_ERROR);
+             PNG_CHUNK_ERROR);
          /* Do not overwrite an sRGB value */
          return from == 2;
       }
@@ -1095,7 +1096,7 @@
       else /* sRGB tag not involved */
       {
          png_chunk_report(png_ptr, "gamma value does not match libpng estimate",
-            PNG_CHUNK_WARNING);
+             PNG_CHUNK_WARNING);
          return from == 1;
       }
    }
@@ -1105,7 +1106,7 @@
 
 void /* PRIVATE */
 png_colorspace_set_gamma(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, png_fixed_point gAMA)
+    png_colorspacerp colorspace, png_fixed_point gAMA)
 {
    /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
     * occur.  Since the fixed point representation is asymetrical it is
@@ -1663,8 +1664,8 @@
 
 static int
 png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
-   int preferred)
+    png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
+    int preferred)
 {
    if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
       return 0;
@@ -1711,7 +1712,7 @@
 
 int /* PRIVATE */
 png_colorspace_set_chromaticities(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, const png_xy *xy, int preferred)
+    png_colorspacerp colorspace, const png_xy *xy, int preferred)
 {
    /* We must check the end points to ensure they are reasonable - in the past
     * color management systems have crashed as a result of getting bogus
@@ -1725,7 +1726,7 @@
    {
       case 0: /* success */
          return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,
-            preferred);
+             preferred);
 
       case 1:
          /* We can't invert the chromaticities so we can't produce value XYZ
@@ -1748,7 +1749,7 @@
 
 int /* PRIVATE */
 png_colorspace_set_endpoints(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
+    png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
 {
    png_XYZ XYZ = *XYZ_in;
    png_xy xy;
@@ -1757,7 +1758,7 @@
    {
       case 0:
          return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,
-            preferred);
+             preferred);
 
       case 1:
          /* End points are invalid. */
@@ -1814,7 +1815,7 @@
 
 static int
 png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   png_const_charp name, png_alloc_size_t value, png_const_charp reason)
+    png_const_charp name, png_alloc_size_t value, png_const_charp reason)
 {
    size_t pos;
    char message[196]; /* see below for calculation */
@@ -1839,8 +1840,8 @@
          char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/
 
          pos = png_safecat(message, (sizeof message), pos,
-            png_format_number(number, number+(sizeof number),
-               PNG_NUMBER_FORMAT_x, value));
+             png_format_number(number, number+(sizeof number),
+             PNG_NUMBER_FORMAT_x, value));
          pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/
       }
 #  endif
@@ -1854,7 +1855,7 @@
     * application errors the PNG won't be written.)
     */
    png_chunk_report(png_ptr, message,
-      (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
+       (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
 
    return 0;
 }
@@ -1863,7 +1864,7 @@
 #ifdef PNG_sRGB_SUPPORTED
 int /* PRIVATE */
 png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   int intent)
+    int intent)
 {
    /* sRGB sets known gamma, end points and (from the chunk) intent. */
    /* IMPORTANT: these are not necessarily the values found in an ICC profile
@@ -1900,10 +1901,10 @@
     */
    if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
       return png_icc_profile_error(png_ptr, colorspace, "sRGB",
-         (unsigned)intent, "invalid sRGB rendering intent");
+          (unsigned)intent, "invalid sRGB rendering intent");
 
    if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
-      colorspace->rendering_intent != intent)
+       colorspace->rendering_intent != intent)
       return png_icc_profile_error(png_ptr, colorspace, "sRGB",
          (unsigned)intent, "inconsistent rendering intents");
 
@@ -1917,8 +1918,8 @@
     * warn but overwrite the value with the correct one.
     */
    if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
-      !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
-         100))
+       !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
+       100))
       png_chunk_report(png_ptr, "cHRM chunk does not match sRGB",
          PNG_CHUNK_ERROR);
 
@@ -1926,7 +1927,7 @@
     * returns true when the 'from' argument corresponds to sRGB (2).
     */
    (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,
-      2/*from sRGB*/);
+       2/*from sRGB*/);
 
    /* intent: bugs in GCC force 'int' to be used as the parameter type. */
    colorspace->rendering_intent = (png_uint_16)intent;
@@ -1959,21 +1960,55 @@
 static const png_byte D50_nCIEXYZ[12] =
    { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
 
-int /* PRIVATE */
-png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   png_const_charp name, png_uint_32 profile_length)
+static int /* bool */
+icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
+    png_const_charp name, png_uint_32 profile_length)
 {
    if (profile_length < 132)
       return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
-         "too short");
+          "too short");
 
    return 1;
 }
 
+#ifdef PNG_READ_iCCP_SUPPORTED
+int /* PRIVATE */
+png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
+    png_const_charp name, png_uint_32 profile_length)
+{
+   if (!icc_check_length(png_ptr, colorspace, name, profile_length))
+      return 0;
+
+   /* This needs to be here because the 'normal' check is in
+    * png_decompress_chunk, yet this happens after the attempt to
+    * png_malloc_base the required data.  We only need this on read; on write
+    * the caller supplies the profile buffer so libpng doesn't allocate it.  See
+    * the call to icc_check_length below (the write case).
+    */
+#  ifdef PNG_SET_USER_LIMITS_SUPPORTED
+      else if (png_ptr->user_chunk_malloc_max > 0 &&
+               png_ptr->user_chunk_malloc_max < profile_length)
+         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
+             "exceeds application limits");
+#  elif PNG_USER_CHUNK_MALLOC_MAX > 0
+      else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)
+         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
+             "exceeds libpng limits");
+#  else /* !SET_USER_LIMITS */
+      /* This will get compiled out on all 32-bit and better systems. */
+      else if (PNG_SIZE_MAX < profile_length)
+         return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
+             "exceeds system limits");
+#  endif /* !SET_USER_LIMITS */
+
+   return 1;
+}
+#endif /* READ_iCCP */
+
 int /* PRIVATE */
 png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   png_const_charp name, png_uint_32 profile_length,
-   png_const_bytep profile/* first 132 bytes only */, int color_type)
+    png_const_charp name, png_uint_32 profile_length,
+    png_const_bytep profile/* first 132 bytes only */, int color_type)
 {
    png_uint_32 temp;
 
@@ -1985,18 +2020,18 @@
    temp = png_get_uint_32(profile);
    if (temp != profile_length)
       return png_icc_profile_error(png_ptr, colorspace, name, temp,
-         "length does not match profile");
+          "length does not match profile");
 
    temp = (png_uint_32) (*(profile+8));
    if (temp > 3 && (profile_length & 3))
       return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
-         "invalid length");
+          "invalid length");
 
    temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
    if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
       profile_length < 132+12*temp) /* truncated tag table */
       return png_icc_profile_error(png_ptr, colorspace, name, temp,
-         "tag count too large");
+          "tag count too large");
 
    /* The 'intent' must be valid or we can't store it, ICC limits the intent to
     * 16 bits.
@@ -2004,14 +2039,14 @@
    temp = png_get_uint_32(profile+64);
    if (temp >= 0xffff) /* The ICC limit */
       return png_icc_profile_error(png_ptr, colorspace, name, temp,
-         "invalid rendering intent");
+          "invalid rendering intent");
 
    /* This is just a warning because the profile may be valid in future
     * versions.
     */
    if (temp >= PNG_sRGB_INTENT_LAST)
       (void)png_icc_profile_error(png_ptr, NULL, name, temp,
-         "intent outside defined range");
+          "intent outside defined range");
 
    /* At this point the tag table can't be checked because it hasn't necessarily
     * been loaded; however, various header fields can be checked.  These checks
@@ -2028,7 +2063,7 @@
    temp = png_get_uint_32(profile+36); /* signature 'ascp' */
    if (temp != 0x61637370)
       return png_icc_profile_error(png_ptr, colorspace, name, temp,
-         "invalid signature");
+          "invalid signature");
 
    /* Currently the PCS illuminant/adopted white point (the computational
     * white point) are required to be D50,
@@ -2039,7 +2074,7 @@
     */
    if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)
       (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,
-         "PCS illuminant is not D50");
+          "PCS illuminant is not D50");
 
    /* The PNG spec requires this:
     * "If the iCCP chunk is present, the image samples conform to the colour
@@ -2067,18 +2102,18 @@
       case 0x52474220: /* 'RGB ' */
          if ((color_type & PNG_COLOR_MASK_COLOR) == 0)
             return png_icc_profile_error(png_ptr, colorspace, name, temp,
-               "RGB color space not permitted on grayscale PNG");
+                "RGB color space not permitted on grayscale PNG");
          break;
 
       case 0x47524159: /* 'GRAY' */
          if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
             return png_icc_profile_error(png_ptr, colorspace, name, temp,
-               "Gray color space not permitted on RGB PNG");
+                "Gray color space not permitted on RGB PNG");
          break;
 
       default:
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
-            "invalid ICC profile color space");
+             "invalid ICC profile color space");
    }
 
    /* It is up to the application to check that the profile class matches the
@@ -2103,7 +2138,7 @@
       case 0x61627374: /* 'abst' */
          /* May not be embedded in an image */
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
-            "invalid embedded Abstract ICC profile");
+             "invalid embedded Abstract ICC profile");
 
       case 0x6c696e6b: /* 'link' */
          /* DeviceLink profiles cannot be interpreted in a non-device specific
@@ -2113,7 +2148,7 @@
           * PNG.
           */
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
-            "unexpected DeviceLink ICC profile class");
+             "unexpected DeviceLink ICC profile class");
 
       case 0x6e6d636c: /* 'nmcl' */
          /* A NamedColor profile is also device specific, however it doesn't
@@ -2121,7 +2156,7 @@
           * certainly it will fail the tests below.
           */
          (void)png_icc_profile_error(png_ptr, NULL, name, temp,
-            "unexpected NamedColor ICC profile class");
+             "unexpected NamedColor ICC profile class");
          break;
 
       default:
@@ -2131,7 +2166,7 @@
           * understood profiles.
           */
          (void)png_icc_profile_error(png_ptr, NULL, name, temp,
-            "unrecognized ICC profile class");
+             "unrecognized ICC profile class");
          break;
    }
 
@@ -2147,7 +2182,7 @@
 
       default:
          return png_icc_profile_error(png_ptr, colorspace, name, temp,
-            "unexpected ICC PCS encoding");
+             "unexpected ICC PCS encoding");
    }
 
    return 1;
@@ -2155,8 +2190,8 @@
 
 int /* PRIVATE */
 png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   png_const_charp name, png_uint_32 profile_length,
-   png_const_bytep profile /* header plus whole tag table */)
+    png_const_charp name, png_uint_32 profile_length,
+    png_const_bytep profile /* header plus whole tag table */)
 {
    png_uint_32 tag_count = png_get_uint_32(profile+128);
    png_uint_32 itag;
@@ -2184,7 +2219,7 @@
           * alignment.
           */
          (void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
-            "ICC profile tag start not a multiple of 4");
+             "ICC profile tag start not a multiple of 4");
       }
 
       /* This is a hard error; potentially it can cause read outside the
@@ -2192,7 +2227,7 @@
        */
       if (tag_start > profile_length || tag_length > profile_length - tag_start)
          return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
-            "ICC profile tag outside profile");
+             "ICC profile tag outside profile");
    }
 
    return 1; /* success, maybe with warnings */
@@ -2220,22 +2255,22 @@
     */
    /* adler32, crc32, MD5[4], intent, date, length, file-name */
    PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
-      PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
-      "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
+       PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
+       "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
 
    /* ICC sRGB v2 perceptual no black-compensation: */
    PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
-      PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
-      "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
+       PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
+       "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
 
    PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
-      PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
-      "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
+       PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
+       "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
 
    /* ICC sRGB v4 perceptual */
    PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
-      PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
-      "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
+       PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
+       "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
 
    /* The following profiles have no known MD5 checksum. If there is a match
     * on the (empty) MD5 the other fields are used to attempt a match and
@@ -2243,8 +2278,8 @@
     * which suggests that they were also made by Hewlett Packard.
     */
    PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
-      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
-      "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
+       PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
+       "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
 
    /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not
     * match the D50 PCS illuminant in the header (it is in fact the D65 values,
@@ -2254,17 +2289,17 @@
     * chromaticAdaptationTag.
     */
    PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
-      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
-      "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
+       PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
+       "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
 
    PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
-      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
-      "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
+       PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
+       "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
 };
 
 static int
 png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
-   png_const_bytep profile, uLong adler)
+    png_const_bytep profile, uLong adler)
 {
    /* The quick check is to verify just the MD5 signature and trust the
     * rest of the data.  Because the profile has already been verified for
@@ -2348,7 +2383,7 @@
                       * which is made irrelevant by this error.
                       */
                      png_chunk_report(png_ptr, "known incorrect sRGB profile",
-                        PNG_CHUNK_ERROR);
+                         PNG_CHUNK_ERROR);
                   }
 
                   /* Warn that this being done; this isn't even an error since
@@ -2358,8 +2393,8 @@
                   else if (png_sRGB_checks[i].have_md5 == 0)
                   {
                      png_chunk_report(png_ptr,
-                        "out-of-date sRGB profile with no signature",
-                        PNG_CHUNK_WARNING);
+                         "out-of-date sRGB profile with no signature",
+                         PNG_CHUNK_WARNING);
                   }
 
                   return 1+png_sRGB_checks[i].is_broken;
@@ -2382,38 +2417,36 @@
 
    return 0; /* no match */
 }
-#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
 
 void /* PRIVATE */
 png_icc_set_sRGB(png_const_structrp png_ptr,
-   png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
+    png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
 {
    /* Is this profile one of the known ICC sRGB profiles?  If it is, just set
     * the sRGB information.
     */
-#if PNG_sRGB_PROFILE_CHECKS >= 0
    if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
-#endif
       (void)png_colorspace_set_sRGB(png_ptr, colorspace,
          (int)/*already checked*/png_get_uint_32(profile+64));
 }
+#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
 #endif /* sRGB */
 
 int /* PRIVATE */
 png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
-   png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
-   int color_type)
+    png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
+    int color_type)
 {
    if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
       return 0;
 
-   if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
+   if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
        png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
-          color_type) != 0 &&
+           color_type) != 0 &&
        png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
-          profile) != 0)
+           profile) != 0)
    {
-#     ifdef PNG_sRGB_SUPPORTED
+#     if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
          /* If no sRGB support, don't try storing sRGB information */
          png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
 #     endif
@@ -2472,7 +2505,7 @@
          /* Check for an internal error. */
          if (r+g+b != 32768)
             png_error(png_ptr,
-               "internal error handling cHRM coefficients");
+                "internal error handling cHRM coefficients");
 
          else
          {
@@ -2498,7 +2531,7 @@
 static int /* PRIVATE */
 png_gt(size_t a, size_t b)
 {
-    return a > b;
+   return a > b;
 }
 #else
 #   define png_gt(a,b) ((a) > (b))
@@ -2506,9 +2539,9 @@
 
 void /* PRIVATE */
 png_check_IHDR(png_const_structrp png_ptr,
-   png_uint_32 width, png_uint_32 height, int bit_depth,
-   int color_type, int interlace_type, int compression_type,
-   int filter_type)
+    png_uint_32 width, png_uint_32 height, int bit_depth,
+    int color_type, int interlace_type, int compression_type,
+    int filter_type)
 {
    int error = 0;
 
@@ -2525,7 +2558,7 @@
       error = 1;
    }
 
-   if (png_gt(((width + 7) & (~7)),
+   if (png_gt(((width + 7) & (~7U)),
        ((PNG_SIZE_MAX
            - 48        /* big_row_buf hack */
            - 1)        /* filter byte */
@@ -2671,7 +2704,7 @@
 
 int /* PRIVATE */
 png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
-   png_size_tp whereami)
+    png_size_tp whereami)
 {
    int state = *statep;
    png_size_t i = *whereami;
@@ -2936,7 +2969,7 @@
              */
             if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
             {
-               czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */
+               czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */
                exp_b10 = 0;      /* Dot added below before first output. */
             }
             else
@@ -3114,11 +3147,11 @@
                if (exp_b10 < 0)
                {
                   *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
-                  uexp_b10 = -exp_b10;
+                  uexp_b10 = (unsigned int)(-exp_b10);
                }
 
                else
-                  uexp_b10 = exp_b10;
+                  uexp_b10 = (unsigned int)exp_b10;
 
                cdigits = 0;
 
@@ -3180,9 +3213,9 @@
 
       /* Avoid overflow here on the minimum integer. */
       if (fp < 0)
-         *ascii++ = 45, num = -fp;
+         *ascii++ = 45, num = (png_uint_32)(-fp);
       else
-         num = fp;
+         num = (png_uint_32)fp;
 
       if (num <= 0x80000000) /* else overflowed */
       {
@@ -3834,25 +3867,25 @@
 {
    if (value > 0 && value < 65535)
    {
-#     ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
-         /* The same (unsigned int)->(double) constraints apply here as above,
-          * however in this case the (unsigned int) to (int) conversion can
-          * overflow on an ANSI-C90 compliant system so the cast needs to ensure
-          * that this is not possible.
-          */
-         double r = floor(65535*pow((png_int_32)value/65535.,
-                     gamma_val*.00001)+.5);
-         return (png_uint_16)r;
-#     else
-         png_int_32 lg2 = png_log16bit(value);
-         png_fixed_point res;
-
-         if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
-            return png_exp16bit(res);
-
-         /* Overflow. */
-         value = 0;
-#     endif
+# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
+      /* The same (unsigned int)->(double) constraints apply here as above,
+       * however in this case the (unsigned int) to (int) conversion can
+       * overflow on an ANSI-C90 compliant system so the cast needs to ensure
+       * that this is not possible.
+       */
+      double r = floor(65535*pow((png_int_32)value/65535.,
+          gamma_val*.00001)+.5);
+      return (png_uint_16)r;
+# else
+      png_int_32 lg2 = png_log16bit(value);
+      png_fixed_point res;
+
+      if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
+         return png_exp16bit(res);
+
+      /* Overflow. */
+      value = 0;
+# endif
    }
 
    return (png_uint_16)value;
@@ -3891,7 +3924,7 @@
  */
 static void
 png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
-   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
 {
    /* Various values derived from 'shift': */
    PNG_CONST unsigned int num = 1U << (8U - shift);
@@ -3968,7 +4001,7 @@
  */
 static void
 png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
-   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
 {
    PNG_CONST unsigned int num = 1U << (8U - shift);
    PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
@@ -4036,7 +4069,7 @@
  */
 static void
 png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
-   PNG_CONST png_fixed_point gamma_val)
+    PNG_CONST png_fixed_point gamma_val)
 {
    unsigned int i;
    png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
@@ -4116,131 +4149,133 @@
 void /* PRIVATE */
 png_build_gamma_table(png_structrp png_ptr, int bit_depth)
 {
-  png_debug(1, "in png_build_gamma_table");
-
-  /* Remove any existing table; this copes with multiple calls to
-   * png_read_update_info.  The warning is because building the gamma tables
-   * multiple times is a performance hit - it's harmless but the ability to call
-   * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible
-   * to warn if the app introduces such a hit.
-   */
-  if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
-  {
-    png_warning(png_ptr, "gamma table being rebuilt");
-    png_destroy_gamma_table(png_ptr);
-  }
-
-  if (bit_depth <= 8)
-  {
-     png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
-         png_ptr->screen_gamma > 0 ?  png_reciprocal2(png_ptr->colorspace.gamma,
-         png_ptr->screen_gamma) : PNG_FP_1);
+   png_debug(1, "in png_build_gamma_table");
+
+   /* Remove any existing table; this copes with multiple calls to
+    * png_read_update_info. The warning is because building the gamma tables
+    * multiple times is a performance hit - it's harmless but the ability to
+    * call png_read_update_info() multiple times is new in 1.5.6 so it seems
+    * sensible to warn if the app introduces such a hit.
+    */
+   if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
+   {
+      png_warning(png_ptr, "gamma table being rebuilt");
+      png_destroy_gamma_table(png_ptr);
+   }
+
+   if (bit_depth <= 8)
+   {
+      png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
+          png_ptr->screen_gamma > 0 ?
+          png_reciprocal2(png_ptr->colorspace.gamma,
+          png_ptr->screen_gamma) : PNG_FP_1);
 
 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
    defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
    defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-     if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
-     {
-        png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
-            png_reciprocal(png_ptr->colorspace.gamma));
-
-        png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
-            png_ptr->screen_gamma > 0 ?  png_reciprocal(png_ptr->screen_gamma) :
-            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
-     }
+      if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
+      {
+         png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
+             png_reciprocal(png_ptr->colorspace.gamma));
+
+         png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
+             png_ptr->screen_gamma > 0 ?
+             png_reciprocal(png_ptr->screen_gamma) :
+             png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
+      }
 #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
-  }
+   }
 #ifdef PNG_16BIT_SUPPORTED
-  else
-  {
-     png_byte shift, sig_bit;
-
-     if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
-     {
-        sig_bit = png_ptr->sig_bit.red;
-
-        if (png_ptr->sig_bit.green > sig_bit)
-           sig_bit = png_ptr->sig_bit.green;
-
-        if (png_ptr->sig_bit.blue > sig_bit)
-           sig_bit = png_ptr->sig_bit.blue;
-     }
-     else
-        sig_bit = png_ptr->sig_bit.gray;
-
-     /* 16-bit gamma code uses this equation:
-      *
-      *   ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
-      *
-      * Where 'iv' is the input color value and 'ov' is the output value -
-      * pow(iv, gamma).
-      *
-      * Thus the gamma table consists of up to 256 256-entry tables.  The table
-      * is selected by the (8-gamma_shift) most significant of the low 8 bits of
-      * the color value then indexed by the upper 8 bits:
-      *
-      *   table[low bits][high 8 bits]
-      *
-      * So the table 'n' corresponds to all those 'iv' of:
-      *
-      *   <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
-      *
-      */
-     if (sig_bit > 0 && sig_bit < 16U)
-        /* shift == insignificant bits */
-        shift = (png_byte)((16U - sig_bit) & 0xff);
-
-     else
-        shift = 0; /* keep all 16 bits */
-
-     if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
-     {
-        /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
-         * the significant bits in the *input* when the output will
-         * eventually be 8 bits.  By default it is 11.
-         */
-        if (shift < (16U - PNG_MAX_GAMMA_8))
-           shift = (16U - PNG_MAX_GAMMA_8);
-     }
-
-     if (shift > 8U)
-        shift = 8U; /* Guarantees at least one table! */
-
-     png_ptr->gamma_shift = shift;
-
-     /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
-      * PNG_COMPOSE).  This effectively smashed the background calculation for
-      * 16-bit output because the 8-bit table assumes the result will be reduced
-      * to 8 bits.
-      */
-     if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
-         png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
-         png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
-         png_ptr->screen_gamma) : PNG_FP_1);
-
-     else
-         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
-         png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
-         png_ptr->screen_gamma) : PNG_FP_1);
+   else
+   {
+      png_byte shift, sig_bit;
+
+      if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
+      {
+         sig_bit = png_ptr->sig_bit.red;
+
+         if (png_ptr->sig_bit.green > sig_bit)
+            sig_bit = png_ptr->sig_bit.green;
+
+         if (png_ptr->sig_bit.blue > sig_bit)
+            sig_bit = png_ptr->sig_bit.blue;
+      }
+      else
+         sig_bit = png_ptr->sig_bit.gray;
+
+      /* 16-bit gamma code uses this equation:
+       *
+       *   ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
+       *
+       * Where 'iv' is the input color value and 'ov' is the output value -
+       * pow(iv, gamma).
+       *
+       * Thus the gamma table consists of up to 256 256-entry tables.  The table
+       * is selected by the (8-gamma_shift) most significant of the low 8 bits
+       * of the color value then indexed by the upper 8 bits:
+       *
+       *   table[low bits][high 8 bits]
+       *
+       * So the table 'n' corresponds to all those 'iv' of:
+       *
+       *   <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
+       *
+       */
+      if (sig_bit > 0 && sig_bit < 16U)
+         /* shift == insignificant bits */
+         shift = (png_byte)((16U - sig_bit) & 0xff);
+
+      else
+         shift = 0; /* keep all 16 bits */
+
+      if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
+      {
+         /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
+          * the significant bits in the *input* when the output will
+          * eventually be 8 bits.  By default it is 11.
+          */
+         if (shift < (16U - PNG_MAX_GAMMA_8))
+            shift = (16U - PNG_MAX_GAMMA_8);
+      }
+
+      if (shift > 8U)
+         shift = 8U; /* Guarantees at least one table! */
+
+      png_ptr->gamma_shift = shift;
+
+      /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
+       * PNG_COMPOSE).  This effectively smashed the background calculation for
+       * 16-bit output because the 8-bit table assumes the result will be
+       * reduced to 8 bits.
+       */
+      if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
+          png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
+          png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
+          png_ptr->screen_gamma) : PNG_FP_1);
+
+      else
+          png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
+          png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
+          png_ptr->screen_gamma) : PNG_FP_1);
 
 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
    defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
    defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-     if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
-     {
-        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
-            png_reciprocal(png_ptr->colorspace.gamma));
-
-        /* Notice that the '16 from 1' table should be full precision, however
-         * the lookup on this table still uses gamma_shift, so it can't be.
-         * TODO: fix this.
-         */
-        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,
-            png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
-            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
-     }
+      if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
+      {
+         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
+             png_reciprocal(png_ptr->colorspace.gamma));
+
+         /* Notice that the '16 from 1' table should be full precision, however
+          * the lookup on this table still uses gamma_shift, so it can't be.
+          * TODO: fix this.
+          */
+         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,
+             png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
+             png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
+      }
 #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
-  }
+   }
 #endif /* 16BIT */
 }
 #endif /* READ_GAMMA */
@@ -4253,11 +4288,11 @@
    if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
       (option & 1) == 0)
    {
-      int mask = 3 << option;
-      int setting = (2 + (onoff != 0)) << option;
-      int current = png_ptr->options;
-
-      png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
+      png_uint_32 mask = 3 << option;
+      png_uint_32 setting = (2 + (onoff != 0)) << option;
+      png_uint_32 current = png_ptr->options;
+
+      png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff);
 
       return (current & mask) >> option;
    }
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h	Wed Jul 05 22:46:04 2017 +0200
@@ -29,9 +29,9 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.23, June 9, 2016
+ * libpng version 1.6.28, January 5, 2017
  *
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -40,7 +40,7 @@
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
+ *   libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017:
  *     Glenn Randers-Pehrson.
  *   See also "Contributing Authors", below.
  */
@@ -53,12 +53,8 @@
  *
  * This code is released under the libpng license.
  *
- * Some files in the "contrib" directory and some configure-generated
- * files that are distributed with libpng have other copyright owners and
- * are released under other open source licenses.
- *
- * libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
- * Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
+ * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
+ * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
  * derived from libpng-1.0.6, and are distributed according to the same
  * disclaimer and license as libpng-1.0.6 with the following individuals
  * added to the list of Contributing Authors:
@@ -69,6 +65,7 @@
  *    Cosmin Truta
  *    Gilles Vollant
  *    James Yu
+ *    Mandar Sahastrabuddhe
  *
  * and with the following additions to the disclaimer:
  *
@@ -79,10 +76,10 @@
  *    risk of satisfactory quality, performance, accuracy, and effort is with
  *    the user.
  *
- * Some files in the "contrib" directory have other copyright owners and
+ * Some files in the "contrib" directory and some configure-generated
+ * files that are distributed with libpng have other copyright owners and
  * are released under other open source licenses.
  *
- *
  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  * libpng-0.96, and are distributed according to the same disclaimer and
@@ -93,9 +90,6 @@
  *    Glenn Randers-Pehrson
  *    Willem van Schaik
  *
- * Some files in the "scripts" directory have different copyright owners
- * but are also released under this license.
- *
  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  * and are distributed according to the same disclaimer and license as
@@ -241,11 +235,11 @@
  *    ...
  *    1.0.19                  10    10019  10.so.0.19[.0]
  *    ...
- *    1.2.56                  13    10256  12.so.0.56[.0]
+ *    1.2.57                  13    10257  12.so.0.57[.0]
  *    ...
- *    1.5.27                  15    10527  15.so.15.27[.0]
+ *    1.5.28                  15    10527  15.so.15.28[.0]
  *    ...
- *    1.6.23                  16    10623  16.so.16.23[.0]
+ *    1.6.28                  16    10628  16.so.16.28[.0]
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -273,13 +267,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    June 9, 2016
+ *    January 5, 2017
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.6.23 are Y2K compliant.  It is my belief that
+ *    upward through 1.6.28 are Y2K compliant.  It is my belief that
  *    earlier versions were also Y2K compliant.
  *
  *    Libpng only has two year fields.  One is a 2-byte unsigned integer
@@ -341,9 +335,8 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.23"
-#define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.6.23 - June 9, 2016\n"
+#define PNG_LIBPNG_VER_STRING "1.6.28"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
 
 #define PNG_LIBPNG_VER_SONUM   16
 #define PNG_LIBPNG_VER_DLLNUM  16
@@ -351,7 +344,7 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   6
-#define PNG_LIBPNG_VER_RELEASE 23
+#define PNG_LIBPNG_VER_RELEASE 28
 
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -382,20 +375,20 @@
  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
  */
-#define PNG_LIBPNG_VER 10623 /* 1.6.23 */
+#define PNG_LIBPNG_VER 10628 /* 1.6.28 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
  */
 #ifndef PNGLCONF_H
-    /* If pnglibconf.h is missing, you can
-     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
-     */
+/* If pnglibconf.h is missing, you can
+ * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
+ */
 #   include "pnglibconf.h"
 #endif
 
 #ifndef PNG_VERSION_INFO_ONLY
-   /* Machine specific configuration. */
+/* Machine specific configuration. */
 #  include "pngconf.h"
 #endif
 
@@ -492,7 +485,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_6_23;
+typedef char* png_libpng_version_1_6_28;
 
 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  *
@@ -685,17 +678,17 @@
  */
 typedef struct png_unknown_chunk_t
 {
-    png_byte name[5]; /* Textual chunk name with '\0' terminator */
-    png_byte *data;   /* Data, should not be modified on read! */
-    png_size_t size;
-
-    /* On write 'location' must be set using the flag values listed below.
-     * Notice that on read it is set by libpng however the values stored have
-     * more bits set than are listed below.  Always treat the value as a
-     * bitmask.  On write set only one bit - setting multiple bits may cause the
-     * chunk to be written in multiple places.
-     */
-    png_byte location; /* mode of operation at read time */
+   png_byte name[5]; /* Textual chunk name with '\0' terminator */
+   png_byte *data;   /* Data, should not be modified on read! */
+   png_size_t size;
+
+   /* On write 'location' must be set using the flag values listed below.
+    * Notice that on read it is set by libpng however the values stored have
+    * more bits set than are listed below.  Always treat the value as a
+    * bitmask.  On write set only one bit - setting multiple bits may cause the
+    * chunk to be written in multiple places.
+    */
+   png_byte location; /* mode of operation at read time */
 }
 png_unknown_chunk;
 
@@ -2328,8 +2321,10 @@
  *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
  *    be processed by libpng.
  */
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
 PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
     int keep, png_const_bytep chunk_list, int num_chunks));
+#endif /* HANDLE_AS_UNKNOWN */
 
 /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
  * the result is therefore true (non-zero) if special handling is required,
@@ -2337,7 +2332,7 @@
  */
 PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
     png_const_bytep chunk_name));
-#endif
+#endif /* SET_UNKNOWN_CHUNKS */
 
 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
@@ -2558,33 +2553,37 @@
 
  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
 
-#  define png_composite(composite, fg, alpha, bg)         \
-     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
-           * (png_uint_16)(alpha)                         \
-           + (png_uint_16)(bg)*(png_uint_16)(255          \
-           - (png_uint_16)(alpha)) + 128);                \
-       (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
-
-#  define png_composite_16(composite, fg, alpha, bg)       \
-     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
-           * (png_uint_32)(alpha)                          \
-           + (png_uint_32)(bg)*(65535                      \
-           - (png_uint_32)(alpha)) + 32768);               \
-       (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
+#  define png_composite(composite, fg, alpha, bg)        \
+   {                                                     \
+      png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
+          * (png_uint_16)(alpha)                         \
+          + (png_uint_16)(bg)*(png_uint_16)(255          \
+          - (png_uint_16)(alpha)) + 128);                \
+      (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
+   }
+
+#  define png_composite_16(composite, fg, alpha, bg)     \
+   {                                                     \
+      png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
+          * (png_uint_32)(alpha)                         \
+          + (png_uint_32)(bg)*(65535                     \
+          - (png_uint_32)(alpha)) + 32768);              \
+      (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
+   }
 
 #else  /* Standard method using integer division */
 
-#  define png_composite(composite, fg, alpha, bg)                        \
-     (composite) =                                                       \
-         (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
-         (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
-         127) / 255))
-
-#  define png_composite_16(composite, fg, alpha, bg)                         \
-     (composite) =                                                           \
-         (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
-         (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +     \
-         32767) / 65535))
+#  define png_composite(composite, fg, alpha, bg)                      \
+   (composite) =                                                       \
+       (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
+       (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
+       127) / 255))
+
+#  define png_composite_16(composite, fg, alpha, bg)                       \
+   (composite) =                                                           \
+       (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
+       (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +     \
+       32767) / 65535))
 #endif /* READ_COMPOSITE_NODIV */
 
 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
@@ -2620,38 +2619,38 @@
  * format for negative values, which is almost certainly true.
  */
 #  define PNG_get_uint_32(buf) \
-     (((png_uint_32)(*(buf)) << 24) + \
-      ((png_uint_32)(*((buf) + 1)) << 16) + \
-      ((png_uint_32)(*((buf) + 2)) << 8) + \
-      ((png_uint_32)(*((buf) + 3))))
+   (((png_uint_32)(*(buf)) << 24) + \
+    ((png_uint_32)(*((buf) + 1)) << 16) + \
+    ((png_uint_32)(*((buf) + 2)) << 8) + \
+    ((png_uint_32)(*((buf) + 3))))
 
    /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
     * function) incorrectly returned a value of type png_uint_32.
     */
 #  define PNG_get_uint_16(buf) \
-     ((png_uint_16) \
-      (((unsigned int)(*(buf)) << 8) + \
-       ((unsigned int)(*((buf) + 1)))))
+   ((png_uint_16) \
+    (((unsigned int)(*(buf)) << 8) + \
+    ((unsigned int)(*((buf) + 1)))))
 
 #  define PNG_get_int_32(buf) \
-     ((png_int_32)((*(buf) & 0x80) \
-      ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
-      : (png_int_32)png_get_uint_32(buf)))
-
-   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
-    * but defining a macro name prefixed with PNG_PREFIX.
-    */
+   ((png_int_32)((*(buf) & 0x80) \
+    ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
+    : (png_int_32)png_get_uint_32(buf)))
+
+/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
+ * but defining a macro name prefixed with PNG_PREFIX.
+ */
 #  ifndef PNG_PREFIX
-#     define png_get_uint_32(buf) PNG_get_uint_32(buf)
-#     define png_get_uint_16(buf) PNG_get_uint_16(buf)
-#     define png_get_int_32(buf)  PNG_get_int_32(buf)
+#    define png_get_uint_32(buf) PNG_get_uint_32(buf)
+#    define png_get_uint_16(buf) PNG_get_uint_16(buf)
+#    define png_get_int_32(buf)  PNG_get_int_32(buf)
 #  endif
 #else
 #  ifdef PNG_PREFIX
-      /* No macros; revert to the (redefined) function */
-#     define PNG_get_uint_32 (png_get_uint_32)
-#     define PNG_get_uint_16 (png_get_uint_16)
-#     define PNG_get_int_32  (png_get_int_32)
+   /* No macros; revert to the (redefined) function */
+#    define PNG_get_uint_32 (png_get_uint_32)
+#    define PNG_get_uint_16 (png_get_uint_16)
+#    define PNG_get_int_32  (png_get_int_32)
 #  endif
 #endif
 
@@ -3199,9 +3198,9 @@
 #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
    ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
     (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
-     12U+3U*(image).colormap_entries/*PLTE data*/+\
-     (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
-      12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
+    12U+3U*(image).colormap_entries/*PLTE data*/+\
+    (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
+    12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
     12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
    /* A helper for the following macro; if your compiler cannot handle the
     * following macro use this one with the result of
@@ -3249,7 +3248,11 @@
 #endif
 #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
 #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
-#define PNG_OPTION_NEXT  6 /* Next option - numbers must be even */
+#ifdef PNG_MIPS_MSA_API_SUPPORTED
+#  define PNG_MIPS_MSA   6 /* HARDWARE: MIPS Msa SIMD instructions supported */
+#endif
+#define PNG_IGNORE_ADLER32 8
+#define PNG_OPTION_NEXT  10 /* Next option - numbers must be even */
 
 /* Return values: NOTE: there are four values and 'off' is *not* zero */
 #define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h	Wed Jul 05 22:46:04 2017 +0200
@@ -29,9 +29,9 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.23, June 9, 2016
+ * libpng version 1.6.28, January 5, 2017
  *
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -216,27 +216,27 @@
    * compatible with GCC or Visual C because of different calling conventions.
    */
 #  if PNG_API_RULE == 2
-    /* If this line results in an error, either because __watcall is not
-     * understood or because of a redefine just below you cannot use *this*
-     * build of the library with the compiler you are using.  *This* build was
-     * build using Watcom and applications must also be built using Watcom!
-     */
+   /* If this line results in an error, either because __watcall is not
+    * understood or because of a redefine just below you cannot use *this*
+    * build of the library with the compiler you are using.  *This* build was
+    * build using Watcom and applications must also be built using Watcom!
+    */
 #    define PNGCAPI __watcall
 #  endif
 
 #  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
 #    define PNGCAPI __cdecl
 #    if PNG_API_RULE == 1
-       /* If this line results in an error __stdcall is not understood and
-        * PNG_API_RULE should not have been set to '1'.
-        */
+   /* If this line results in an error __stdcall is not understood and
+    * PNG_API_RULE should not have been set to '1'.
+    */
 #      define PNGAPI __stdcall
 #    endif
 #  else
-    /* An older compiler, or one not detected (erroneously) above,
-     * if necessary override on the command line to get the correct
-     * variants for the compiler.
-     */
+   /* An older compiler, or one not detected (erroneously) above,
+    * if necessary override on the command line to get the correct
+    * variants for the compiler.
+    */
 #    ifndef PNGCAPI
 #      define PNGCAPI _cdecl
 #    endif
@@ -253,10 +253,10 @@
 
 #  if (defined(_MSC_VER) && _MSC_VER < 800) ||\
       (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
-    /* older Borland and MSC
-     * compilers used '__export' and required this to be after
-     * the type.
-     */
+   /* older Borland and MSC
+    * compilers used '__export' and required this to be after
+    * the type.
+    */
 #    ifndef PNG_EXPORT_TYPE
 #      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
 #    endif
@@ -272,9 +272,9 @@
 #  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
 #    define PNGAPI _System
 #  else /* !Windows/x86 && !OS/2 */
-    /* Use the defaults, or define PNG*API on the command line (but
-     * this will have to be done for every compile!)
-     */
+   /* Use the defaults, or define PNG*API on the command line (but
+    * this will have to be done for every compile!)
+    */
 #  endif /* other system, !OS/2 */
 #endif /* !Windows/x86 */
 
@@ -295,7 +295,7 @@
  */
 #ifndef PNG_IMPEXP
 #  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
-     /* This forces use of a DLL, disallowing static linking */
+   /* This forces use of a DLL, disallowing static linking */
 #    define PNG_IMPEXP PNG_DLL_IMPORT
 #  endif
 
@@ -368,7 +368,7 @@
    * less efficient code.
    */
 #  if defined(__clang__) && defined(__has_attribute)
-     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
+   /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
 #    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
 #      define PNG_USE_RESULT __attribute__((__warn_unused_result__))
 #    endif
@@ -535,9 +535,9 @@
 #  error "libpng requires a signed 32-bit (or more) type"
 #endif
 
-#if UINT_MAX > 4294967294
+#if UINT_MAX > 4294967294U
    typedef unsigned int png_uint_32;
-#elif ULONG_MAX > 4294967294
+#elif ULONG_MAX > 4294967294U
    typedef unsigned long int png_uint_32;
 #else
 #  error "libpng requires an unsigned 32-bit (or more) type"
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -54,7 +54,7 @@
 #ifdef PNG_WARNINGS_SUPPORTED
 static void /* PRIVATE */
 png_default_warning PNGARG((png_const_structrp png_ptr,
-   png_const_charp warning_message));
+    png_const_charp warning_message));
 #endif /* WARNINGS */
 
 /* This function is called whenever there is a fatal error.  This function
@@ -65,7 +65,7 @@
 #ifdef PNG_ERROR_TEXT_SUPPORTED
 PNG_FUNCTION(void,PNGAPI
 png_error,(png_const_structrp png_ptr, png_const_charp error_message),
-   PNG_NORETURN)
+    PNG_NORETURN)
 {
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
    char msg[16];
@@ -93,18 +93,18 @@
 
             else
                error_message += offset;
-      }
+         }
 
-      else
-      {
-         if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
+         else
          {
-            msg[0] = '0';
-            msg[1] = '\0';
-            error_message = msg;
+            if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
+            {
+               msg[0] = '0';
+               msg[1] = '\0';
+               error_message = msg;
+            }
          }
-       }
-     }
+      }
    }
 #endif
    if (png_ptr != NULL && png_ptr->error_fn != NULL)
@@ -138,7 +138,7 @@
  */
 size_t
 png_safecat(png_charp buffer, size_t bufsize, size_t pos,
-   png_const_charp string)
+    png_const_charp string)
 {
    if (buffer != NULL && pos < bufsize)
    {
@@ -159,7 +159,7 @@
  */
 png_charp
 png_format_number(png_const_charp start, png_charp end, int format,
-   png_alloc_size_t number)
+    png_alloc_size_t number)
 {
    int count = 0;    /* number of digits output */
    int mincount = 1; /* minimum number required */
@@ -261,7 +261,7 @@
    }
    if (png_ptr != NULL && png_ptr->warning_fn != NULL)
       (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
-         warning_message + offset);
+          warning_message + offset);
    else
       png_default_warning(png_ptr, warning_message + offset);
 }
@@ -273,7 +273,7 @@
  */
 void
 png_warning_parameter(png_warning_parameters p, int number,
-   png_const_charp string)
+    png_const_charp string)
 {
    if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
       (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
@@ -281,7 +281,7 @@
 
 void
 png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
-   png_alloc_size_t value)
+    png_alloc_size_t value)
 {
    char buffer[PNG_NUMBER_BUFFER_SIZE];
    png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
@@ -289,7 +289,7 @@
 
 void
 png_warning_parameter_signed(png_warning_parameters p, int number, int format,
-   png_int_32 value)
+    png_int_32 value)
 {
    png_alloc_size_t u;
    png_charp str;
@@ -310,7 +310,7 @@
 
 void
 png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
-   png_const_charp message)
+    png_const_charp message)
 {
    /* The internal buffer is just 192 bytes - enough for all our messages,
     * overflow doesn't happen because this code checks!  If someone figures
@@ -419,10 +419,10 @@
 void /* PRIVATE */
 png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
 {
-  if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
-     png_warning(png_ptr, error_message);
-  else
-     png_error(png_ptr, error_message);
+   if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
+      png_warning(png_ptr, error_message);
+   else
+      png_error(png_ptr, error_message);
 
 #  ifndef PNG_ERROR_TEXT_SUPPORTED
       PNG_UNUSED(error_message)
@@ -432,10 +432,10 @@
 void /* PRIVATE */
 png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
 {
-  if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
-     png_warning(png_ptr, error_message);
-  else
-     png_error(png_ptr, error_message);
+   if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
+      png_warning(png_ptr, error_message);
+   else
+      png_error(png_ptr, error_message);
 
 #  ifndef PNG_ERROR_TEXT_SUPPORTED
       PNG_UNUSED(error_message)
@@ -506,7 +506,7 @@
 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
 PNG_FUNCTION(void,PNGAPI
 png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
-   PNG_NORETURN)
+    PNG_NORETURN)
 {
    char msg[18+PNG_MAX_ERROR_TEXT];
    if (png_ptr == NULL)
@@ -601,7 +601,7 @@
 {
 #  define fixed_message "fixed point overflow in "
 #  define fixed_message_ln ((sizeof fixed_message)-1)
-   int  iin;
+   unsigned int  iin;
    char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
    memcpy(msg, fixed_message, fixed_message_ln);
    iin = 0;
@@ -648,7 +648,7 @@
       else
       {
          png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
-            png_malloc_warn(png_ptr, jmp_buf_size));
+             png_malloc_warn(png_ptr, jmp_buf_size));
 
          if (png_ptr->jmp_buf_ptr == NULL)
             return NULL; /* new NULL return on OOM */
@@ -737,7 +737,7 @@
  */
 static PNG_FUNCTION(void /* PRIVATE */,
 png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
-   PNG_NORETURN)
+    PNG_NORETURN)
 {
 #ifdef PNG_CONSOLE_IO_SUPPORTED
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
@@ -911,7 +911,7 @@
     */
 PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
 png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
-   PNG_NORETURN)
+    PNG_NORETURN)
 {
    const png_const_structrp png_ptr = png_nonconst_ptr;
    png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
@@ -934,7 +934,7 @@
       /* Missing longjmp buffer, the following is to help debugging: */
       {
          size_t pos = png_safecat(image->message, (sizeof image->message), 0,
-            "bad longjmp: ");
+             "bad longjmp: ");
          png_safecat(image->message, (sizeof image->message), pos,
              error_message);
       }
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c	Wed Jul 05 22:46:04 2017 +0200
@@ -28,9 +28,9 @@
  * License version 2 only, as published by the Free Software Foundation.
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.6.17 [March 26, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -366,7 +366,7 @@
    png_fixed_point result;
    if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
        5000) != 0)
-      return result;
+      return (png_uint_32)result;
 
    /* Overflow. */
    return 0;
@@ -514,7 +514,7 @@
 #ifdef PNG_bKGD_SUPPORTED
 png_uint_32 PNGAPI
 png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
-   png_color_16p *background)
+    png_color_16p *background)
 {
    if (png_ptr != NULL && info_ptr != NULL &&
        (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
@@ -554,28 +554,28 @@
 
       if (white_x != NULL)
          *white_x = png_float(png_ptr,
-            info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
+             info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
       if (white_y != NULL)
          *white_y = png_float(png_ptr,
-            info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
+             info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
       if (red_x != NULL)
          *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
-            "cHRM red X");
+             "cHRM red X");
       if (red_y != NULL)
          *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
-            "cHRM red Y");
+             "cHRM red Y");
       if (green_x != NULL)
          *green_x = png_float(png_ptr,
-            info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
+             info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
       if (green_y != NULL)
          *green_y = png_float(png_ptr,
-            info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
+             info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
       if (blue_x != NULL)
          *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
-            "cHRM blue X");
+             "cHRM blue X");
       if (blue_y != NULL)
          *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
-            "cHRM blue Y");
+             "cHRM blue Y");
       return (PNG_INFO_cHRM);
    }
 
@@ -584,42 +584,42 @@
 
 png_uint_32 PNGAPI
 png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
-   double *red_X, double *red_Y, double *red_Z, double *green_X,
-   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
-   double *blue_Z)
+    double *red_X, double *red_Y, double *red_Z, double *green_X,
+    double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
+    double *blue_Z)
 {
    if (png_ptr != NULL && info_ptr != NULL &&
-      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
+       (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
    {
       png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
 
       if (red_X != NULL)
          *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
-            "cHRM red X");
+             "cHRM red X");
       if (red_Y != NULL)
          *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
-            "cHRM red Y");
+             "cHRM red Y");
       if (red_Z != NULL)
          *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
-            "cHRM red Z");
+             "cHRM red Z");
       if (green_X != NULL)
          *green_X = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
+             info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
       if (green_Y != NULL)
          *green_Y = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
+             info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
       if (green_Z != NULL)
          *green_Z = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
+             info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
       if (blue_X != NULL)
          *blue_X = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
+             info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
       if (blue_Y != NULL)
          *blue_Y = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
+             info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
       if (blue_Z != NULL)
          *blue_Z = png_float(png_ptr,
-            info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
+             info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
       return (PNG_INFO_cHRM);
    }
 
@@ -709,8 +709,8 @@
    png_debug1(1, "in %s retrieval function", "gAMA");
 
    if (png_ptr != NULL && info_ptr != NULL &&
-      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
-      file_gamma != NULL)
+       (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
+       file_gamma != NULL)
    {
       *file_gamma = info_ptr->colorspace.gamma;
       return (PNG_INFO_gAMA);
@@ -732,7 +732,7 @@
       file_gamma != NULL)
    {
       *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
-         "png_get_gAMA");
+          "png_get_gAMA");
       return (PNG_INFO_gAMA);
    }
 
@@ -929,7 +929,7 @@
        */
       *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
       *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
-         "sCAL height");
+          "sCAL height");
       return (PNG_INFO_sCAL);
    }
 
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h	Wed Jul 05 22:46:04 2017 +0200
@@ -33,7 +33,7 @@
  * file and, per its terms, should not be removed:
  */
 
-/* libpng version 1.6.23, June 9, 2016 */
+/* libpng version 1.6.28, January 5, 2017 */
 
 /* Copyright (c) 1998-2016 Glenn Randers-Pehrson */
 
@@ -83,7 +83,7 @@
 #define PNG_READ_BGR_SUPPORTED
 #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
 #define PNG_READ_COMPOSITE_NODIV_SUPPORTED
-#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
+/*#undef PNG_READ_COMPRESSED_TEXT_SUPPORTED*/
 #define PNG_READ_EXPAND_16_SUPPORTED
 #define PNG_READ_EXPAND_SUPPORTED
 #define PNG_READ_FILLER_SUPPORTED
@@ -115,8 +115,8 @@
 #define PNG_READ_cHRM_SUPPORTED
 #define PNG_READ_gAMA_SUPPORTED
 #define PNG_READ_hIST_SUPPORTED
-#define PNG_READ_iCCP_SUPPORTED
-#define PNG_READ_iTXt_SUPPORTED
+/*#undef PNG_READ_iCCP_SUPPORTED*/
+/*#undef PNG_READ_iTXt_SUPPORTED*/
 #define PNG_READ_oFFs_SUPPORTED
 #define PNG_READ_pCAL_SUPPORTED
 #define PNG_READ_pHYs_SUPPORTED
@@ -127,7 +127,7 @@
 #define PNG_READ_tEXt_SUPPORTED
 #define PNG_READ_tIME_SUPPORTED
 #define PNG_READ_tRNS_SUPPORTED
-#define PNG_READ_zTXt_SUPPORTED
+/*#undef PNG_READ_zTXt_SUPPORTED*/
 /*#undef PNG_SAVE_INT_32_SUPPORTED*/
 #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
 #define PNG_SEQUENTIAL_READ_SUPPORTED
@@ -231,10 +231,10 @@
 #define PNG_QUANTIZE_RED_BITS 5
 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
 #define PNG_TEXT_Z_DEFAULT_STRATEGY 0
-#define PNG_USER_CHUNK_CACHE_MAX 0
-#define PNG_USER_CHUNK_MALLOC_MAX 0
-#define PNG_USER_HEIGHT_MAX 1000000
-#define PNG_USER_WIDTH_MAX 1000000
+#define PNG_USER_CHUNK_CACHE_MAX 1000
+#define PNG_USER_CHUNK_MALLOC_MAX 8000000
+#define PNG_USER_HEIGHT_MAX 8000
+#define PNG_USER_WIDTH_MAX 8000
 #define PNG_ZBUF_SIZE 8192
 #define PNG_ZLIB_VERNUM 0
 #define PNG_Z_DEFAULT_COMPRESSION (-1)
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -94,7 +94,7 @@
  */
 PNG_FUNCTION(png_voidp /* PRIVATE */,
 png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
-   PNG_ALLOCATED)
+    PNG_ALLOCATED)
 {
    /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
     * allocators have also been removed in 1.6.0, so any 16-bit system now has
@@ -135,9 +135,9 @@
  */
 static png_voidp
 png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
-   size_t element_size)
+    size_t element_size)
 {
-   png_alloc_size_t req = nelements; /* known to be > 0 */
+   png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
 
    if (req <= PNG_SIZE_MAX/element_size)
       return png_malloc_base(png_ptr, req * element_size);
@@ -148,7 +148,7 @@
 
 PNG_FUNCTION(png_voidp /* PRIVATE */,
 png_malloc_array,(png_const_structrp png_ptr, int nelements,
-   size_t element_size),PNG_ALLOCATED)
+    size_t element_size),PNG_ALLOCATED)
 {
    if (nelements <= 0 || element_size == 0)
       png_error(png_ptr, "internal error: array alloc");
@@ -158,7 +158,7 @@
 
 PNG_FUNCTION(png_voidp /* PRIVATE */,
 png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
-   int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
+    int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
 {
    /* These are internal errors: */
    if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
@@ -171,7 +171,7 @@
    if (add_elements <= INT_MAX - old_elements)
    {
       png_voidp new_array = png_malloc_array_checked(png_ptr,
-         old_elements+add_elements, element_size);
+          old_elements+add_elements, element_size);
 
       if (new_array != NULL)
       {
@@ -182,7 +182,7 @@
             memcpy(new_array, old_array, element_size*(unsigned)old_elements);
 
          memset((char*)new_array + element_size*(unsigned)old_elements, 0,
-            element_size*(unsigned)add_elements);
+             element_size*(unsigned)add_elements);
 
          return new_array;
       }
@@ -215,7 +215,7 @@
 #ifdef PNG_USER_MEM_SUPPORTED
 PNG_FUNCTION(png_voidp,PNGAPI
 png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
-   PNG_ALLOCATED PNG_DEPRECATED)
+    PNG_ALLOCATED PNG_DEPRECATED)
 {
    png_voidp ret;
 
@@ -238,7 +238,7 @@
  */
 PNG_FUNCTION(png_voidp,PNGAPI
 png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
-   PNG_ALLOCATED)
+    PNG_ALLOCATED)
 {
    if (png_ptr != NULL)
    {
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,7 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.23 [June 9, 2016]
+ * Last changed in libpng 1.6.24 [August 4, 2016]
  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -105,11 +105,11 @@
 png_uint_32 PNGAPI
 png_process_data_skip(png_structrp png_ptr)
 {
-  /* TODO: Deprecate and remove this API.
-   * Somewhere the implementation of this seems to have been lost,
-   * or abandoned.  It was only to support some internal back-door access
-   * to png_struct) in libpng-1.4.x.
-   */
+/* TODO: Deprecate and remove this API.
+ * Somewhere the implementation of this seems to have been lost,
+ * or abandoned.  It was only to support some internal back-door access
+ * to png_struct) in libpng-1.4.x.
+ */
    png_app_warning(png_ptr,
 "png_process_data_skip is not implemented in any current version of libpng");
    return 0;
@@ -438,7 +438,7 @@
    {
       PNG_PUSH_SAVE_BUFFER_IF_FULL
       png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
-         PNG_HANDLE_CHUNK_AS_DEFAULT);
+          PNG_HANDLE_CHUNK_AS_DEFAULT);
    }
 
    png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
@@ -549,7 +549,7 @@
 
 void /* PRIVATE */
 png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
-   png_size_t buffer_length)
+    png_size_t buffer_length)
 {
    png_ptr->current_buffer = buffer;
    png_ptr->current_buffer_size = buffer_length;
@@ -652,7 +652,7 @@
 
 void /* PRIVATE */
 png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
-   png_size_t buffer_length)
+    png_size_t buffer_length)
 {
    /* The caller checks for a non-zero buffer length. */
    if (!(buffer_length > 0) || buffer == NULL)
@@ -712,7 +712,12 @@
             png_warning(png_ptr, "Truncated compressed data in IDAT");
 
          else
-            png_error(png_ptr, "Decompression error in IDAT");
+         {
+            if (ret == Z_DATA_ERROR)
+               png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch");
+            else
+               png_error(png_ptr, "Decompression error in IDAT");
+         }
 
          /* Skip the check on unprocessed input */
          return;
@@ -810,7 +815,7 @@
    {
       if (png_ptr->pass < 6)
          png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
-            png_ptr->transformations);
+             png_ptr->transformations);
 
       switch (png_ptr->pass)
       {
@@ -1072,7 +1077,7 @@
 {
    if (png_ptr->row_fn != NULL)
       (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
-         (int)png_ptr->pass);
+          (int)png_ptr->pass);
 }
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,7 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.22 [May 26, 2016]
+ * Last changed in libpng 1.6.26 [October 20, 2016]
  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -210,6 +210,35 @@
 #  endif
 #endif /* PNG_ARM_NEON_OPT > 0 */
 
+#ifndef PNG_MIPS_MSA_OPT
+#  if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+#     define PNG_MIPS_MSA_OPT 2
+#  else
+#     define PNG_MIPS_MSA_OPT 0
+#  endif
+#endif
+
+#if PNG_MIPS_MSA_OPT > 0
+#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
+#  ifndef PNG_MIPS_MSA_IMPLEMENTATION
+#     if defined(__mips_msa)
+#        if defined(__clang__)
+#        elif defined(__GNUC__)
+#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
+#              define PNG_MIPS_MSA_IMPLEMENTATION 2
+#           endif /* no GNUC support */
+#        endif /* __GNUC__ */
+#     else /* !defined __mips_msa */
+#        define PNG_MIPS_MSA_IMPLEMENTATION 2
+#     endif /* __mips_msa */
+#  endif /* !PNG_MIPS_MSA_IMPLEMENTATION */
+
+#  ifndef PNG_MIPS_MSA_IMPLEMENTATION
+#     define PNG_MIPS_MSA_IMPLEMENTATION 1
+#  endif
+#endif /* PNG_MIPS_MSA_OPT > 0 */
+
+
 /* Is this a build of a DLL where compilation of the object modules requires
  * different preprocessor settings to those required for a simple library?  If
  * so PNG_BUILD_DLL must be set.
@@ -448,10 +477,10 @@
 
 #  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
     defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
-     /* We need to check that <math.h> hasn't already been included earlier
-      * as it seems it doesn't agree with <fp.h>, yet we should really use
-      * <fp.h> if possible.
-      */
+   /* We need to check that <math.h> hasn't already been included earlier
+    * as it seems it doesn't agree with <fp.h>, yet we should really use
+    * <fp.h> if possible.
+    */
 #    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
 #      include <fp.h>
 #    endif
@@ -459,9 +488,9 @@
 #    include <math.h>
 #  endif
 #  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
-     /* Amiga SAS/C: We must include builtin FPU functions when compiling using
-      * MATH=68881
-      */
+   /* Amiga SAS/C: We must include builtin FPU functions when compiling using
+    * MATH=68881
+    */
 #    include <m68881.h>
 #  endif
 #endif
@@ -532,7 +561,8 @@
 /* This implicitly assumes alignment is always to a power of 2. */
 #ifdef png_alignof
 #  define png_isaligned(ptr, type)\
-   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
+   (((type)((const char*)ptr-(const char*)0) & \
+   (type)(png_alignof(type)-1)) == 0)
 #else
 #  define png_isaligned(ptr, type) 0
 #endif
@@ -549,92 +579,92 @@
  * are defined in png.h because they need to be visible to applications
  * that call png_set_unknown_chunk().
  */
-/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */
-/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */
-#define PNG_HAVE_IDAT               0x04
-/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */
-#define PNG_HAVE_IEND               0x10
-                   /*               0x20 (unused) */
-                   /*               0x40 (unused) */
-                   /*               0x80 (unused) */
-#define PNG_HAVE_CHUNK_HEADER      0x100
-#define PNG_WROTE_tIME             0x200
-#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
-#define PNG_BACKGROUND_IS_GRAY     0x800
-#define PNG_HAVE_PNG_SIGNATURE    0x1000
-#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
-                   /*             0x4000 (unused) */
-#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */
+/* #define PNG_HAVE_IHDR            0x01U (defined in png.h) */
+/* #define PNG_HAVE_PLTE            0x02U (defined in png.h) */
+#define PNG_HAVE_IDAT               0x04U
+/* #define PNG_AFTER_IDAT           0x08U (defined in png.h) */
+#define PNG_HAVE_IEND               0x10U
+                   /*               0x20U (unused) */
+                   /*               0x40U (unused) */
+                   /*               0x80U (unused) */
+#define PNG_HAVE_CHUNK_HEADER      0x100U
+#define PNG_WROTE_tIME             0x200U
+#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U
+#define PNG_BACKGROUND_IS_GRAY     0x800U
+#define PNG_HAVE_PNG_SIGNATURE    0x1000U
+#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
+                   /*             0x4000U (unused) */
+#define PNG_IS_READ_STRUCT        0x8000U /* Else is a write struct */
 
 /* Flags for the transformations the PNG library does on the image data */
-#define PNG_BGR                 0x0001
-#define PNG_INTERLACE           0x0002
-#define PNG_PACK                0x0004
-#define PNG_SHIFT               0x0008
-#define PNG_SWAP_BYTES          0x0010
-#define PNG_INVERT_MONO         0x0020
-#define PNG_QUANTIZE            0x0040
-#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */
-#define PNG_BACKGROUND_EXPAND   0x0100
-#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */
-#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */
-#define PNG_RGBA                0x0800
-#define PNG_EXPAND              0x1000
-#define PNG_GAMMA               0x2000
-#define PNG_GRAY_TO_RGB         0x4000
-#define PNG_FILLER              0x8000
-#define PNG_PACKSWAP           0x10000
-#define PNG_SWAP_ALPHA         0x20000
-#define PNG_STRIP_ALPHA        0x40000
-#define PNG_INVERT_ALPHA       0x80000
-#define PNG_USER_TRANSFORM    0x100000
-#define PNG_RGB_TO_GRAY_ERR   0x200000
-#define PNG_RGB_TO_GRAY_WARN  0x400000
-#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
-#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */
-#define PNG_ADD_ALPHA        0x1000000 /* Added to libpng-1.2.7 */
-#define PNG_EXPAND_tRNS      0x2000000 /* Added to libpng-1.2.9 */
-#define PNG_SCALE_16_TO_8    0x4000000 /* Added to libpng-1.5.4 */
-                       /*    0x8000000 unused */
-                       /*   0x10000000 unused */
-                       /*   0x20000000 unused */
-                       /*   0x40000000 unused */
+#define PNG_BGR                 0x0001U
+#define PNG_INTERLACE           0x0002U
+#define PNG_PACK                0x0004U
+#define PNG_SHIFT               0x0008U
+#define PNG_SWAP_BYTES          0x0010U
+#define PNG_INVERT_MONO         0x0020U
+#define PNG_QUANTIZE            0x0040U
+#define PNG_COMPOSE             0x0080U    /* Was PNG_BACKGROUND */
+#define PNG_BACKGROUND_EXPAND   0x0100U
+#define PNG_EXPAND_16           0x0200U    /* Added to libpng 1.5.2 */
+#define PNG_16_TO_8             0x0400U    /* Becomes 'chop' in 1.5.4 */
+#define PNG_RGBA                0x0800U
+#define PNG_EXPAND              0x1000U
+#define PNG_GAMMA               0x2000U
+#define PNG_GRAY_TO_RGB         0x4000U
+#define PNG_FILLER              0x8000U
+#define PNG_PACKSWAP           0x10000U
+#define PNG_SWAP_ALPHA         0x20000U
+#define PNG_STRIP_ALPHA        0x40000U
+#define PNG_INVERT_ALPHA       0x80000U
+#define PNG_USER_TRANSFORM    0x100000U
+#define PNG_RGB_TO_GRAY_ERR   0x200000U
+#define PNG_RGB_TO_GRAY_WARN  0x400000U
+#define PNG_RGB_TO_GRAY       0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */
+#define PNG_ENCODE_ALPHA      0x800000U /* Added to libpng-1.5.4 */
+#define PNG_ADD_ALPHA        0x1000000U /* Added to libpng-1.2.7 */
+#define PNG_EXPAND_tRNS      0x2000000U /* Added to libpng-1.2.9 */
+#define PNG_SCALE_16_TO_8    0x4000000U /* Added to libpng-1.5.4 */
+                       /*    0x8000000U unused */
+                       /*   0x10000000U unused */
+                       /*   0x20000000U unused */
+                       /*   0x40000000U unused */
 /* Flags for png_create_struct */
-#define PNG_STRUCT_PNG   0x0001
-#define PNG_STRUCT_INFO  0x0002
+#define PNG_STRUCT_PNG   0x0001U
+#define PNG_STRUCT_INFO  0x0002U
 
 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
-#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
-#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */
-                                  /*      0x0004    unused */
-#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */
-                                  /*      0x0010    unused */
-                                  /*      0x0020    unused */
-#define PNG_FLAG_ROW_INIT                 0x0040
-#define PNG_FLAG_FILLER_AFTER             0x0080
-#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
-#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
-#define PNG_FLAG_CRC_CRITICAL_USE         0x0400
-#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
-#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */
-#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */
-#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */
-/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */
-/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */
-#define PNG_FLAG_LIBRARY_MISMATCH        0x20000
-#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000
-#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000
-#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */
-#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */
-#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */
-                                  /*    0x800000    unused */
-                                  /*   0x1000000    unused */
-                                  /*   0x2000000    unused */
-                                  /*   0x4000000    unused */
-                                  /*   0x8000000    unused */
-                                  /*  0x10000000    unused */
-                                  /*  0x20000000    unused */
-                                  /*  0x40000000    unused */
+#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001U
+#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002U /* Added to libpng-1.6.0 */
+                                  /*      0x0004U    unused */
+#define PNG_FLAG_ZSTREAM_ENDED            0x0008U /* Added to libpng-1.6.0 */
+                                  /*      0x0010U    unused */
+                                  /*      0x0020U    unused */
+#define PNG_FLAG_ROW_INIT                 0x0040U
+#define PNG_FLAG_FILLER_AFTER             0x0080U
+#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100U
+#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200U
+#define PNG_FLAG_CRC_CRITICAL_USE         0x0400U
+#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800U
+#define PNG_FLAG_ASSUME_sRGB              0x1000U /* Added to libpng-1.5.4 */
+#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000U /* Added to libpng-1.5.4 */
+#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000U /* Added to libpng-1.5.4 */
+/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000U */
+/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000U */
+#define PNG_FLAG_LIBRARY_MISMATCH        0x20000U
+#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000U
+#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000U
+#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000U /* Added to libpng-1.4.0 */
+#define PNG_FLAG_APP_WARNINGS_WARN      0x200000U /* Added to libpng-1.6.0 */
+#define PNG_FLAG_APP_ERRORS_WARN        0x400000U /* Added to libpng-1.6.0 */
+                                  /*    0x800000U    unused */
+                                  /*   0x1000000U    unused */
+                                  /*   0x2000000U    unused */
+                                  /*   0x4000000U    unused */
+                                  /*   0x8000000U    unused */
+                                  /*  0x10000000U    unused */
+                                  /*  0x20000000U    unused */
+                                  /*  0x40000000U    unused */
 
 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
@@ -668,6 +698,24 @@
     ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
     (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
 
+/* This returns the number of trailing bits in the last byte of a row, 0 if the
+ * last byte is completely full of pixels.  It is, in principle, (pixel_bits x
+ * width) % 8, but that would overflow for large 'width'.  The second macro is
+ * the same except that it returns the number of unused bits in the last byte;
+ * (8-TRAILBITS), but 0 when TRAILBITS is 0.
+ *
+ * NOTE: these macros are intended to be self-evidently correct and never
+ * overflow on the assumption that pixel_bits is in the range 0..255.  The
+ * arguments are evaluated only once and they can be signed (e.g. as a result of
+ * the integral promotions).  The result of the expression always has type
+ * (png_uint_32), however the compiler always knows it is in the range 0..7.
+ */
+#define PNG_TRAILBITS(pixel_bits, width) \
+    (((pixel_bits) * ((width) % (png_uint_32)8)) % 8)
+
+#define PNG_PADBITS(pixel_bits, width) \
+    ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8)
+
 /* PNG_OUT_OF_RANGE returns true if value is outside the range
  * ideal-delta..ideal+delta.  Each argument is evaluated twice.
  * "ideal" and "delta" should be constants, normally simple
@@ -1053,7 +1101,7 @@
 #ifdef PNG_WRITE_cHRM_SUPPORTED
 PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,
     const png_xy *xy), PNG_EMPTY);
-    /* The xy value must have been previously validated */
+   /* The xy value must have been previously validated */
 #endif
 
 #ifdef PNG_WRITE_sRGB_SUPPORTED
@@ -1202,6 +1250,7 @@
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
     row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
 
+#if PNG_ARM_NEON_OPT > 0
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
     png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
@@ -1216,6 +1265,24 @@
     row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
     row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
+#if PNG_MIPS_MSA_OPT > 0
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
+    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
 
 /* Choose the best filter to use and filter the row data */
 PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
@@ -1243,7 +1310,7 @@
 /* Initialize the row buffers, etc. */
 PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
 
-#if PNG_ZLIB_VERNUM >= 0x1240
+#if ZLIB_VERNUM >= 0x1240
 PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
       PNG_EMPTY);
 #  define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
@@ -1441,7 +1508,7 @@
 PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,
    png_inforp info_ptr),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,
-     png_bytep row),PNG_EMPTY);
+    png_bytep row),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,
     png_inforp info_ptr),PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,
@@ -1480,13 +1547,13 @@
 
 PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
     png_inforp info_ptr), PNG_EMPTY);
-    /* Synchronize the info 'valid' flags with the colorspace */
+   /* Synchronize the info 'valid' flags with the colorspace */
 
 PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,
     png_inforp info_ptr), PNG_EMPTY);
-    /* Copy the png_struct colorspace to the info_struct and call the above to
-     * synchronize the flags.  Checks for NULL info_ptr and does nothing.
-     */
+   /* Copy the png_struct colorspace to the info_struct and call the above to
+    * synchronize the flags.  Checks for NULL info_ptr and does nothing.
+    */
 #endif
 
 /* Added at libpng version 1.4.0 */
@@ -1520,9 +1587,11 @@
    /* The 'name' is used for information only */
 
 /* Routines for checking parts of an ICC profile. */
+#ifdef PNG_READ_iCCP_SUPPORTED
 PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
    png_colorspacerp colorspace, png_const_charp name,
    png_uint_32 profile_length), PNG_EMPTY);
+#endif /* READ_iCCP */
 PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
    png_colorspacerp colorspace, png_const_charp name,
    png_uint_32 profile_length,
@@ -1941,10 +2010,17 @@
     * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
     * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
     */
+#  if PNG_ARM_NEON_OPT > 0
 PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
    (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
 #endif
 
+#if PNG_MIPS_MSA_OPT > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
+   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+#endif
+#endif
+
 PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
    png_const_charp key, png_bytep new_key), PNG_EMPTY);
 
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,7 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.23 [June 9, 2016]
+ * Last changed in libpng 1.6.26 [October 20, 2016]
  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -56,10 +56,10 @@
 {
 #ifndef PNG_USER_MEM_SUPPORTED
    png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
-      error_fn, warn_fn, NULL, NULL, NULL);
+        error_fn, warn_fn, NULL, NULL, NULL);
 #else
    return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
-       warn_fn, NULL, NULL, NULL);
+        warn_fn, NULL, NULL, NULL);
 }
 
 /* Alternate create PNG structure for reading, and allocate any memory
@@ -71,7 +71,7 @@
     png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
 {
    png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
-      error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
+       error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
 #endif /* USER_MEM */
 
    if (png_ptr != NULL)
@@ -280,7 +280,7 @@
 
       else
          png_handle_unknown(png_ptr, info_ptr, length,
-            PNG_HANDLE_CHUNK_AS_DEFAULT);
+             PNG_HANDLE_CHUNK_AS_DEFAULT);
    }
 }
 #endif /* SEQUENTIAL_READ */
@@ -307,7 +307,7 @@
       /* New in 1.6.0 this avoids the bug of doing the initializations twice */
       else
          png_app_error(png_ptr,
-            "png_read_update_info/png_start_read_image: duplicate call");
+             "png_read_update_info/png_start_read_image: duplicate call");
    }
 }
 
@@ -330,7 +330,7 @@
       /* New in 1.6.0 this avoids the bug of doing the initializations twice */
       else
          png_app_error(png_ptr,
-            "png_start_read_image/png_read_update_info: duplicate call");
+             "png_start_read_image/png_read_update_info: duplicate call");
    }
 }
 #endif /* SEQUENTIAL_READ */
@@ -387,9 +387,9 @@
 
          for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
          {
-            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);
-            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);
-            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);
+            png_uint_32 s0   = (png_uint_32)(*(rp    ) << 8) | *(rp + 1);
+            png_uint_32 s1   = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
+            png_uint_32 s2   = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
             png_uint_32 red  = (s0 + s1 + 65536) & 0xffff;
             png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
             *(rp    ) = (png_byte)((red >> 8) & 0xff);
@@ -568,7 +568,7 @@
    {
       if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
          png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
-            png_ptr->prev_row + 1, png_ptr->row_buf[0]);
+             png_ptr->prev_row + 1, png_ptr->row_buf[0]);
       else
          png_error(png_ptr, "bad adaptive filter value");
    }
@@ -612,7 +612,7 @@
    {
       if (png_ptr->pass < 6)
          png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
-            png_ptr->transformations);
+             png_ptr->transformations);
 
       if (dsp_row != NULL)
          png_combine_row(png_ptr, dsp_row, 1/*display*/);
@@ -747,7 +747,7 @@
           * but the caller should do it!
           */
          png_warning(png_ptr, "Interlace handling should be turned on when "
-            "using png_read_image");
+             "using png_read_image");
          /* Make sure this is set correctly */
          png_ptr->num_rows = png_ptr->height;
       }
@@ -807,8 +807,8 @@
 #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
    /* Report invalid palette index; added at libng-1.5.10 */
    if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
-      png_ptr->num_palette_max > png_ptr->num_palette)
-     png_benign_error(png_ptr, "Read palette index exceeding num_palette");
+       png_ptr->num_palette_max > png_ptr->num_palette)
+      png_benign_error(png_ptr, "Read palette index exceeding num_palette");
 #endif
 
    do
@@ -947,7 +947,7 @@
 
       else
          png_handle_unknown(png_ptr, info_ptr, length,
-            PNG_HANDLE_CHUNK_AS_DEFAULT);
+             PNG_HANDLE_CHUNK_AS_DEFAULT);
    } while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
 }
 #endif /* SEQUENTIAL_READ */
@@ -1058,8 +1058,7 @@
 #ifdef PNG_INFO_IMAGE_SUPPORTED
 void PNGAPI
 png_read_png(png_structrp png_ptr, png_inforp info_ptr,
-                           int transforms,
-                           voidp params)
+    int transforms, voidp params)
 {
    if (png_ptr == NULL || info_ptr == NULL)
       return;
@@ -1335,7 +1334,7 @@
          if (info_ptr != NULL)
          {
             png_controlp control = png_voidcast(png_controlp,
-               png_malloc_warn(png_ptr, (sizeof *control)));
+                png_malloc_warn(png_ptr, (sizeof *control)));
 
             if (control != NULL)
             {
@@ -1422,7 +1421,9 @@
    png_structrp png_ptr = image->opaque->png_ptr;
    png_inforp info_ptr = image->opaque->info_ptr;
 
+#ifdef PNG_BENIGN_ERRORS_SUPPORTED
    png_set_benign_errors(png_ptr, 1/*warn*/);
+#endif
    png_read_info(png_ptr, info_ptr);
 
    /* Do this the fast way; just read directly out of png_struct. */
@@ -1460,7 +1461,7 @@
             break;
 
          case PNG_COLOR_TYPE_PALETTE:
-            cmap_entries = png_ptr->num_palette;
+            cmap_entries = (png_uint_32)png_ptr->num_palette;
             break;
 
          default:
@@ -1498,12 +1499,12 @@
 
       else
          return png_image_error(image,
-            "png_image_begin_read_from_stdio: invalid argument");
+             "png_image_begin_read_from_stdio: invalid argument");
    }
 
    else if (image != NULL)
       return png_image_error(image,
-         "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
+          "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
 
    return 0;
 }
@@ -1536,12 +1537,12 @@
 
       else
          return png_image_error(image,
-            "png_image_begin_read_from_file: invalid argument");
+             "png_image_begin_read_from_file: invalid argument");
    }
 
    else if (image != NULL)
       return png_image_error(image,
-         "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
+          "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
 
    return 0;
 }
@@ -1578,7 +1579,7 @@
 }
 
 int PNGAPI png_image_begin_read_from_memory(png_imagep image,
-   png_const_voidp memory, png_size_t size)
+    png_const_voidp memory, png_size_t size)
 {
    if (image != NULL && image->version == PNG_IMAGE_VERSION)
    {
@@ -1601,12 +1602,12 @@
 
       else
          return png_image_error(image,
-            "png_image_begin_read_from_memory: invalid argument");
+             "png_image_begin_read_from_memory: invalid argument");
    }
 
    else if (image != NULL)
       return png_image_error(image,
-         "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
+          "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
 
    return 0;
 }
@@ -1652,12 +1653,12 @@
         * IHDR, PLTE, tRNS, IDAT, and IEND chunks.
         */
        png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,
-         NULL, -1);
+           NULL, -1);
 
        /* But do not ignore image data handling chunks */
        png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
-         chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
-    }
+           chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
+   }
 }
 
 #  define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)
@@ -1724,7 +1725,7 @@
 #ifdef __GNUC__
       default:
          png_error(display->image->opaque->png_ptr,
-            "unexpected encoding (internal error)");
+             "unexpected encoding (internal error)");
 #endif
    }
 
@@ -1733,8 +1734,8 @@
 
 static png_uint_32
 png_colormap_compose(png_image_read_control *display,
-   png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha,
-   png_uint_32 background, int encoding)
+    png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha,
+    png_uint_32 background, int encoding)
 {
    /* The file value is composed on the background, the background has the given
     * encoding and so does the result, the file is encoded with P_FILE and the
@@ -1770,14 +1771,14 @@
  */
 static void
 png_create_colormap_entry(png_image_read_control *display,
-   png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
-   png_uint_32 alpha, int encoding)
+    png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
+    png_uint_32 alpha, int encoding)
 {
    png_imagep image = display->image;
    const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
-      P_LINEAR : P_sRGB;
+       P_LINEAR : P_sRGB;
    const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
-      (red != green || green != blue);
+       (red != green || green != blue);
 
    if (ip > 255)
       png_error(image->opaque->png_ptr, "color-map index out of range");
@@ -1995,7 +1996,7 @@
    for (i=0; i<256; ++i)
       png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
 
-   return i;
+   return (int)i;
 }
 
 static int
@@ -2006,7 +2007,7 @@
    for (i=0; i<256; ++i)
       png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
 
-   return i;
+   return (int)i;
 }
 #define PNG_GRAY_COLORMAP_ENTRIES 256
 
@@ -2057,10 +2058,10 @@
 
       for (g=0; g<6; ++g)
          png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,
-            P_sRGB);
+             P_sRGB);
    }
 
-   return i;
+   return (int)i;
 }
 
 #define PNG_GA_COLORMAP_ENTRIES 256
@@ -2081,11 +2082,11 @@
 
          for (b=0; b<6; ++b)
             png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,
-               P_sRGB);
+                P_sRGB);
       }
    }
 
-   return i;
+   return (int)i;
 }
 
 #define PNG_RGB_COLORMAP_ENTRIES 216
@@ -2133,7 +2134,7 @@
 
       else if (display->background == NULL /* no way to remove it */)
          png_error(png_ptr,
-            "a background color must be supplied to remove alpha/transparency");
+             "background color must be supplied to remove alpha/transparency");
 
       /* Get a copy of the background color (this avoids repeating the checks
        * below.)  The encoding is 8-bit sRGB or 16-bit linear, depending on the
@@ -2228,7 +2229,7 @@
                 */
                if (i != trans)
                   png_create_colormap_entry(display, i, val, val, val, 255,
-                     P_FILE/*8-bit with file gamma*/);
+                      P_FILE/*8-bit with file gamma*/);
 
                /* Else this entry is transparent.  The colors don't matter if
                 * there is an alpha channel (back_alpha == 0), but it does no
@@ -2240,7 +2241,7 @@
                 */
                else
                   png_create_colormap_entry(display, i, back_r, back_g, back_b,
-                     back_alpha, output_encoding);
+                      back_alpha, output_encoding);
             }
 
             /* We need libpng to preserve the original encoding. */
@@ -2278,7 +2279,7 @@
             if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
                png_error(png_ptr, "gray[16] color-map: too few entries");
 
-            cmap_entries = make_gray_colormap(display);
+            cmap_entries = (unsigned int)make_gray_colormap(display);
 
             if (png_ptr->num_trans > 0)
             {
@@ -2305,7 +2306,7 @@
                          * matches.
                          */
                         png_create_colormap_entry(display, gray, back_g, back_g,
-                           back_g, 65535, P_LINEAR);
+                            back_g, 65535, P_LINEAR);
                      }
 
                      /* The background passed to libpng, however, must be the
@@ -2319,8 +2320,8 @@
                       * doesn't.
                       */
                      png_set_background_fixed(png_ptr, &c,
-                        PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
-                        0/*gamma: not used*/);
+                         PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
+                         0/*gamma: not used*/);
 
                      output_processing = PNG_CMAP_NONE;
                      break;
@@ -2350,7 +2351,7 @@
                 * background color at full precision.
                 */
                png_create_colormap_entry(display, 254, back_r, back_g, back_b,
-                  back_alpha, output_encoding);
+                   back_alpha, output_encoding);
             }
 
             else
@@ -2376,7 +2377,7 @@
             if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
                png_error(png_ptr, "gray+alpha color-map: too few entries");
 
-            cmap_entries = make_ga_colormap(display);
+            cmap_entries = (unsigned int)make_ga_colormap(display);
 
             background_index = PNG_CMAP_GA_BACKGROUND;
             output_processing = PNG_CMAP_GA;
@@ -2410,7 +2411,7 @@
                if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
                   png_error(png_ptr, "gray-alpha color-map: too few entries");
 
-               cmap_entries = make_gray_colormap(display);
+               cmap_entries = (unsigned int)make_gray_colormap(display);
 
                if (output_encoding == P_LINEAR)
                {
@@ -2418,7 +2419,7 @@
 
                   /* And make sure the corresponding palette entry matches. */
                   png_create_colormap_entry(display, gray, back_g, back_g,
-                     back_g, 65535, P_LINEAR);
+                      back_g, 65535, P_LINEAR);
                }
 
                /* The background passed to libpng, however, must be the sRGB
@@ -2428,8 +2429,8 @@
                c.gray = c.red = c.green = c.blue = (png_uint_16)gray;
 
                png_set_background_fixed(png_ptr, &c,
-                  PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
-                  0/*gamma: not used*/);
+                   PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
+                   0/*gamma: not used*/);
 
                output_processing = PNG_CMAP_NONE;
             }
@@ -2449,7 +2450,7 @@
                {
                   png_uint_32 gray = (i * 256 + 115) / 231;
                   png_create_colormap_entry(display, i++, gray, gray, gray,
-                     255, P_sRGB);
+                      255, P_sRGB);
                }
 
                /* NOTE: this preserves the full precision of the application
@@ -2458,13 +2459,13 @@
                background_index = i;
                png_create_colormap_entry(display, i++, back_r, back_g, back_b,
 #ifdef __COVERITY__
-                 /* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
-                  * here.
-                  */ 255U,
+                   /* Coverity claims that output_encoding
+                    * cannot be 2 (P_LINEAR) here.
+                    */ 255U,
 #else
-                  output_encoding == P_LINEAR ? 65535U : 255U,
+                    output_encoding == P_LINEAR ? 65535U : 255U,
 #endif
-                  output_encoding);
+                    output_encoding);
 
                /* For non-opaque input composite on the sRGB background - this
                 * requires inverting the encoding for each component.  The input
@@ -2502,9 +2503,9 @@
                      png_uint_32 gray = png_sRGB_table[g*51] * alpha;
 
                      png_create_colormap_entry(display, i++,
-                        PNG_sRGB_FROM_LINEAR(gray + back_rx),
-                        PNG_sRGB_FROM_LINEAR(gray + back_gx),
-                        PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB);
+                         PNG_sRGB_FROM_LINEAR(gray + back_rx),
+                         PNG_sRGB_FROM_LINEAR(gray + back_gx),
+                         PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB);
                   }
                }
 
@@ -2530,7 +2531,7 @@
              * png_set_tRNS_to_alpha before png_set_background_fixed.
              */
             png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,
-               -1);
+                -1);
             data_encoding = P_sRGB;
 
             /* The output will now be one or two 8-bit gray or gray+alpha
@@ -2549,7 +2550,7 @@
                if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
                   png_error(png_ptr, "rgb[ga] color-map: too few entries");
 
-               cmap_entries = make_ga_colormap(display);
+               cmap_entries = (unsigned int)make_ga_colormap(display);
                background_index = PNG_CMAP_GA_BACKGROUND;
                output_processing = PNG_CMAP_GA;
             }
@@ -2575,12 +2576,12 @@
                   png_ptr->num_trans > 0) &&
                   png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
                {
-                  cmap_entries = make_gray_file_colormap(display);
+                  cmap_entries = (unsigned int)make_gray_file_colormap(display);
                   data_encoding = P_FILE;
                }
 
                else
-                  cmap_entries = make_gray_colormap(display);
+                  cmap_entries = (unsigned int)make_gray_colormap(display);
 
                /* But if the input has alpha or transparency it must be removed
                 */
@@ -2606,13 +2607,13 @@
                         gray = png_sRGB_table[gray]; /* now P_LINEAR */
 
                      gray = PNG_DIV257(png_gamma_16bit_correct(gray,
-                        png_ptr->colorspace.gamma)); /* now P_FILE */
+                         png_ptr->colorspace.gamma)); /* now P_FILE */
 
                      /* And make sure the corresponding palette entry contains
                       * exactly the required sRGB value.
                       */
                      png_create_colormap_entry(display, gray, back_g, back_g,
-                        back_g, 0/*unused*/, output_encoding);
+                         back_g, 0/*unused*/, output_encoding);
                   }
 
                   else if (output_encoding == P_LINEAR)
@@ -2637,8 +2638,8 @@
                    */
                   expand_tRNS = 1;
                   png_set_background_fixed(png_ptr, &c,
-                     PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
-                     0/*gamma: not used*/);
+                      PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
+                      0/*gamma: not used*/);
                }
 
                output_processing = PNG_CMAP_NONE;
@@ -2668,11 +2669,11 @@
                   if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
                      png_error(png_ptr, "rgb+alpha color-map: too few entries");
 
-                  cmap_entries = make_rgb_colormap(display);
+                  cmap_entries = (unsigned int)make_rgb_colormap(display);
 
                   /* Add a transparent entry. */
                   png_create_colormap_entry(display, cmap_entries, 255, 255,
-                     255, 0, P_sRGB);
+                      255, 0, P_sRGB);
 
                   /* This is stored as the background index for the processing
                    * algorithm.
@@ -2693,7 +2694,7 @@
                          */
                         for (b=0; b<256; b = (b << 1) | 0x7f)
                            png_create_colormap_entry(display, cmap_entries++,
-                              r, g, b, 128, P_sRGB);
+                               r, g, b, 128, P_sRGB);
                      }
                   }
 
@@ -2717,10 +2718,10 @@
                   if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
                      png_error(png_ptr, "rgb-alpha color-map: too few entries");
 
-                  cmap_entries = make_rgb_colormap(display);
+                  cmap_entries = (unsigned int)make_rgb_colormap(display);
 
                   png_create_colormap_entry(display, cmap_entries, back_r,
-                        back_g, back_b, 0/*unused*/, output_encoding);
+                      back_g, back_b, 0/*unused*/, output_encoding);
 
                   if (output_encoding == P_LINEAR)
                   {
@@ -2742,9 +2743,9 @@
                    * index.
                    */
                   if (memcmp((png_const_bytep)display->colormap +
-                        sample_size * cmap_entries,
-                     (png_const_bytep)display->colormap +
-                        sample_size * PNG_RGB_INDEX(r,g,b),
+                      sample_size * cmap_entries,
+                      (png_const_bytep)display->colormap +
+                          sample_size * PNG_RGB_INDEX(r,g,b),
                      sample_size) != 0)
                   {
                      /* The background color must be added. */
@@ -2762,13 +2763,13 @@
                             */
                            for (b=0; b<256; b = (b << 1) | 0x7f)
                               png_create_colormap_entry(display, cmap_entries++,
-                                 png_colormap_compose(display, r, P_sRGB, 128,
-                                    back_r, output_encoding),
-                                 png_colormap_compose(display, g, P_sRGB, 128,
-                                    back_g, output_encoding),
-                                 png_colormap_compose(display, b, P_sRGB, 128,
-                                    back_b, output_encoding),
-                                 0/*unused*/, output_encoding);
+                                  png_colormap_compose(display, r, P_sRGB, 128,
+                                      back_r, output_encoding),
+                                  png_colormap_compose(display, g, P_sRGB, 128,
+                                      back_g, output_encoding),
+                                  png_colormap_compose(display, b, P_sRGB, 128,
+                                      back_b, output_encoding),
+                                  0/*unused*/, output_encoding);
                         }
                      }
 
@@ -2786,8 +2787,8 @@
                      c.blue = (png_uint_16)back_b;
 
                      png_set_background_fixed(png_ptr, &c,
-                        PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
-                        0/*gamma: not used*/);
+                         PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
+                         0/*gamma: not used*/);
 
                      output_processing = PNG_CMAP_RGB;
                   }
@@ -2802,7 +2803,7 @@
                if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
                   png_error(png_ptr, "rgb color-map: too few entries");
 
-               cmap_entries = make_rgb_colormap(display);
+               cmap_entries = (unsigned int)make_rgb_colormap(display);
                output_processing = PNG_CMAP_RGB;
             }
          }
@@ -2826,11 +2827,11 @@
 
             output_processing = PNG_CMAP_NONE;
             data_encoding = P_FILE; /* Don't change from color-map indices */
-            cmap_entries = png_ptr->num_palette;
+            cmap_entries = (unsigned int)png_ptr->num_palette;
             if (cmap_entries > 256)
                cmap_entries = 256;
 
-            if (cmap_entries > image->colormap_entries)
+            if (cmap_entries > (unsigned int)image->colormap_entries)
                png_error(png_ptr, "palette color-map: too few entries");
 
             for (i=0; i < cmap_entries; ++i)
@@ -2839,7 +2840,7 @@
                {
                   if (trans[i] == 0)
                      png_create_colormap_entry(display, i, back_r, back_g,
-                        back_b, 0, output_encoding);
+                         back_b, 0, output_encoding);
 
                   else
                   {
@@ -2847,22 +2848,22 @@
                       * on the sRGB color in 'back'.
                       */
                      png_create_colormap_entry(display, i,
-                        png_colormap_compose(display, colormap[i].red, P_FILE,
-                           trans[i], back_r, output_encoding),
-                        png_colormap_compose(display, colormap[i].green, P_FILE,
-                           trans[i], back_g, output_encoding),
-                        png_colormap_compose(display, colormap[i].blue, P_FILE,
-                           trans[i], back_b, output_encoding),
-                        output_encoding == P_LINEAR ? trans[i] * 257U :
-                           trans[i],
-                        output_encoding);
+                         png_colormap_compose(display, colormap[i].red,
+                             P_FILE, trans[i], back_r, output_encoding),
+                         png_colormap_compose(display, colormap[i].green,
+                             P_FILE, trans[i], back_g, output_encoding),
+                         png_colormap_compose(display, colormap[i].blue,
+                             P_FILE, trans[i], back_b, output_encoding),
+                         output_encoding == P_LINEAR ? trans[i] * 257U :
+                             trans[i],
+                         output_encoding);
                   }
                }
 
                else
                   png_create_colormap_entry(display, i, colormap[i].red,
-                     colormap[i].green, colormap[i].blue,
-                     i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);
+                      colormap[i].green, colormap[i].blue,
+                      i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);
             }
 
             /* The PNG data may have indices packed in fewer than 8 bits, it
@@ -2942,7 +2943,7 @@
          png_error(png_ptr, "bad background index (internal error)");
    }
 
-   display->colormap_processing = output_processing;
+   display->colormap_processing = (int)output_processing;
 
    return 1/*ok*/;
 }
@@ -2952,7 +2953,7 @@
 png_image_read_and_map(png_voidp argument)
 {
    png_image_read_control *display = png_voidcast(png_image_read_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
    int passes;
@@ -3089,7 +3090,7 @@
 
                      if (alpha >= 196)
                         *outrow = PNG_RGB_INDEX(inrow[0], inrow[1],
-                           inrow[2]);
+                            inrow[2]);
 
                      else if (alpha < 64)
                         *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND;
@@ -3141,7 +3142,7 @@
 png_image_read_colormapped(png_voidp argument)
 {
    png_image_read_control *display = png_voidcast(png_image_read_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_controlp control = image->opaque;
    png_structrp png_ptr = control->png_ptr;
@@ -3251,14 +3252,14 @@
 
    else
    {
-      png_alloc_size_t row_bytes = display->row_bytes;
+      png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
 
       while (--passes >= 0)
       {
          png_uint_32      y = image->height;
          png_bytep        row = png_voidcast(png_bytep, display->first_row);
 
-         while (y-- > 0)
+         for (; y > 0; --y)
          {
             png_read_row(png_ptr, row, NULL);
             row += row_bytes;
@@ -3274,7 +3275,7 @@
 png_image_read_composite(png_voidp argument)
 {
    png_image_read_control *display = png_voidcast(png_image_read_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
    int passes;
@@ -3401,7 +3402,7 @@
 png_image_read_background(png_voidp argument)
 {
    png_image_read_control *display = png_voidcast(png_image_read_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
    png_inforp info_ptr = image->opaque->info_ptr;
@@ -3461,8 +3462,7 @@
 
             for (pass = 0; pass < passes; ++pass)
             {
-               png_bytep        row = png_voidcast(png_bytep,
-                                                   display->first_row);
+               png_bytep row = png_voidcast(png_bytep, display->first_row);
                unsigned int     startx, stepx, stepy;
                png_uint_32      y;
 
@@ -3490,7 +3490,7 @@
                   for (; y<height; y += stepy)
                   {
                      png_bytep inrow = png_voidcast(png_bytep,
-                        display->local_row);
+                         display->local_row);
                      png_bytep outrow = first_row + y * step_row;
                      png_const_bytep end_row = outrow + width;
 
@@ -3535,7 +3535,7 @@
                   for (; y<height; y += stepy)
                   {
                      png_bytep inrow = png_voidcast(png_bytep,
-                        display->local_row);
+                         display->local_row);
                      png_bytep outrow = first_row + y * step_row;
                      png_const_bytep end_row = outrow + width;
 
@@ -3582,13 +3582,14 @@
           */
          {
             png_uint_16p first_row = png_voidcast(png_uint_16p,
-               display->first_row);
+                display->first_row);
             /* The division by two is safe because the caller passed in a
              * stride which was multiplied by 2 (below) to get row_bytes.
              */
             ptrdiff_t    step_row = display->row_bytes / 2;
-            int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
-            unsigned int outchannels = 1+preserve_alpha;
+            unsigned int preserve_alpha = (image->format &
+                PNG_FORMAT_FLAG_ALPHA) != 0;
+            unsigned int outchannels = 1U+preserve_alpha;
             int swap_alpha = 0;
 
 #           ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
@@ -3632,7 +3633,7 @@
 
                   /* Read the row, which is packed: */
                   png_read_row(png_ptr, png_voidcast(png_bytep,
-                     display->local_row), NULL);
+                      display->local_row), NULL);
                   inrow = png_voidcast(png_const_uint_16p, display->local_row);
 
                   /* Now do the pre-multiplication on each pixel in this row.
@@ -3681,7 +3682,7 @@
 png_image_read_direct(png_voidp argument)
 {
    png_image_read_control *display = png_voidcast(png_image_read_control*,
-      argument);
+       argument);
    png_imagep image = display->image;
    png_structrp png_ptr = image->opaque->png_ptr;
    png_inforp info_ptr = image->opaque->info_ptr;
@@ -3732,7 +3733,7 @@
                do_local_background = 1/*maybe*/;
 
             png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
-               PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
+                PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
          }
 
          change &= ~PNG_FORMAT_FLAG_COLOR;
@@ -3791,7 +3792,7 @@
           * final value.
           */
          if (png_muldiv(&gtest, output_gamma, png_ptr->colorspace.gamma,
-               PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
+             PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
             do_local_background = 0;
 
          else if (mode == PNG_ALPHA_STANDARD)
@@ -3854,8 +3855,8 @@
                 * pixels.
                 */
                png_set_background_fixed(png_ptr, &c,
-                  PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
-                  0/*gamma: not used*/);
+                   PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
+                   0/*gamma: not used*/);
             }
 
             else /* compose on row: implemented below. */
@@ -4085,14 +4086,14 @@
 
    else
    {
-      png_alloc_size_t row_bytes = display->row_bytes;
+      png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
 
       while (--passes >= 0)
       {
          png_uint_32      y = image->height;
          png_bytep        row = png_voidcast(png_bytep, display->first_row);
 
-         while (y-- > 0)
+         for (; y > 0; --y)
          {
             png_read_row(png_ptr, row, NULL);
             row += row_bytes;
@@ -4105,7 +4106,7 @@
 
 int PNGAPI
 png_image_finish_read(png_imagep image, png_const_colorp background,
-   void *buffer, png_int_32 row_stride, void *colormap)
+    void *buffer, png_int_32 row_stride, void *colormap)
 {
    if (image != NULL && image->version == PNG_IMAGE_VERSION)
    {
@@ -4115,7 +4116,13 @@
        */
       const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
 
-      if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
+      /* The following checks just the 'row_stride' calculation to ensure it
+       * fits in a signed 32-bit value.  Because channels/components can be
+       * either 1 or 2 bytes in size the length of a row can still overflow 32
+       * bits; this is just to verify that the 'row_stride' argument can be
+       * represented.
+       */
+      if (image->width <= 0x7fffffffU/channels) /* no overflow */
       {
          png_uint_32 check;
          const png_uint_32 png_row_stride = image->width * channels;
@@ -4124,18 +4131,35 @@
             row_stride = (png_int_32)/*SAFE*/png_row_stride;
 
          if (row_stride < 0)
-            check = -row_stride;
+            check = (png_uint_32)(-row_stride);
 
          else
-            check = row_stride;
-
+            check = (png_uint_32)row_stride;
+
+         /* This verifies 'check', the absolute value of the actual stride
+          * passed in and detects overflow in the application calculation (i.e.
+          * if the app did actually pass in a non-zero 'row_stride'.
+          */
          if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
          {
             /* Now check for overflow of the image buffer calculation; this
              * limits the whole image size to 32 bits for API compatibility with
              * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
+             *
+             * The PNG_IMAGE_BUFFER_SIZE macro is:
+             *
+             *    (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride))
+             *
+             * And the component size is always 1 or 2, so make sure that the
+             * number of *bytes* that the application is saying are available
+             * does actually fit into a 32-bit number.
+             *
+             * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE
+             * will be changed to use png_alloc_size_t; bigger images can be
+             * accomodated on 64-bit systems.
              */
-            if (image->height <= 0xFFFFFFFF/png_row_stride)
+            if (image->height <=
+                0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
             {
                if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
                   (image->colormap_entries > 0 && colormap != NULL))
@@ -4155,15 +4179,16 @@
                    * all the setup has already been done.
                    */
                   if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
-                     result = png_safe_execute(image,
-                                    png_image_read_colormap, &display) &&
-                              png_safe_execute(image,
-                                    png_image_read_colormapped, &display);
+                     result =
+                         png_safe_execute(image,
+                             png_image_read_colormap, &display) &&
+                             png_safe_execute(image,
+                             png_image_read_colormapped, &display);
 
                   else
                      result =
                         png_safe_execute(image,
-                              png_image_read_direct, &display);
+                            png_image_read_direct, &display);
 
                   png_image_free(image);
                   return result;
@@ -4171,27 +4196,27 @@
 
                else
                   return png_image_error(image,
-                     "png_image_finish_read[color-map]: no color-map");
+                      "png_image_finish_read[color-map]: no color-map");
             }
 
             else
                return png_image_error(image,
-                  "png_image_finish_read: image too large");
+                   "png_image_finish_read: image too large");
          }
 
          else
             return png_image_error(image,
-               "png_image_finish_read: invalid argument");
+                "png_image_finish_read: invalid argument");
       }
 
       else
          return png_image_error(image,
-            "png_image_finish_read: row_stride too large");
+             "png_image_finish_read: row_stride too large");
    }
 
    else if (image != NULL)
       return png_image_error(image,
-         "png_image_finish_read: damaged PNG_IMAGE_VERSION");
+          "png_image_finish_read: damaged PNG_IMAGE_VERSION");
 
    return 0;
 }
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.17 [March 26, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.24 [August 4, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -113,7 +113,7 @@
  */
 void PNGAPI
 png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
-   png_rw_ptr read_data_fn)
+    png_rw_ptr read_data_fn)
 {
    if (png_ptr == NULL)
       return;
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,7 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.22 [May 26, 2016]
+ * Last changed in libpng 1.6.24 [August 4, 2016]
  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -76,7 +76,7 @@
 
       case PNG_CRC_WARN_DISCARD:    /* Not a valid action for critical data */
          png_warning(png_ptr,
-            "Can't discard critical data on CRC error");
+             "Can't discard critical data on CRC error");
       case PNG_CRC_ERROR_QUIT:                                /* Error/quit */
 
       case PNG_CRC_DEFAULT:
@@ -129,7 +129,7 @@
    {
       if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
          png_app_error(png_ptr,
-            "invalid after png_start_read_image or png_read_update_info");
+             "invalid after png_start_read_image or png_read_update_info");
 
       else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)
          png_app_error(png_ptr, "invalid before the PNG header has been read");
@@ -237,7 +237,7 @@
 #if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
 static png_fixed_point
 translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
-   int is_screen)
+    int is_screen)
 {
    /* Check for flag values.  The main reason for having the old Mac value as a
     * flag is that it is pretty near impossible to work out what the correct
@@ -301,7 +301,7 @@
 #ifdef PNG_READ_ALPHA_MODE_SUPPORTED
 void PNGFAPI
 png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
-   png_fixed_point output_gamma)
+    png_fixed_point output_gamma)
 {
    int compose = 0;
    png_fixed_point file_gamma;
@@ -405,7 +405,7 @@
 
       if ((png_ptr->transformations & PNG_COMPOSE) != 0)
          png_error(png_ptr,
-            "conflicting calls to set alpha mode and background");
+             "conflicting calls to set alpha mode and background");
 
       png_ptr->transformations |= PNG_COMPOSE;
    }
@@ -416,7 +416,7 @@
 png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
 {
    png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
-      output_gamma));
+       output_gamma));
 }
 #  endif
 #endif
@@ -457,7 +457,7 @@
       int i;
 
       png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
-          (png_uint_32)(num_palette * (sizeof (png_byte))));
+          (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
       for (i = 0; i < num_palette; i++)
          png_ptr->quantize_index[i] = (png_byte)i;
    }
@@ -474,7 +474,7 @@
 
          /* Initialize an array to sort colors */
          png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
-             (png_uint_32)(num_palette * (sizeof (png_byte))));
+             (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
 
          /* Initialize the quantize_sort array */
          for (i = 0; i < num_palette; i++)
@@ -608,9 +608,9 @@
 
          /* Initialize palette index arrays */
          png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
-             (png_uint_32)(num_palette * (sizeof (png_byte))));
+             (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
          png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
-             (png_uint_32)(num_palette * (sizeof (png_byte))));
+             (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
 
          /* Initialize the sort array */
          for (i = 0; i < num_palette; i++)
@@ -830,7 +830,7 @@
 #ifdef PNG_READ_GAMMA_SUPPORTED
 void PNGFAPI
 png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
-   png_fixed_point file_gamma)
+    png_fixed_point file_gamma)
 {
    png_debug(1, "in png_set_gamma_fixed");
 
@@ -872,7 +872,7 @@
 png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
 {
    png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
-      convert_gamma_value(png_ptr, file_gamma));
+       convert_gamma_value(png_ptr, file_gamma));
 }
 #  endif /* FLOATING_POINT */
 #endif /* READ_GAMMA */
@@ -1018,7 +1018,7 @@
        * that it just worked and get a memory overwrite.
        */
       png_error(png_ptr,
-        "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
+          "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
 
       /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
    }
@@ -1045,7 +1045,7 @@
       {
          if (red >= 0 && green >= 0)
             png_app_warning(png_ptr,
-               "ignoring out of range rgb_to_gray coefficients");
+                "ignoring out of range rgb_to_gray coefficients");
 
          /* Use the defaults, from the cHRM chunk if set, else the historical
           * values which are close to the sRGB/HDTV/ITU-Rec 709 values.  See
@@ -1054,7 +1054,7 @@
           * something has already provided a default.
           */
          if (png_ptr->rgb_to_gray_red_coeff == 0 &&
-            png_ptr->rgb_to_gray_green_coeff == 0)
+             png_ptr->rgb_to_gray_green_coeff == 0)
          {
             png_ptr->rgb_to_gray_red_coeff   = 6968;
             png_ptr->rgb_to_gray_green_coeff = 23434;
@@ -1071,10 +1071,10 @@
 
 void PNGAPI
 png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
-   double green)
+    double green)
 {
    png_set_rgb_to_gray_fixed(png_ptr, error_action,
-      png_fixed(png_ptr, red, "rgb to gray red coefficient"),
+       png_fixed(png_ptr, red, "rgb to gray red coefficient"),
       png_fixed(png_ptr, green, "rgb to gray green coefficient"));
 }
 #endif /* FLOATING POINT */
@@ -1331,7 +1331,7 @@
       {
          if (png_ptr->screen_gamma != 0) /* screen set too */
             gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
-               png_ptr->screen_gamma);
+                png_ptr->screen_gamma);
 
          else
             /* Assume the output matches the input; a long time default behavior
@@ -1612,7 +1612,7 @@
           */
          if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
             png_warning(png_ptr,
-               "libpng does not support gamma+background+rgb_to_gray");
+                "libpng does not support gamma+background+rgb_to_gray");
 
          if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0)
          {
@@ -1648,13 +1648,13 @@
                   case PNG_BACKGROUND_GAMMA_FILE:
                      g = png_reciprocal(png_ptr->colorspace.gamma);
                      gs = png_reciprocal2(png_ptr->colorspace.gamma,
-                        png_ptr->screen_gamma);
+                         png_ptr->screen_gamma);
                      break;
 
                   case PNG_BACKGROUND_GAMMA_UNIQUE:
                      g = png_reciprocal(png_ptr->background_gamma);
                      gs = png_reciprocal2(png_ptr->background_gamma,
-                        png_ptr->screen_gamma);
+                         png_ptr->screen_gamma);
                      break;
                   default:
                      g = PNG_FP_1;    /* back_1 */
@@ -1682,11 +1682,11 @@
                if (png_gamma_significant(g) != 0)
                {
                   back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
-                     g);
+                      g);
                   back_1.green = png_gamma_8bit_correct(
-                     png_ptr->background.green, g);
+                      png_ptr->background.green, g);
                   back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,
-                     g);
+                      g);
                }
 
                else
@@ -1757,7 +1757,7 @@
                case PNG_BACKGROUND_GAMMA_FILE:
                   g = png_reciprocal(png_ptr->colorspace.gamma);
                   gs = png_reciprocal2(png_ptr->colorspace.gamma,
-                     png_ptr->screen_gamma);
+                      png_ptr->screen_gamma);
                   break;
 
                case PNG_BACKGROUND_GAMMA_UNIQUE:
@@ -2178,7 +2178,7 @@
          {
             png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
             png_bytep dp = row + (png_size_t)row_width - 1;
-            png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
+            png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
             for (i = 0; i < row_width; i++)
             {
                *dp = (png_byte)((*sp >> shift) & 0x01);
@@ -2202,7 +2202,7 @@
 
             png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
             png_bytep dp = row + (png_size_t)row_width - 1;
-            png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
+            png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
             for (i = 0; i < row_width; i++)
             {
                *dp = (png_byte)((*sp >> shift) & 0x03);
@@ -2225,7 +2225,7 @@
          {
             png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
             png_bytep dp = row + (png_size_t)row_width - 1;
-            png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
+            png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
             for (i = 0; i < row_width; i++)
             {
                *dp = (png_byte)((*sp >> shift) & 0x0f);
@@ -3251,7 +3251,8 @@
                         == png_ptr->trans_color.gray)
                      {
                         unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
-                        tmp |= png_ptr->background.gray << shift;
+                        tmp |=
+                            (unsigned int)(png_ptr->background.gray << shift);
                         *sp = (png_byte)(tmp & 0xff);
                      }
 
@@ -3280,7 +3281,8 @@
                             == png_ptr->trans_color.gray)
                         {
                            unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
-                           tmp |= png_ptr->background.gray << shift;
+                           tmp |=
+                              (unsigned int)png_ptr->background.gray << shift;
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -3290,7 +3292,7 @@
                            unsigned int g = (gamma_table [p | (p << 2) |
                                (p << 4) | (p << 6)] >> 6) & 0x03;
                            unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
-                           tmp |= g << shift;
+                           tmp |= (unsigned int)(g << shift);
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -3316,7 +3318,8 @@
                             == png_ptr->trans_color.gray)
                         {
                            unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
-                           tmp |= png_ptr->background.gray << shift;
+                           tmp |=
+                               (unsigned int)png_ptr->background.gray << shift;
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -3346,7 +3349,8 @@
                             == png_ptr->trans_color.gray)
                         {
                            unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
-                           tmp |= png_ptr->background.gray << shift;
+                           tmp |=
+                              (unsigned int)(png_ptr->background.gray << shift);
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -3356,7 +3360,7 @@
                            unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
                               0x0f;
                            unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
-                           tmp |= g << shift;
+                           tmp |= (unsigned int)(g << shift);
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -3382,7 +3386,8 @@
                             == png_ptr->trans_color.gray)
                         {
                            unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
-                           tmp |= png_ptr->background.gray << shift;
+                           tmp |=
+                              (unsigned int)(png_ptr->background.gray << shift);
                            *sp = (png_byte)(tmp & 0xff);
                         }
 
@@ -4223,7 +4228,7 @@
  */
 static void
 png_do_expand_palette(png_row_infop row_info, png_bytep row,
-   png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
+    png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
 {
    int shift, value;
    png_bytep sp, dp;
@@ -4530,7 +4535,7 @@
             row_info->channels = 2;
             row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
             row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
-               row_width);
+                row_width);
          }
       }
       else if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
@@ -4790,7 +4795,7 @@
        (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
        row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
       png_do_strip_channel(row_info, png_ptr->row_buf + 1,
-         0 /* at_start == false, because SWAP_ALPHA happens later */);
+          0 /* at_start == false, because SWAP_ALPHA happens later */);
 #endif
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.20 [December 3, 2014]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.27 [January 5, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -114,11 +114,11 @@
 {
    png_uint_32 uval = png_get_uint_32(buf);
    if ((uval & 0x80000000) == 0) /* non-negative */
-      return uval;
+      return (png_int_32)uval;
 
    uval = (uval ^ 0xffffffff) + 1;  /* 2's complement: -x = ~x+1 */
    if ((uval & 0x80000000) == 0) /* no overflow */
-       return -(png_int_32)uval;
+      return -(png_int_32)uval;
    /* The following has to be safe; this function only gets called on PNG data
     * and if we get here that data is invalid.  0 is the most safe value and
     * if not then an attacker would surely just generate a PNG with 0 instead.
@@ -398,11 +398,10 @@
     */
    {
       int ret; /* zlib return code */
-#if PNG_ZLIB_VERNUM >= 0x1240
+#if ZLIB_VERNUM >= 0x1240
+      int window_bits = 0;
 
 # if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
-      int window_bits;
-
       if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
           PNG_OPTION_ON)
       {
@@ -412,13 +411,11 @@
 
       else
       {
-         window_bits = 0;
          png_ptr->zstream_start = 1;
       }
-# else
-#   define window_bits 0
 # endif
-#endif
+
+#endif /* ZLIB_VERNUM >= 0x1240 */
 
       /* Set this for safety, just in case the previous owner left pointers to
        * memory allocations.
@@ -430,25 +427,32 @@
 
       if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
       {
-#if PNG_ZLIB_VERNUM < 0x1240
+#if ZLIB_VERNUM >= 0x1240
+         ret = inflateReset2(&png_ptr->zstream, window_bits);
+#else
          ret = inflateReset(&png_ptr->zstream);
-#else
-         ret = inflateReset2(&png_ptr->zstream, window_bits);
 #endif
       }
 
       else
       {
-#if PNG_ZLIB_VERNUM < 0x1240
+#if ZLIB_VERNUM >= 0x1240
+         ret = inflateInit2(&png_ptr->zstream, window_bits);
+#else
          ret = inflateInit(&png_ptr->zstream);
-#else
-         ret = inflateInit2(&png_ptr->zstream, window_bits);
 #endif
 
          if (ret == Z_OK)
             png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
       }
 
+#if ZLIB_VERNUM >= 0x1281 && \
+   defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
+      if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
+         /* Turn off validation of the ADLER32 checksum in IDAT chunks */
+         ret = inflateValidate(&png_ptr->zstream, 0);
+#endif
+
       if (ret == Z_OK)
          png_ptr->zowner = owner;
 
@@ -463,7 +467,7 @@
 #endif
 }
 
-#if PNG_ZLIB_VERNUM >= 0x1240
+#if ZLIB_VERNUM >= 0x1240
 /* Handle the start of the inflate stream if we called inflateInit2(strm,0);
  * in this case some zlib versions skip validation of the CINFO field and, in
  * certain circumstances, libpng may end up displaying an invalid image, in
@@ -489,6 +493,7 @@
 #endif /* Zlib >= 1.2.4 */
 
 #ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
+#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED)
 /* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
  * allow the caller to do multiple calls if required.  If the 'finish' flag is
  * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
@@ -627,9 +632,9 @@
  */
 static int
 png_decompress_chunk(png_structrp png_ptr,
-   png_uint_32 chunklength, png_uint_32 prefix_size,
-   png_alloc_size_t *newlength /* must be initialized to the maximum! */,
-   int terminate /*add a '\0' to the end of the uncompressed data*/)
+    png_uint_32 chunklength, png_uint_32 prefix_size,
+    png_alloc_size_t *newlength /* must be initialized to the maximum! */,
+    int terminate /*add a '\0' to the end of the uncompressed data*/)
 {
    /* TODO: implement different limits for different types of chunk.
     *
@@ -666,8 +671,8 @@
          png_uint_32 lzsize = chunklength - prefix_size;
 
          ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
-            /* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
-            /* output: */ NULL, newlength);
+             /* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
+             /* output: */ NULL, newlength);
 
          if (ret == Z_STREAM_END)
          {
@@ -687,15 +692,15 @@
                 */
                png_alloc_size_t new_size = *newlength;
                png_alloc_size_t buffer_size = prefix_size + new_size +
-                  (terminate != 0);
+                   (terminate != 0);
                png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr,
-                  buffer_size));
+                   buffer_size));
 
                if (text != NULL)
                {
                   ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
-                     png_ptr->read_buffer + prefix_size, &lzsize,
-                     text + prefix_size, newlength);
+                      png_ptr->read_buffer + prefix_size, &lzsize,
+                      text + prefix_size, newlength);
 
                   if (ret == Z_STREAM_END)
                   {
@@ -740,7 +745,7 @@
                    * the extra space may otherwise be used as a Trojan Horse.
                    */
                   if (ret == Z_STREAM_END &&
-                     chunklength - prefix_size != lzsize)
+                      chunklength - prefix_size != lzsize)
                      png_chunk_benign_error(png_ptr, "extra compressed data");
                }
 
@@ -782,6 +787,7 @@
       return Z_MEM_ERROR;
    }
 }
+#endif /* READ_zTXt || READ_iTXt */
 #endif /* READ_COMPRESSED_TEXT */
 
 #ifdef PNG_READ_iCCP_SUPPORTED
@@ -790,8 +796,8 @@
  */
 static int
 png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
-   png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
-   int finish)
+    png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
+    int finish)
 {
    if (png_ptr->zowner == png_ptr->chunk_name)
    {
@@ -830,8 +836,8 @@
           * the available output is produced; this allows reading of truncated
           * streams.
           */
-         ret = PNG_INFLATE(png_ptr,
-            *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
+         ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ?
+             Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
       }
       while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
 
@@ -849,7 +855,7 @@
       return Z_STREAM_ERROR;
    }
 }
-#endif
+#endif /* READ_iCCP */
 
 /* Read and check the IDHR chunk */
 
@@ -1037,7 +1043,7 @@
    if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
 #endif
    {
-      png_crc_finish(png_ptr, (int) length - num * 3);
+      png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
    }
 
 #ifndef PNG_READ_OPT_PLTE_SUPPORTED
@@ -1320,7 +1326,7 @@
 
    png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
    (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,
-      1/*prefer cHRM values*/);
+       1/*prefer cHRM values*/);
    png_colorspace_sync(png_ptr, info_ptr);
 }
 #endif
@@ -1460,8 +1466,8 @@
                png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);
                png_ptr->zstream.avail_in = read_length;
                (void)png_inflate_read(png_ptr, local_buffer,
-                  (sizeof local_buffer), &length, profile_header, &size,
-                  0/*finish: don't, because the output is too small*/);
+                   (sizeof local_buffer), &length, profile_header, &size,
+                   0/*finish: don't, because the output is too small*/);
 
                if (size == 0)
                {
@@ -1471,14 +1477,14 @@
                      png_get_uint_32(profile_header);
 
                   if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
-                     keyword, profile_length) != 0)
+                      keyword, profile_length) != 0)
                   {
                      /* The length is apparently ok, so we can check the 132
                       * byte header.
                       */
                      if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
-                        keyword, profile_length, profile_header,
-                        png_ptr->color_type) != 0)
+                         keyword, profile_length, profile_header,
+                         png_ptr->color_type) != 0)
                      {
                         /* Now read the tag table; a variable size buffer is
                          * needed at this point, allocate one for the whole
@@ -1486,20 +1492,20 @@
                          * that none of these stuff will overflow.
                          */
                         const png_uint_32 tag_count = png_get_uint_32(
-                           profile_header+128);
+                            profile_header+128);
                         png_bytep profile = png_read_buffer(png_ptr,
-                           profile_length, 2/*silent*/);
+                            profile_length, 2/*silent*/);
 
                         if (profile != NULL)
                         {
                            memcpy(profile, profile_header,
-                              (sizeof profile_header));
+                               (sizeof profile_header));
 
                            size = 12 * tag_count;
 
                            (void)png_inflate_read(png_ptr, local_buffer,
-                              (sizeof local_buffer), &length,
-                              profile + (sizeof profile_header), &size, 0);
+                               (sizeof local_buffer), &length,
+                               profile + (sizeof profile_header), &size, 0);
 
                            /* Still expect a buffer error because we expect
                             * there to be some tag data!
@@ -1507,22 +1513,22 @@
                            if (size == 0)
                            {
                               if (png_icc_check_tag_table(png_ptr,
-                                 &png_ptr->colorspace, keyword, profile_length,
-                                 profile) != 0)
+                                  &png_ptr->colorspace, keyword, profile_length,
+                                  profile) != 0)
                               {
                                  /* The profile has been validated for basic
                                   * security issues, so read the whole thing in.
                                   */
                                  size = profile_length - (sizeof profile_header)
-                                    - 12 * tag_count;
+                                     - 12 * tag_count;
 
                                  (void)png_inflate_read(png_ptr, local_buffer,
-                                    (sizeof local_buffer), &length,
-                                    profile + (sizeof profile_header) +
-                                    12 * tag_count, &size, 1/*finish*/);
+                                     (sizeof local_buffer), &length,
+                                     profile + (sizeof profile_header) +
+                                     12 * tag_count, &size, 1/*finish*/);
 
                                  if (length > 0 && !(png_ptr->flags &
-                                       PNG_FLAG_BENIGN_ERRORS_WARN))
+                                     PNG_FLAG_BENIGN_ERRORS_WARN))
                                     errmsg = "extra compressed data";
 
                                  /* But otherwise allow extra data: */
@@ -1534,34 +1540,34 @@
                                         * keep going.
                                         */
                                        png_chunk_warning(png_ptr,
-                                          "extra compressed data");
+                                           "extra compressed data");
                                     }
 
                                     png_crc_finish(png_ptr, length);
                                     finished = 1;
 
-#                                   ifdef PNG_sRGB_SUPPORTED
+# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
                                     /* Check for a match against sRGB */
                                     png_icc_set_sRGB(png_ptr,
-                                       &png_ptr->colorspace, profile,
-                                       png_ptr->zstream.adler);
-#                                   endif
+                                        &png_ptr->colorspace, profile,
+                                        png_ptr->zstream.adler);
+# endif
 
                                     /* Steal the profile for info_ptr. */
                                     if (info_ptr != NULL)
                                     {
                                        png_free_data(png_ptr, info_ptr,
-                                          PNG_FREE_ICCP, 0);
+                                           PNG_FREE_ICCP, 0);
 
                                        info_ptr->iccp_name = png_voidcast(char*,
-                                          png_malloc_base(png_ptr,
-                                          keyword_length+1));
+                                           png_malloc_base(png_ptr,
+                                           keyword_length+1));
                                        if (info_ptr->iccp_name != NULL)
                                        {
                                           memcpy(info_ptr->iccp_name, keyword,
-                                             keyword_length+1);
+                                              keyword_length+1);
                                           info_ptr->iccp_proflen =
-                                             profile_length;
+                                              profile_length;
                                           info_ptr->iccp_profile = profile;
                                           png_ptr->read_buffer = NULL; /*steal*/
                                           info_ptr->free_me |= PNG_FREE_ICCP;
@@ -1743,13 +1749,13 @@
    data_length = length - (png_uint_32)(entry_start - buffer);
 
    /* Integrity-check the data length */
-   if ((data_length % entry_size) != 0)
+   if ((data_length % (unsigned int)entry_size) != 0)
    {
       png_warning(png_ptr, "sPLT chunk has bad length");
       return;
    }
 
-   dl = (png_int_32)(data_length / entry_size);
+   dl = (png_uint_32)(data_length / (unsigned int)entry_size);
    max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
 
    if (dl > max_dl)
@@ -1758,10 +1764,10 @@
       return;
    }
 
-   new_palette.nentries = (png_int_32)(data_length / entry_size);
-
-   new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
-       png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry)));
+   new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
+
+   new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
+       (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry)));
 
    if (new_palette.entries == NULL)
    {
@@ -2298,7 +2304,7 @@
    }
 
    png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,
-      (png_charp)units, params);
+       (png_charp)units, params);
 
    png_free(png_ptr, params);
 }
@@ -2341,7 +2347,7 @@
    }
 
    png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
-      length + 1);
+       length + 1);
 
    buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
 
@@ -2393,7 +2399,7 @@
       else
          /* This is the (only) success case. */
          png_set_sCAL_s(png_ptr, info_ptr, buffer[0],
-            (png_charp)buffer+1, (png_charp)buffer+heighti);
+             (png_charp)buffer+1, (png_charp)buffer+heighti);
    }
 }
 #endif
@@ -2493,8 +2499,8 @@
 
    if (buffer == NULL)
    {
-     png_chunk_benign_error(png_ptr, "out of memory");
-     return;
+      png_chunk_benign_error(png_ptr, "out of memory");
+      return;
    }
 
    png_crc_read(png_ptr, buffer, length);
@@ -2601,7 +2607,7 @@
        * and text chunks.
        */
       if (png_decompress_chunk(png_ptr, length, keyword_length+2,
-         &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
+          &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
       {
          png_text text;
 
@@ -2741,7 +2747,7 @@
           * iCCP and text chunks.
           */
          if (png_decompress_chunk(png_ptr, length, prefix_length,
-            &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
+             &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
             buffer = png_ptr->read_buffer;
 
          else
@@ -2821,7 +2827,7 @@
       {
          /* Do a 'warn' here - it is handled below. */
          png_ptr->unknown_chunk.data = png_voidcast(png_bytep,
-            png_malloc_warn(png_ptr, length));
+             png_malloc_warn(png_ptr, length));
       }
    }
 
@@ -2846,7 +2852,7 @@
 /* Handle an unknown, or known but disabled, chunk */
 void /* PRIVATE */
 png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
-   png_uint_32 length, int keep)
+    png_uint_32 length, int keep)
 {
    int handled = 0; /* the chunk was handled */
 
@@ -2884,7 +2890,7 @@
       {
          /* Callback to user unknown chunk handler */
          int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,
-            &png_ptr->unknown_chunk);
+             &png_ptr->unknown_chunk);
 
          /* ret is:
           * negative: An error occurred; png_chunk_error will be called.
@@ -2918,9 +2924,9 @@
                {
                   png_chunk_warning(png_ptr, "Saving unknown chunk:");
                   png_app_warning(png_ptr,
-                     "forcing save of an unhandled chunk;"
-                     " please call png_set_keep_unknown_chunks");
-                     /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
+                      "forcing save of an unhandled chunk;"
+                      " please call png_set_keep_unknown_chunks");
+                      /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
                }
 #              endif
                keep = PNG_HANDLE_CHUNK_IF_SAFE;
@@ -3013,7 +3019,7 @@
              * out; store the chunk.
              */
             png_set_unknown_chunks(png_ptr, info_ptr,
-               &png_ptr->unknown_chunk, 1);
+                &png_ptr->unknown_chunk, 1);
             handled = 1;
 #  ifdef PNG_USER_LIMITS_SUPPORTED
             break;
@@ -3125,7 +3131,7 @@
 #     ifdef PNG_READ_PACKSWAP_SUPPORTED
       if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
          /* little-endian byte */
-         end_mask = 0xff << end_mask;
+         end_mask = (unsigned int)(0xff << end_mask);
 
       else /* big-endian byte */
 #     endif
@@ -3446,8 +3452,8 @@
                   /* Everything is aligned for png_uint_16 copies, but try for
                    * png_uint_32 first.
                    */
-                  if (png_isaligned(dp, png_uint_32) != 0 &&
-                      png_isaligned(sp, png_uint_32) != 0 &&
+                  if (png_isaligned(dp, png_uint_32) &&
+                      png_isaligned(sp, png_uint_32) &&
                       bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
                       bytes_to_jump % (sizeof (png_uint_32)) == 0)
                   {
@@ -3567,11 +3573,11 @@
 #ifdef PNG_READ_INTERLACING_SUPPORTED
 void /* PRIVATE */
 png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
-   png_uint_32 transformations /* Because these may affect the byte layout */)
+    png_uint_32 transformations /* Because these may affect the byte layout */)
 {
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    /* Offset to next interlace block */
-   static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_read_interlace");
    if (row != NULL && row_info != NULL)
@@ -3586,9 +3592,10 @@
          {
             png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
             png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
-            int sshift, dshift;
-            int s_start, s_end, s_inc;
-            int jstop = png_pass_inc[pass];
+            unsigned int sshift, dshift;
+            unsigned int s_start, s_end;
+            int s_inc;
+            int jstop = (int)png_pass_inc[pass];
             png_byte v;
             png_uint_32 i;
             int j;
@@ -3596,8 +3603,8 @@
 #ifdef PNG_READ_PACKSWAP_SUPPORTED
             if ((transformations & PNG_PACKSWAP) != 0)
             {
-                sshift = (int)((row_info->width + 7) & 0x07);
-                dshift = (int)((final_width + 7) & 0x07);
+                sshift = ((row_info->width + 7) & 0x07);
+                dshift = ((final_width + 7) & 0x07);
                 s_start = 7;
                 s_end = 0;
                 s_inc = -1;
@@ -3606,8 +3613,8 @@
             else
 #endif
             {
-                sshift = 7 - (int)((row_info->width + 7) & 0x07);
-                dshift = 7 - (int)((final_width + 7) & 0x07);
+                sshift = 7 - ((row_info->width + 7) & 0x07);
+                dshift = 7 - ((final_width + 7) & 0x07);
                 s_start = 0;
                 s_end = 7;
                 s_inc = 1;
@@ -3619,7 +3626,7 @@
                for (j = 0; j < jstop; j++)
                {
                   unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
-                  tmp |= v << dshift;
+                  tmp |= (unsigned int)(v << dshift);
                   *dp = (png_byte)(tmp & 0xff);
 
                   if (dshift == s_end)
@@ -3629,7 +3636,7 @@
                   }
 
                   else
-                     dshift += s_inc;
+                     dshift = (unsigned int)((int)dshift + s_inc);
                }
 
                if (sshift == s_end)
@@ -3639,7 +3646,7 @@
                }
 
                else
-                  sshift += s_inc;
+                  sshift = (unsigned int)((int)sshift + s_inc);
             }
             break;
          }
@@ -3648,16 +3655,17 @@
          {
             png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
             png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
-            int sshift, dshift;
-            int s_start, s_end, s_inc;
-            int jstop = png_pass_inc[pass];
+            unsigned int sshift, dshift;
+            unsigned int s_start, s_end;
+            int s_inc;
+            int jstop = (int)png_pass_inc[pass];
             png_uint_32 i;
 
 #ifdef PNG_READ_PACKSWAP_SUPPORTED
             if ((transformations & PNG_PACKSWAP) != 0)
             {
-               sshift = (int)(((row_info->width + 3) & 0x03) << 1);
-               dshift = (int)(((final_width + 3) & 0x03) << 1);
+               sshift = (((row_info->width + 3) & 0x03) << 1);
+               dshift = (((final_width + 3) & 0x03) << 1);
                s_start = 6;
                s_end = 0;
                s_inc = -2;
@@ -3666,8 +3674,8 @@
             else
 #endif
             {
-               sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
-               dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
+               sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
+               dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
                s_start = 0;
                s_end = 6;
                s_inc = 2;
@@ -3682,7 +3690,7 @@
                for (j = 0; j < jstop; j++)
                {
                   unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
-                  tmp |= v << dshift;
+                  tmp |= (unsigned int)(v << dshift);
                   *dp = (png_byte)(tmp & 0xff);
 
                   if (dshift == s_end)
@@ -3692,7 +3700,7 @@
                   }
 
                   else
-                     dshift += s_inc;
+                     dshift = (unsigned int)((int)dshift + s_inc);
                }
 
                if (sshift == s_end)
@@ -3702,7 +3710,7 @@
                }
 
                else
-                  sshift += s_inc;
+                  sshift = (unsigned int)((int)sshift + s_inc);
             }
             break;
          }
@@ -3711,16 +3719,17 @@
          {
             png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
             png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
-            int sshift, dshift;
-            int s_start, s_end, s_inc;
+            unsigned int sshift, dshift;
+            unsigned int s_start, s_end;
+            int s_inc;
             png_uint_32 i;
-            int jstop = png_pass_inc[pass];
+            int jstop = (int)png_pass_inc[pass];
 
 #ifdef PNG_READ_PACKSWAP_SUPPORTED
             if ((transformations & PNG_PACKSWAP) != 0)
             {
-               sshift = (int)(((row_info->width + 1) & 0x01) << 2);
-               dshift = (int)(((final_width + 1) & 0x01) << 2);
+               sshift = (((row_info->width + 1) & 0x01) << 2);
+               dshift = (((final_width + 1) & 0x01) << 2);
                s_start = 4;
                s_end = 0;
                s_inc = -4;
@@ -3729,8 +3738,8 @@
             else
 #endif
             {
-               sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
-               dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
+               sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
+               dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
                s_start = 0;
                s_end = 4;
                s_inc = 4;
@@ -3744,7 +3753,7 @@
                for (j = 0; j < jstop; j++)
                {
                   unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
-                  tmp |= v << dshift;
+                  tmp |= (unsigned int)(v << dshift);
                   *dp = (png_byte)(tmp & 0xff);
 
                   if (dshift == s_end)
@@ -3754,7 +3763,7 @@
                   }
 
                   else
-                     dshift += s_inc;
+                     dshift = (unsigned int)((int)dshift + s_inc);
                }
 
                if (sshift == s_end)
@@ -3764,7 +3773,7 @@
                }
 
                else
-                  sshift += s_inc;
+                  sshift = (unsigned int)((int)sshift + s_inc);
             }
             break;
          }
@@ -3778,7 +3787,7 @@
 
             png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
 
-            int jstop = png_pass_inc[pass];
+            int jstop = (int)png_pass_inc[pass];
             png_uint_32 i;
 
             for (i = 0; i < row_info->width; i++)
@@ -3811,7 +3820,7 @@
 
 static void
 png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row)
+    png_const_bytep prev_row)
 {
    png_size_t i;
    png_size_t istop = row_info->rowbytes;
@@ -3829,7 +3838,7 @@
 
 static void
 png_read_filter_row_up(png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row)
+    png_const_bytep prev_row)
 {
    png_size_t i;
    png_size_t istop = row_info->rowbytes;
@@ -3845,7 +3854,7 @@
 
 static void
 png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row)
+    png_const_bytep prev_row)
 {
    png_size_t i;
    png_bytep rp = row;
@@ -3872,7 +3881,7 @@
 
 static void
 png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row)
+    png_const_bytep prev_row)
 {
    png_bytep rp_end = row + row_info->rowbytes;
    int a, c;
@@ -3920,9 +3929,9 @@
 
 static void
 png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row)
+    png_const_bytep prev_row)
 {
-   int bpp = (row_info->pixel_depth + 7) >> 3;
+   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
    png_bytep rp_end = row + bpp;
 
    /* Process the first pixel in the row completely (this is the same as 'up'
@@ -3935,7 +3944,7 @@
    }
 
    /* Remainder */
-   rp_end += row_info->rowbytes - bpp;
+   rp_end = rp_end + (row_info->rowbytes - bpp);
 
    while (row < rp_end)
    {
@@ -4005,7 +4014,7 @@
 
 void /* PRIVATE */
 png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,
-   png_const_bytep prev_row, int filter)
+    png_const_bytep prev_row, int filter)
 {
    /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define
     * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic
@@ -4023,7 +4032,7 @@
 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
 void /* PRIVATE */
 png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
-   png_alloc_size_t avail_out)
+    png_alloc_size_t avail_out)
 {
    /* Loop reading IDATs and decompressing the result into output[avail_out] */
    png_ptr->zstream.next_out = output;
@@ -4280,7 +4289,7 @@
    /* Offset to next interlace block in the y direction */
    static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 
-   int max_pixel_depth;
+   unsigned int max_pixel_depth;
    png_size_t row_bytes;
 
    png_debug(1, "in png_read_start_row");
@@ -4309,7 +4318,7 @@
       png_ptr->iwidth = png_ptr->width;
    }
 
-   max_pixel_depth = png_ptr->pixel_depth;
+   max_pixel_depth = (unsigned int)png_ptr->pixel_depth;
 
    /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
     * calculations to calculate the final pixel depth, then
@@ -4444,7 +4453,7 @@
 defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
    {
-      int user_pixel_depth = png_ptr->user_transform_depth *
+      unsigned int user_pixel_depth = png_ptr->user_transform_depth *
          png_ptr->user_transform_channels;
 
       if (user_pixel_depth > max_pixel_depth)
@@ -4466,7 +4475,7 @@
     * for safety's sake
     */
    row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
-       1 + ((max_pixel_depth + 7) >> 3);
+       1 + ((max_pixel_depth + 7) >> 3U);
 
 #ifdef PNG_MAX_MALLOC_64K
    if (row_bytes > (png_uint_32)65536L)
@@ -4475,42 +4484,42 @@
 
    if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
    {
-     png_free(png_ptr, png_ptr->big_row_buf);
-     png_free(png_ptr, png_ptr->big_prev_row);
-
-     if (png_ptr->interlaced != 0)
-        png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,
-            row_bytes + 48);
-
-     else
-        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
-
-     png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
+      png_free(png_ptr, png_ptr->big_row_buf);
+      png_free(png_ptr, png_ptr->big_prev_row);
+
+      if (png_ptr->interlaced != 0)
+         png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,
+             row_bytes + 48);
+
+      else
+         png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
+
+      png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
 
 #ifdef PNG_ALIGNED_MEMORY_SUPPORTED
-     /* Use 16-byte aligned memory for row_buf with at least 16 bytes
-      * of padding before and after row_buf; treat prev_row similarly.
-      * NOTE: the alignment is to the start of the pixels, one beyond the start
-      * of the buffer, because of the filter byte.  Prior to libpng 1.5.6 this
-      * was incorrect; the filter byte was aligned, which had the exact
-      * opposite effect of that intended.
-      */
-     {
-        png_bytep temp = png_ptr->big_row_buf + 32;
-        int extra = (int)((temp - (png_bytep)0) & 0x0f);
-        png_ptr->row_buf = temp - extra - 1/*filter byte*/;
-
-        temp = png_ptr->big_prev_row + 32;
-        extra = (int)((temp - (png_bytep)0) & 0x0f);
-        png_ptr->prev_row = temp - extra - 1/*filter byte*/;
-     }
+      /* Use 16-byte aligned memory for row_buf with at least 16 bytes
+       * of padding before and after row_buf; treat prev_row similarly.
+       * NOTE: the alignment is to the start of the pixels, one beyond the start
+       * of the buffer, because of the filter byte.  Prior to libpng 1.5.6 this
+       * was incorrect; the filter byte was aligned, which had the exact
+       * opposite effect of that intended.
+       */
+      {
+         png_bytep temp = png_ptr->big_row_buf + 32;
+         int extra = (int)((temp - (png_bytep)0) & 0x0f);
+         png_ptr->row_buf = temp - extra - 1/*filter byte*/;
+
+         temp = png_ptr->big_prev_row + 32;
+         extra = (int)((temp - (png_bytep)0) & 0x0f);
+         png_ptr->prev_row = temp - extra - 1/*filter byte*/;
+      }
 
 #else
-     /* Use 31 bytes of padding before and 17 bytes after row_buf. */
-     png_ptr->row_buf = png_ptr->big_row_buf + 31;
-     png_ptr->prev_row = png_ptr->big_prev_row + 31;
+      /* Use 31 bytes of padding before and 17 bytes after row_buf. */
+      png_ptr->row_buf = png_ptr->big_row_buf + 31;
+      png_ptr->prev_row = png_ptr->big_prev_row + 31;
 #endif
-     png_ptr->old_big_row_buf_size = row_bytes + 48;
+      png_ptr->old_big_row_buf_size = row_bytes + 48;
    }
 
 #ifdef PNG_MAX_MALLOC_64K
@@ -4535,7 +4544,7 @@
     * does not, so free the read buffer now regardless; the sequential reader
     * reallocates it on demand.
     */
-   if (png_ptr->read_buffer != 0)
+   if (png_ptr->read_buffer != NULL)
    {
       png_bytep buffer = png_ptr->read_buffer;
 
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,7 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.23 [June 9, 2016]
+ * Last changed in libpng 1.6.26 [October 20, 2016]
  * Copyright (c) 1998-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -132,14 +132,14 @@
     double green_x, double green_y, double blue_x, double blue_y)
 {
    png_set_cHRM_fixed(png_ptr, info_ptr,
-      png_fixed(png_ptr, white_x, "cHRM White X"),
-      png_fixed(png_ptr, white_y, "cHRM White Y"),
-      png_fixed(png_ptr, red_x, "cHRM Red X"),
-      png_fixed(png_ptr, red_y, "cHRM Red Y"),
-      png_fixed(png_ptr, green_x, "cHRM Green X"),
-      png_fixed(png_ptr, green_y, "cHRM Green Y"),
-      png_fixed(png_ptr, blue_x, "cHRM Blue X"),
-      png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
+       png_fixed(png_ptr, white_x, "cHRM White X"),
+       png_fixed(png_ptr, white_y, "cHRM White Y"),
+       png_fixed(png_ptr, red_x, "cHRM Red X"),
+       png_fixed(png_ptr, red_y, "cHRM Red Y"),
+       png_fixed(png_ptr, green_x, "cHRM Green X"),
+       png_fixed(png_ptr, green_y, "cHRM Green Y"),
+       png_fixed(png_ptr, blue_x, "cHRM Blue X"),
+       png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
 }
 
 void PNGAPI
@@ -148,15 +148,15 @@
     double blue_X, double blue_Y, double blue_Z)
 {
    png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
-      png_fixed(png_ptr, red_X, "cHRM Red X"),
-      png_fixed(png_ptr, red_Y, "cHRM Red Y"),
-      png_fixed(png_ptr, red_Z, "cHRM Red Z"),
-      png_fixed(png_ptr, green_X, "cHRM Green X"),
-      png_fixed(png_ptr, green_Y, "cHRM Green Y"),
-      png_fixed(png_ptr, green_Z, "cHRM Green Z"),
-      png_fixed(png_ptr, blue_X, "cHRM Blue X"),
-      png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
-      png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
+       png_fixed(png_ptr, red_X, "cHRM Red X"),
+       png_fixed(png_ptr, red_Y, "cHRM Red Y"),
+       png_fixed(png_ptr, red_Z, "cHRM Red Z"),
+       png_fixed(png_ptr, green_X, "cHRM Green X"),
+       png_fixed(png_ptr, green_Y, "cHRM Green Y"),
+       png_fixed(png_ptr, green_Z, "cHRM Green Z"),
+       png_fixed(png_ptr, blue_X, "cHRM Blue X"),
+       png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
+       png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
 }
 #  endif /* FLOATING_POINT */
 
@@ -311,17 +311,29 @@
 
    /* Check that the type matches the specification. */
    if (type < 0 || type > 3)
-      png_error(png_ptr, "Invalid pCAL equation type");
+   {
+      png_chunk_report(png_ptr, "Invalid pCAL equation type",
+            PNG_CHUNK_WRITE_ERROR);
+      return;
+   }
 
    if (nparams < 0 || nparams > 255)
-      png_error(png_ptr, "Invalid pCAL parameter count");
+   {
+      png_chunk_report(png_ptr, "Invalid pCAL parameter count",
+            PNG_CHUNK_WRITE_ERROR);
+      return;
+   }
 
    /* Validate params[nparams] */
    for (i=0; i<nparams; ++i)
    {
       if (params[i] == NULL ||
           !png_check_fp_string(params[i], strlen(params[i])))
-         png_error(png_ptr, "Invalid format for pCAL parameter");
+      {
+         png_chunk_report(png_ptr, "Invalid format for pCAL parameter",
+               PNG_CHUNK_WRITE_ERROR);
+         return;
+      }
    }
 
    info_ptr->pcal_purpose = png_voidcast(png_charp,
@@ -329,8 +341,8 @@
 
    if (info_ptr->pcal_purpose == NULL)
    {
-      png_warning(png_ptr, "Insufficient memory for pCAL purpose");
-
+      png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose",
+            PNG_CHUNK_WRITE_ERROR);
       return;
    }
 
@@ -344,10 +356,10 @@
 
    length = strlen(units) + 1;
    png_debug1(3, "allocating units for info (%lu bytes)",
-     (unsigned long)length);
+       (unsigned long)length);
 
    info_ptr->pcal_units = png_voidcast(png_charp,
-      png_malloc_warn(png_ptr, length));
+       png_malloc_warn(png_ptr, length));
 
    if (info_ptr->pcal_units == NULL)
    {
@@ -359,7 +371,7 @@
    memcpy(info_ptr->pcal_units, units, length);
 
    info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
-       (png_size_t)((nparams + 1) * (sizeof (png_charp)))));
+       (png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
 
    if (info_ptr->pcal_params == NULL)
    {
@@ -368,7 +380,8 @@
       return;
    }
 
-   memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
+   memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
+       (sizeof (png_charp)));
 
    for (i = 0; i < nparams; i++)
    {
@@ -426,7 +439,7 @@
    png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
 
    info_ptr->scal_s_width = png_voidcast(png_charp,
-      png_malloc_warn(png_ptr, lengthw));
+       png_malloc_warn(png_ptr, lengthw));
 
    if (info_ptr->scal_s_width == NULL)
    {
@@ -442,7 +455,7 @@
    png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
 
    info_ptr->scal_s_height = png_voidcast(png_charp,
-      png_malloc_warn(png_ptr, lengthh));
+       png_malloc_warn(png_ptr, lengthh));
 
    if (info_ptr->scal_s_height == NULL)
    {
@@ -481,9 +494,9 @@
       char sheight[PNG_sCAL_MAX_DIGITS+1];
 
       png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
-         PNG_sCAL_PRECISION);
+          PNG_sCAL_PRECISION);
       png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
-         PNG_sCAL_PRECISION);
+          PNG_sCAL_PRECISION);
 
       png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
    }
@@ -591,7 +604,8 @@
        PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
 
    if (num_palette > 0)
-      memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
+      memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
+          (sizeof (png_color)));
    info_ptr->palette = png_ptr->palette;
    info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
 
@@ -676,7 +690,7 @@
     */
    {
       int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
-         proflen, profile, info_ptr->color_type);
+          proflen, profile, info_ptr->color_type);
 
       png_colorspace_sync_info(png_ptr, info_ptr);
 
@@ -701,7 +715,7 @@
 
    memcpy(new_iccp_name, name, length);
    new_iccp_profile = png_voidcast(png_bytep,
-      png_malloc_warn(png_ptr, proflen));
+       png_malloc_warn(png_ptr, proflen));
 
    if (new_iccp_profile == NULL)
    {
@@ -776,14 +790,14 @@
           * the overflow checks.
           */
          new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
-            info_ptr->text, old_num_text, max_text-old_num_text,
-            sizeof *new_text));
+             info_ptr->text, old_num_text, max_text-old_num_text,
+             sizeof *new_text));
       }
 
       if (new_text == NULL)
       {
          png_chunk_report(png_ptr, "too many text chunks",
-            PNG_CHUNK_WRITE_ERROR);
+             PNG_CHUNK_WRITE_ERROR);
 
          return 1;
       }
@@ -811,7 +825,7 @@
           text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
       {
          png_chunk_report(png_ptr, "text compression mode is out of range",
-            PNG_CHUNK_WRITE_ERROR);
+             PNG_CHUNK_WRITE_ERROR);
          continue;
       }
 
@@ -843,7 +857,7 @@
 #  else /* iTXt */
       {
          png_chunk_report(png_ptr, "iTXt chunk not supported",
-            PNG_CHUNK_WRITE_ERROR);
+             PNG_CHUNK_WRITE_ERROR);
          continue;
       }
 #  endif
@@ -872,7 +886,7 @@
       if (textp->key == NULL)
       {
          png_chunk_report(png_ptr, "text chunk: out of memory",
-               PNG_CHUNK_WRITE_ERROR);
+             PNG_CHUNK_WRITE_ERROR);
 
          return 1;
       }
@@ -984,7 +998,7 @@
        {
          /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
           info_ptr->trans_alpha = png_voidcast(png_bytep,
-             png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
+              png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
           memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
        }
        png_ptr->trans_alpha = info_ptr->trans_alpha;
@@ -1004,7 +1018,7 @@
              trans_color->green > sample_max ||
              trans_color->blue > sample_max)))
             png_warning(png_ptr,
-               "tRNS chunk has out-of-range samples for bit_depth");
+                "tRNS chunk has out-of-range samples for bit_depth");
       }
 #endif
 
@@ -1046,8 +1060,8 @@
     * overflows.  Notice that the parameters are (int) and (size_t)
     */
    np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
-      info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
-      sizeof *np));
+       info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
+       sizeof *np));
 
    if (np == NULL)
    {
@@ -1108,7 +1122,7 @@
        * checked it when doing the allocation.
        */
       memcpy(np->entries, entries->entries,
-         entries->nentries * sizeof (png_sPLT_entry));
+          (unsigned int)entries->nentries * sizeof (png_sPLT_entry));
 
       /* Note that 'continue' skips the advance of the out pointer and out
        * count, so an invalid entry is not added.
@@ -1138,10 +1152,10 @@
    {
       /* Write struct, so unknown chunks come from the app */
       png_app_warning(png_ptr,
-         "png_set_unknown_chunks now expects a valid location");
+          "png_set_unknown_chunks now expects a valid location");
       /* Use the old behavior */
       location = (png_byte)(png_ptr->mode &
-         (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
+          (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
    }
 
    /* This need not be an internal error - if the app calls
@@ -1164,7 +1178,7 @@
 
 void PNGAPI
 png_set_unknown_chunks(png_const_structrp png_ptr,
-   png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
+    png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
 {
    png_unknown_chunkp np;
 
@@ -1203,13 +1217,13 @@
     * appropriate to read or write.
     */
    np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr,
-         info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
-         sizeof *np));
+       info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
+       sizeof *np));
 
    if (np == NULL)
    {
       png_chunk_report(png_ptr, "too many unknown chunks",
-         PNG_CHUNK_WRITE_ERROR);
+          PNG_CHUNK_WRITE_ERROR);
 
       return;
    }
@@ -1238,12 +1252,12 @@
       else
       {
          np->data = png_voidcast(png_bytep,
-            png_malloc_base(png_ptr, unknowns->size));
+             png_malloc_base(png_ptr, unknowns->size));
 
          if (np->data == NULL)
          {
             png_chunk_report(png_ptr, "unknown chunk: out of memory",
-               PNG_CHUNK_WRITE_ERROR);
+                PNG_CHUNK_WRITE_ERROR);
             /* But just skip storing the unknown chunk */
             continue;
          }
@@ -1277,7 +1291,7 @@
       {
          png_app_error(png_ptr, "invalid unknown chunk location");
          /* Fake out the pre 1.6.0 behavior: */
-         if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
+         if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
             location = PNG_AFTER_IDAT;
 
          else
@@ -1401,7 +1415,7 @@
          return;
       }
 
-      num_chunks = num_chunks_in;
+      num_chunks = (unsigned int)num_chunks_in;
    }
 
    old_num_chunks = png_ptr->num_chunk_list;
@@ -1450,7 +1464,7 @@
       for (i=0; i<num_chunks; ++i)
       {
          old_num_chunks = add_one_chunk(new_list, old_num_chunks,
-            chunk_list+5*i, keep);
+             chunk_list+5*i, keep);
       }
 
       /* Now remove any spurious 'default' entries. */
@@ -1530,60 +1544,60 @@
 void PNGAPI
 png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
 {
-    if (png_ptr == NULL)
-       return;
+   if (png_ptr == NULL)
+      return;
 
-    if (size == 0 || size > PNG_UINT_31_MAX)
-       png_error(png_ptr, "invalid compression buffer size");
+   if (size == 0 || size > PNG_UINT_31_MAX)
+      png_error(png_ptr, "invalid compression buffer size");
 
 #  ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-      if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
-      {
-         png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
-         return;
-      }
+   if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
+   {
+      png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
+      return;
+   }
 #  endif
 
 #  ifdef PNG_WRITE_SUPPORTED
-      if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
+   if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
+   {
+      if (png_ptr->zowner != 0)
       {
-         if (png_ptr->zowner != 0)
-         {
-            png_warning(png_ptr,
-              "Compression buffer size cannot be changed because it is in use");
+         png_warning(png_ptr,
+             "Compression buffer size cannot be changed because it is in use");
 
-            return;
-         }
+         return;
+      }
 
 #ifndef __COVERITY__
-         /* Some compilers complain that this is always false.  However, it
-          * can be true when integer overflow happens.
-          */
-         if (size > ZLIB_IO_MAX)
-         {
-            png_warning(png_ptr,
-               "Compression buffer size limited to system maximum");
-            size = ZLIB_IO_MAX; /* must fit */
-         }
+      /* Some compilers complain that this is always false.  However, it
+       * can be true when integer overflow happens.
+       */
+      if (size > ZLIB_IO_MAX)
+      {
+         png_warning(png_ptr,
+             "Compression buffer size limited to system maximum");
+         size = ZLIB_IO_MAX; /* must fit */
+      }
 #endif
 
-         if (size < 6)
-         {
-            /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
-             * if this is permitted.
-             */
-            png_warning(png_ptr,
-               "Compression buffer size cannot be reduced below 6");
+      if (size < 6)
+      {
+         /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
+          * if this is permitted.
+          */
+         png_warning(png_ptr,
+             "Compression buffer size cannot be reduced below 6");
 
-            return;
-         }
+         return;
+      }
 
-         if (png_ptr->zbuffer_size != size)
-         {
-            png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
-            png_ptr->zbuffer_size = (uInt)size;
-         }
+      if (png_ptr->zbuffer_size != size)
+      {
+         png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
+         png_ptr->zbuffer_size = (uInt)size;
       }
+   }
 #  endif
 }
 
@@ -1591,7 +1605,7 @@
 png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
 {
    if (png_ptr != NULL && info_ptr != NULL)
-      info_ptr->valid &= ~mask;
+      info_ptr->valid &= (unsigned int)(~mask);
 }
 
 
@@ -1690,7 +1704,9 @@
 png_uint_32 /* PRIVATE */
 png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
 {
+#ifdef PNG_WARNINGS_SUPPORTED
    png_const_charp orig_key = key;
+#endif
    png_uint_32 key_len = 0;
    int bad_character = 0;
    int space = 1;
@@ -1753,7 +1769,9 @@
 
       png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
    }
-#endif /* WARNINGS */
+#else /* !WARNINGS */
+   PNG_UNUSED(png_ptr)
+#endif /* !WARNINGS */
 
    return key_len;
 }
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.18 [July 23, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.28 [January 5, 2017]
+ * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -277,7 +277,7 @@
    png_byte filter;           /* file filter type (always 0) */
    png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
    png_byte pass;             /* current interlace pass (0 - 6) */
-   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */
+   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ in png.h ) */
    png_byte color_type;       /* color type of file */
    png_byte bit_depth;        /* bit depth of file */
    png_byte usr_bit_depth;    /* bit depth of users row: write only */
@@ -291,7 +291,7 @@
                               /* pixel depth used for the row buffers */
    png_byte transformed_pixel_depth;
                               /* pixel depth after read/write transforms */
-#if PNG_ZLIB_VERNUM >= 0x1240
+#if ZLIB_VERNUM >= 0x1240
    png_byte zstream_start;    /* at start of an input zlib stream */
 #endif /* Zlib >= 1.2.4 */
 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
@@ -381,7 +381,7 @@
 
 /* Options */
 #ifdef PNG_SET_OPTION_SUPPORTED
-   png_byte options;           /* On/off state (up to 4 options) */
+   png_uint_32 options;           /* On/off state (up to 16 options) */
 #endif
 
 #if PNG_LIBPNG_VER < 10700
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtest.c	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2110 +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.
- */
-
-/* pngtest.c - a simple test program to test libpng
- *
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.5.25 [December 3, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This program reads in a PNG image, writes it out again, and then
- * compares the two files.  If the files are identical, this shows that
- * the basic chunk handling, filtering, and (de)compression code is working
- * properly.  It does not currently test all of the transforms, although
- * it probably should.
- *
- * The program will report "FAIL" in certain legitimate cases:
- * 1) when the compression level or filter selection method is changed.
- * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.
- * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks
- *    exist in the input file.
- * 4) others not listed here...
- * In these cases, it is best to check with another tool such as "pngcheck"
- * to see what the differences between the two files are.
- *
- * If a filename is given on the command-line, then this file is used
- * for the input, rather than the default "pngtest.png".  This allows
- * testing a wide variety of files easily.  You can also test a number
- * of files at once by typing "pngtest -m file1.png file2.png ..."
- */
-
-#define _POSIX_SOURCE 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Defined so I can write to a file on gui/windowing platforms */
-/*  #define STDERR stderr  */
-#define STDERR stdout   /* For DOS */
-
-#include "png.h"
-
-/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
- * a skipped test, in earlier versions we need to succeed on a skipped test, so:
- */
-#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
-#  define SKIP 77
-#else
-#  define SKIP 0
-#endif
-
-/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
- * simply as a result of re-ordering them.  This may be fixed in 1.7
- *
- * pngtest allocates a single row buffer for each row and overwrites it,
- * therefore if the write side doesn't support the writing of interlaced images
- * nothing can be done for an interlaced image (and the code below will fail
- * horribly trying to write extra data after writing garbage).
- */
-#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
-   defined PNG_READ_bKGD_SUPPORTED &&\
-   defined PNG_READ_cHRM_SUPPORTED &&\
-   defined PNG_READ_gAMA_SUPPORTED &&\
-   defined PNG_READ_oFFs_SUPPORTED &&\
-   defined PNG_READ_pCAL_SUPPORTED &&\
-   defined PNG_READ_pHYs_SUPPORTED &&\
-   defined PNG_READ_sBIT_SUPPORTED &&\
-   defined PNG_READ_sCAL_SUPPORTED &&\
-   defined PNG_READ_sRGB_SUPPORTED &&\
-   defined PNG_READ_sPLT_SUPPORTED &&\
-   defined PNG_READ_tEXt_SUPPORTED &&\
-   defined PNG_READ_tIME_SUPPORTED &&\
-   defined PNG_READ_zTXt_SUPPORTED &&\
-   (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700)
-
-#ifdef PNG_ZLIB_HEADER
-#  include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
-#else
-#  include "zlib.h"
-#endif
-
-/* Copied from pngpriv.h but only used in error messages below. */
-#ifndef PNG_ZBUF_SIZE
-#  define PNG_ZBUF_SIZE 8192
-#endif
-#define FCLOSE(file) fclose(file)
-
-#ifndef PNG_STDIO_SUPPORTED
-typedef FILE                * png_FILE_p;
-#endif
-
-/* Makes pngtest verbose so we can find problems. */
-#ifndef PNG_DEBUG
-#  define PNG_DEBUG 0
-#endif
-
-#if PNG_DEBUG > 1
-#  define pngtest_debug(m)        ((void)fprintf(stderr, m "\n"))
-#  define pngtest_debug1(m,p1)    ((void)fprintf(stderr, m "\n", p1))
-#  define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2))
-#else
-#  define pngtest_debug(m)        ((void)0)
-#  define pngtest_debug1(m,p1)    ((void)0)
-#  define pngtest_debug2(m,p1,p2) ((void)0)
-#endif
-
-#if !PNG_DEBUG
-#  define SINGLE_ROWBUF_ALLOC  /* Makes buffer overruns easier to nail */
-#endif
-
-#ifndef PNG_UNUSED
-#  define PNG_UNUSED(param) (void)param;
-#endif
-
-/* Turn on CPU timing
-#define PNGTEST_TIMING
-*/
-
-#ifndef PNG_FLOATING_POINT_SUPPORTED
-#undef PNGTEST_TIMING
-#endif
-
-#ifdef PNGTEST_TIMING
-static float t_start, t_stop, t_decode, t_encode, t_misc;
-#include <time.h>
-#endif
-
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-#define PNG_tIME_STRING_LENGTH 29
-static int tIME_chunk_present = 0;
-static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
-
-#if PNG_LIBPNG_VER < 10619
-#define png_convert_to_rfc1123_buffer(ts, t) tIME_to_str(read_ptr, ts, t)
-
-static int
-tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
-{
-    png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
-
-    if (str == NULL)
-        return 0;
-
-    strcpy(ts, str);
-    return 1;
-}
-#endif /* older libpng */
-#endif
-
-static int verbose = 0;
-static int strict = 0;
-static int relaxed = 0;
-static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
-static int error_count = 0; /* count calls to png_error */
-static int warning_count = 0; /* count calls to png_warning */
-
-/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
-#ifndef png_jmpbuf
-#  define png_jmpbuf(png_ptr) png_ptr->jmpbuf
-#endif
-
-/* Defines for unknown chunk handling if required. */
-#ifndef PNG_HANDLE_CHUNK_ALWAYS
-#  define PNG_HANDLE_CHUNK_ALWAYS       3
-#endif
-#ifndef PNG_HANDLE_CHUNK_IF_SAFE
-#  define PNG_HANDLE_CHUNK_IF_SAFE      2
-#endif
-
-/* Utility to save typing/errors, the argument must be a name */
-#define MEMZERO(var) ((void)memset(&var, 0, sizeof var))
-
-/* Example of using row callbacks to make a simple progress meter */
-static int status_pass = 1;
-static int status_dots_requested = 0;
-static int status_dots = 1;
-
-static void PNGCBAPI
-read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
-{
-   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
-      return;
-
-   if (status_pass != pass)
-   {
-      fprintf(stdout, "\n Pass %d: ", pass);
-      status_pass = pass;
-      status_dots = 31;
-   }
-
-   status_dots--;
-
-   if (status_dots == 0)
-   {
-      fprintf(stdout, "\n         ");
-      status_dots=30;
-   }
-
-   fprintf(stdout, "r");
-}
-
-#ifdef PNG_WRITE_SUPPORTED
-static void PNGCBAPI
-write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
-{
-   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
-      return;
-
-   fprintf(stdout, "w");
-}
-#endif
-
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-/* Example of using a user transform callback (doesn't do anything at present).
- */
-static void PNGCBAPI
-read_user_callback(png_structp png_ptr, png_row_infop row_info, png_bytep data)
-{
-   PNG_UNUSED(png_ptr)
-   PNG_UNUSED(row_info)
-   PNG_UNUSED(data)
-}
-#endif
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-/* Example of using user transform callback (we don't transform anything,
- * but merely count the zero samples)
- */
-
-static png_uint_32 zero_samples;
-
-static void PNGCBAPI
-count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
-{
-   png_bytep dp = data;
-   if (png_ptr == NULL)
-      return;
-
-   /* Contents of row_info:
-    *  png_uint_32 width      width of row
-    *  png_uint_32 rowbytes   number of bytes in row
-    *  png_byte color_type    color type of pixels
-    *  png_byte bit_depth     bit depth of samples
-    *  png_byte channels      number of channels (1-4)
-    *  png_byte pixel_depth   bits per pixel (depth*channels)
-    */
-
-    /* Counts the number of zero samples (or zero pixels if color_type is 3 */
-
-    if (row_info->color_type == 0 || row_info->color_type == 3)
-    {
-       int pos = 0;
-       png_uint_32 n, nstop;
-
-       for (n = 0, nstop=row_info->width; n<nstop; n++)
-       {
-          if (row_info->bit_depth == 1)
-          {
-             if (((*dp << pos++ ) & 0x80) == 0)
-                zero_samples++;
-
-             if (pos == 8)
-             {
-                pos = 0;
-                dp++;
-             }
-          }
-
-          if (row_info->bit_depth == 2)
-          {
-             if (((*dp << (pos+=2)) & 0xc0) == 0)
-                zero_samples++;
-
-             if (pos == 8)
-             {
-                pos = 0;
-                dp++;
-             }
-          }
-
-          if (row_info->bit_depth == 4)
-          {
-             if (((*dp << (pos+=4)) & 0xf0) == 0)
-                zero_samples++;
-
-             if (pos == 8)
-             {
-                pos = 0;
-                dp++;
-             }
-          }
-
-          if (row_info->bit_depth == 8)
-             if (*dp++ == 0)
-                zero_samples++;
-
-          if (row_info->bit_depth == 16)
-          {
-             if ((*dp | *(dp+1)) == 0)
-                zero_samples++;
-             dp+=2;
-          }
-       }
-    }
-    else /* Other color types */
-    {
-       png_uint_32 n, nstop;
-       int channel;
-       int color_channels = row_info->channels;
-       if (row_info->color_type > 3)
-          color_channels--;
-
-       for (n = 0, nstop=row_info->width; n<nstop; n++)
-       {
-          for (channel = 0; channel < color_channels; channel++)
-          {
-             if (row_info->bit_depth == 8)
-                if (*dp++ == 0)
-                   zero_samples++;
-
-             if (row_info->bit_depth == 16)
-             {
-                if ((*dp | *(dp+1)) == 0)
-                   zero_samples++;
-
-                dp+=2;
-             }
-          }
-          if (row_info->color_type > 3)
-          {
-             dp++;
-             if (row_info->bit_depth == 16)
-                dp++;
-          }
-       }
-    }
-}
-#endif /* WRITE_USER_TRANSFORM */
-
-#ifndef PNG_STDIO_SUPPORTED
-/* START of code to validate stdio-free compilation */
-/* These copies of the default read/write functions come from pngrio.c and
- * pngwio.c.  They allow "don't include stdio" testing of the library.
- * This is the function that does the actual reading of data.  If you are
- * not reading from a standard C stream, you should create a replacement
- * read_data function and use it at run time with png_set_read_fn(), rather
- * than changing the library.
- */
-
-#ifdef PNG_IO_STATE_SUPPORTED
-void
-pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
-   png_uint_32 io_op);
-void
-pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
-   png_uint_32 io_op)
-{
-   png_uint_32 io_state = png_get_io_state(png_ptr);
-   int err = 0;
-
-   /* Check if the current operation (reading / writing) is as expected. */
-   if ((io_state & PNG_IO_MASK_OP) != io_op)
-      png_error(png_ptr, "Incorrect operation in I/O state");
-
-   /* Check if the buffer size specific to the current location
-    * (file signature / header / data / crc) is as expected.
-    */
-   switch (io_state & PNG_IO_MASK_LOC)
-   {
-   case PNG_IO_SIGNATURE:
-      if (data_length > 8)
-         err = 1;
-      break;
-   case PNG_IO_CHUNK_HDR:
-      if (data_length != 8)
-         err = 1;
-      break;
-   case PNG_IO_CHUNK_DATA:
-      break;  /* no restrictions here */
-   case PNG_IO_CHUNK_CRC:
-      if (data_length != 4)
-         err = 1;
-      break;
-   default:
-      err = 1;  /* uninitialized */
-   }
-   if (err != 0)
-      png_error(png_ptr, "Bad I/O state or buffer size");
-}
-#endif
-
-static void PNGCBAPI
-pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
-   png_size_t check = 0;
-   png_voidp io_ptr;
-
-   /* fread() returns 0 on error, so it is OK to store this in a png_size_t
-    * instead of an int, which is what fread() actually returns.
-    */
-   io_ptr = png_get_io_ptr(png_ptr);
-   if (io_ptr != NULL)
-   {
-      check = fread(data, 1, length, (png_FILE_p)io_ptr);
-   }
-
-   if (check != length)
-   {
-      png_error(png_ptr, "Read Error");
-   }
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
-#endif
-}
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-static void PNGCBAPI
-pngtest_flush(png_structp png_ptr)
-{
-   /* Do nothing; fflush() is said to be just a waste of energy. */
-   PNG_UNUSED(png_ptr)   /* Stifle compiler warning */
-}
-#endif
-
-/* This is the function that does the actual writing of data.  If you are
- * not writing to a standard C stream, you should create a replacement
- * write_data function and use it at run time with png_set_write_fn(), rather
- * than changing the library.
- */
-static void PNGCBAPI
-pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
-   png_size_t check;
-
-   check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr));
-
-   if (check != length)
-   {
-      png_error(png_ptr, "Write Error");
-   }
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
-#endif
-}
-#endif /* !STDIO */
-
-/* This function is called when there is a warning, but the library thinks
- * it can continue anyway.  Replacement functions don't have to do anything
- * here if you don't want to.  In the default configuration, png_ptr is
- * not used, but it is passed in case it may be useful.
- */
-typedef struct
-{
-   PNG_CONST char *file_name;
-}  pngtest_error_parameters;
-
-static void PNGCBAPI
-pngtest_warning(png_structp png_ptr, png_const_charp message)
-{
-   PNG_CONST char *name = "UNKNOWN (ERROR!)";
-   pngtest_error_parameters *test =
-      (pngtest_error_parameters*)png_get_error_ptr(png_ptr);
-
-   ++warning_count;
-
-   if (test != NULL && test->file_name != NULL)
-      name = test->file_name;
-
-   fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
-}
-
-/* This is the default error handling function.  Note that replacements for
- * this function MUST NOT RETURN, or the program will likely crash.  This
- * function is used by default, or if the program supplies NULL for the
- * error function pointer in png_set_error_fn().
- */
-static void PNGCBAPI
-pngtest_error(png_structp png_ptr, png_const_charp message)
-{
-   ++error_count;
-
-   pngtest_warning(png_ptr, message);
-   /* We can return because png_error calls the default handler, which is
-    * actually OK in this case.
-    */
-}
-
-/* END of code to validate stdio-free compilation */
-
-/* START of code to validate memory allocation and deallocation */
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-
-/* Allocate memory.  For reasonable files, size should never exceed
- * 64K.  However, zlib may allocate more than 64K if you don't tell
- * it not to.  See zconf.h and png.h for more information.  zlib does
- * need to allocate exactly 64K, so whatever you call here must
- * have the ability to do that.
- *
- * This piece of code can be compiled to validate max 64K allocations
- * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K.
- */
-typedef struct memory_information
-{
-   png_alloc_size_t          size;
-   png_voidp                 pointer;
-   struct memory_information *next;
-} memory_information;
-typedef memory_information *memory_infop;
-
-static memory_infop pinformation = NULL;
-static int current_allocation = 0;
-static int maximum_allocation = 0;
-static int total_allocation = 0;
-static int num_allocations = 0;
-
-png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr,
-    png_alloc_size_t size));
-void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr));
-
-png_voidp
-PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
-{
-
-   /* png_malloc has already tested for NULL; png_create_struct calls
-    * png_debug_malloc directly, with png_ptr == NULL which is OK
-    */
-
-   if (size == 0)
-      return (NULL);
-
-   /* This calls the library allocator twice, once to get the requested
-      buffer and once to get a new free list entry. */
-   {
-      /* Disable malloc_fn and free_fn */
-      memory_infop pinfo;
-      png_set_mem_fn(png_ptr, NULL, NULL, NULL);
-      pinfo = (memory_infop)png_malloc(png_ptr,
-         (sizeof *pinfo));
-      pinfo->size = size;
-      current_allocation += size;
-      total_allocation += size;
-      num_allocations ++;
-
-      if (current_allocation > maximum_allocation)
-         maximum_allocation = current_allocation;
-
-      pinfo->pointer = png_malloc(png_ptr, size);
-      /* Restore malloc_fn and free_fn */
-
-      png_set_mem_fn(png_ptr,
-          NULL, png_debug_malloc, png_debug_free);
-
-      if (size != 0 && pinfo->pointer == NULL)
-      {
-         current_allocation -= size;
-         total_allocation -= size;
-         png_error(png_ptr,
-           "out of memory in pngtest->png_debug_malloc");
-      }
-
-      pinfo->next = pinformation;
-      pinformation = pinfo;
-      /* Make sure the caller isn't assuming zeroed memory. */
-      memset(pinfo->pointer, 0xdd, pinfo->size);
-
-      if (verbose != 0)
-         printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
-            pinfo->pointer);
-
-      return (png_voidp)(pinfo->pointer);
-   }
-}
-
-/* Free a pointer.  It is removed from the list at the same time. */
-void PNGCBAPI
-png_debug_free(png_structp png_ptr, png_voidp ptr)
-{
-   if (png_ptr == NULL)
-      fprintf(STDERR, "NULL pointer to png_debug_free.\n");
-
-   if (ptr == 0)
-   {
-#if 0 /* This happens all the time. */
-      fprintf(STDERR, "WARNING: freeing NULL pointer\n");
-#endif
-      return;
-   }
-
-   /* Unlink the element from the list. */
-   if (pinformation != NULL)
-   {
-      memory_infop *ppinfo = &pinformation;
-
-      for (;;)
-      {
-         memory_infop pinfo = *ppinfo;
-
-         if (pinfo->pointer == ptr)
-         {
-            *ppinfo = pinfo->next;
-            current_allocation -= pinfo->size;
-            if (current_allocation < 0)
-               fprintf(STDERR, "Duplicate free of memory\n");
-            /* We must free the list element too, but first kill
-               the memory that is to be freed. */
-            memset(ptr, 0x55, pinfo->size);
-            free(pinfo);
-            pinfo = NULL;
-            break;
-         }
-
-         if (pinfo->next == NULL)
-         {
-            fprintf(STDERR, "Pointer %p not found\n", ptr);
-            break;
-         }
-
-         ppinfo = &pinfo->next;
-      }
-   }
-
-   /* Finally free the data. */
-   if (verbose != 0)
-      printf("Freeing %p\n", ptr);
-
-   if (ptr != NULL)
-      free(ptr);
-   ptr = NULL;
-}
-#endif /* USER_MEM && DEBUG */
-/* END of code to test memory allocation/deallocation */
-
-
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-/* Demonstration of user chunk support of the sTER and vpAg chunks */
-
-/* (sTER is a public chunk not yet known by libpng.  vpAg is a private
-chunk used in ImageMagick to store "virtual page" size).  */
-
-static struct user_chunk_data
-{
-   png_const_infop info_ptr;
-   png_uint_32     vpAg_width, vpAg_height;
-   png_byte        vpAg_units;
-   png_byte        sTER_mode;
-   int             location[2];
-}
-user_chunk_data;
-
-/* Used for location and order; zero means nothing. */
-#define have_sTER   0x01
-#define have_vpAg   0x02
-#define before_PLTE 0x10
-#define before_IDAT 0x20
-#define after_IDAT  0x40
-
-static void
-init_callback_info(png_const_infop info_ptr)
-{
-   MEMZERO(user_chunk_data);
-   user_chunk_data.info_ptr = info_ptr;
-}
-
-static int
-set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
-{
-   int location;
-
-   if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0)
-      return 0; /* already have one of these */
-
-   /* Find where we are (the code below zeroes info_ptr to indicate that the
-    * chunks before the first IDAT have been read.)
-    */
-   if (data->info_ptr == NULL) /* after IDAT */
-      location = what | after_IDAT;
-
-   else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0)
-      location = what | before_IDAT;
-
-   else
-      location = what | before_PLTE;
-
-   if (data->location[0] == 0)
-      data->location[0] = location;
-
-   else
-      data->location[1] = location;
-
-   return 1; /* handled */
-}
-
-static int PNGCBAPI
-read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
-{
-   struct user_chunk_data *my_user_chunk_data =
-      (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);
-
-   if (my_user_chunk_data == NULL)
-      png_error(png_ptr, "lost user chunk pointer");
-
-   /* Return one of the following:
-    *    return (-n);  chunk had an error
-    *    return (0);  did not recognize
-    *    return (n);  success
-    *
-    * The unknown chunk structure contains the chunk data:
-    * png_byte name[5];
-    * png_byte *data;
-    * png_size_t size;
-    *
-    * Note that libpng has already taken care of the CRC handling.
-    */
-
-   if (chunk->name[0] == 115 && chunk->name[1] ==  84 &&     /* s  T */
-       chunk->name[2] ==  69 && chunk->name[3] ==  82)       /* E  R */
-      {
-         /* Found sTER chunk */
-         if (chunk->size != 1)
-            return (-1); /* Error return */
-
-         if (chunk->data[0] != 0 && chunk->data[0] != 1)
-            return (-1);  /* Invalid mode */
-
-         if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0)
-         {
-            my_user_chunk_data->sTER_mode=chunk->data[0];
-            return (1);
-         }
-
-         else
-            return (0); /* duplicate sTER - give it to libpng */
-      }
-
-   if (chunk->name[0] != 118 || chunk->name[1] != 112 ||    /* v  p */
-       chunk->name[2] !=  65 || chunk->name[3] != 103)      /* A  g */
-      return (0); /* Did not recognize */
-
-   /* Found ImageMagick vpAg chunk */
-
-   if (chunk->size != 9)
-      return (-1); /* Error return */
-
-   if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0)
-      return (0);  /* duplicate vpAg */
-
-   my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
-   my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4);
-   my_user_chunk_data->vpAg_units = chunk->data[8];
-
-   return (1);
-}
-
-#ifdef PNG_WRITE_SUPPORTED
-static void
-write_sTER_chunk(png_structp write_ptr)
-{
-   png_byte sTER[5] = {115,  84,  69,  82, '\0'};
-
-   if (verbose != 0)
-      fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
-
-   png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);
-}
-
-static void
-write_vpAg_chunk(png_structp write_ptr)
-{
-   png_byte vpAg[5] = {118, 112,  65, 103, '\0'};
-
-   png_byte vpag_chunk_data[9];
-
-   if (verbose != 0)
-      fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
-        (unsigned long)user_chunk_data.vpAg_width,
-        (unsigned long)user_chunk_data.vpAg_height,
-        user_chunk_data.vpAg_units);
-
-   png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
-   png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
-   vpag_chunk_data[8] = user_chunk_data.vpAg_units;
-   png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9);
-}
-
-static void
-write_chunks(png_structp write_ptr, int location)
-{
-   int i;
-
-   /* Notice that this preserves the original chunk order, however chunks
-    * intercepted by the callback will be written *after* chunks passed to
-    * libpng.  This will actually reverse a pair of sTER chunks or a pair of
-    * vpAg chunks, resulting in an error later.  This is not worth worrying
-    * about - the chunks should not be duplicated!
-    */
-   for (i=0; i<2; ++i)
-   {
-      if (user_chunk_data.location[i] == (location | have_sTER))
-         write_sTER_chunk(write_ptr);
-
-      else if (user_chunk_data.location[i] == (location | have_vpAg))
-         write_vpAg_chunk(write_ptr);
-   }
-}
-#endif /* WRITE */
-#else /* !READ_USER_CHUNKS */
-#  define write_chunks(pp,loc) ((void)0)
-#endif
-/* END of code to demonstrate user chunk support */
-
-/* START of code to check that libpng has the required text support; this only
- * checks for the write support because if read support is missing the chunk
- * will simply not be reported back to pngtest.
- */
-#ifdef PNG_TEXT_SUPPORTED
-static void
-pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
-   int num_text)
-{
-   while (num_text > 0)
-   {
-      switch (text_ptr[--num_text].compression)
-      {
-         case PNG_TEXT_COMPRESSION_NONE:
-            break;
-
-         case PNG_TEXT_COMPRESSION_zTXt:
-#           ifndef PNG_WRITE_zTXt_SUPPORTED
-               ++unsupported_chunks;
-               /* In libpng 1.7 this now does an app-error, so stop it: */
-               text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
-#           endif
-            break;
-
-         case PNG_ITXT_COMPRESSION_NONE:
-         case PNG_ITXT_COMPRESSION_zTXt:
-#           ifndef PNG_WRITE_iTXt_SUPPORTED
-               ++unsupported_chunks;
-               text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
-#           endif
-            break;
-
-         default:
-            /* This is an error */
-            png_error(png_ptr, "invalid text chunk compression field");
-            break;
-      }
-   }
-}
-#endif
-/* END of code to check that libpng has the required text support */
-
-/* Test one file */
-static int
-test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
-{
-   static png_FILE_p fpin;
-   static png_FILE_p fpout;  /* "static" prevents setjmp corruption */
-   pngtest_error_parameters error_parameters;
-   png_structp read_ptr;
-   png_infop read_info_ptr, end_info_ptr;
-#ifdef PNG_WRITE_SUPPORTED
-   png_structp write_ptr;
-   png_infop write_info_ptr;
-   png_infop write_end_info_ptr;
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   int interlace_preserved = 1;
-#endif /* WRITE_FILTER */
-#else /* !WRITE */
-   png_structp write_ptr = NULL;
-   png_infop write_info_ptr = NULL;
-   png_infop write_end_info_ptr = NULL;
-#endif /* !WRITE */
-   png_bytep row_buf;
-   png_uint_32 y;
-   png_uint_32 width, height;
-   volatile int num_passes;
-   int pass;
-   int bit_depth, color_type;
-
-   row_buf = NULL;
-   error_parameters.file_name = inname;
-
-   if ((fpin = fopen(inname, "rb")) == NULL)
-   {
-      fprintf(STDERR, "Could not find input file %s\n", inname);
-      return (1);
-   }
-
-   if ((fpout = fopen(outname, "wb")) == NULL)
-   {
-      fprintf(STDERR, "Could not open output file %s\n", outname);
-      FCLOSE(fpin);
-      return (1);
-   }
-
-   pngtest_debug("Allocating read and write structures");
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-   read_ptr =
-      png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
-      NULL, NULL, NULL, png_debug_malloc, png_debug_free);
-#else
-   read_ptr =
-      png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-#endif
-   png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
-      pngtest_warning);
-
-#ifdef PNG_WRITE_SUPPORTED
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-   write_ptr =
-      png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
-      NULL, NULL, NULL, png_debug_malloc, png_debug_free);
-#else
-   write_ptr =
-      png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-#endif
-   png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
-      pngtest_warning);
-#endif
-   pngtest_debug("Allocating read_info, write_info and end_info structures");
-   read_info_ptr = png_create_info_struct(read_ptr);
-   end_info_ptr = png_create_info_struct(read_ptr);
-#ifdef PNG_WRITE_SUPPORTED
-   write_info_ptr = png_create_info_struct(write_ptr);
-   write_end_info_ptr = png_create_info_struct(write_ptr);
-#endif
-
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-   init_callback_info(read_info_ptr);
-   png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
-     read_user_chunk_callback);
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-   pngtest_debug("Setting jmpbuf for read struct");
-   if (setjmp(png_jmpbuf(read_ptr)))
-   {
-      fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
-      png_free(read_ptr, row_buf);
-      row_buf = NULL;
-      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
-#ifdef PNG_WRITE_SUPPORTED
-      png_destroy_info_struct(write_ptr, &write_end_info_ptr);
-      png_destroy_write_struct(&write_ptr, &write_info_ptr);
-#endif
-      FCLOSE(fpin);
-      FCLOSE(fpout);
-      return (1);
-   }
-
-#ifdef PNG_WRITE_SUPPORTED
-   pngtest_debug("Setting jmpbuf for write struct");
-
-   if (setjmp(png_jmpbuf(write_ptr)))
-   {
-      fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
-      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
-      png_destroy_info_struct(write_ptr, &write_end_info_ptr);
-#ifdef PNG_WRITE_SUPPORTED
-      png_destroy_write_struct(&write_ptr, &write_info_ptr);
-#endif
-      FCLOSE(fpin);
-      FCLOSE(fpout);
-      return (1);
-   }
-#endif
-#endif
-
-   if (strict != 0)
-   {
-      /* Treat png_benign_error() as errors on read */
-      png_set_benign_errors(read_ptr, 0);
-
-#ifdef PNG_WRITE_SUPPORTED
-      /* Treat them as errors on write */
-      png_set_benign_errors(write_ptr, 0);
-#endif
-
-      /* if strict is not set, then app warnings and errors are treated as
-       * warnings in release builds, but not in unstable builds; this can be
-       * changed with '--relaxed'.
-       */
-   }
-
-   else if (relaxed != 0)
-   {
-      /* Allow application (pngtest) errors and warnings to pass */
-      png_set_benign_errors(read_ptr, 1);
-
-#ifdef PNG_WRITE_SUPPORTED
-      png_set_benign_errors(write_ptr, 1);
-#endif
-   }
-
-   pngtest_debug("Initializing input and output streams");
-#ifdef PNG_STDIO_SUPPORTED
-   png_init_io(read_ptr, fpin);
-#  ifdef PNG_WRITE_SUPPORTED
-   png_init_io(write_ptr, fpout);
-#  endif
-#else
-   png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);
-#  ifdef PNG_WRITE_SUPPORTED
-   png_set_write_fn(write_ptr, (png_voidp)fpout,  pngtest_write_data,
-#    ifdef PNG_WRITE_FLUSH_SUPPORTED
-      pngtest_flush);
-#    else
-      NULL);
-#    endif
-#  endif
-#endif
-
-   if (status_dots_requested == 1)
-   {
-#ifdef PNG_WRITE_SUPPORTED
-      png_set_write_status_fn(write_ptr, write_row_callback);
-#endif
-      png_set_read_status_fn(read_ptr, read_row_callback);
-   }
-
-   else
-   {
-#ifdef PNG_WRITE_SUPPORTED
-      png_set_write_status_fn(write_ptr, NULL);
-#endif
-      png_set_read_status_fn(read_ptr, NULL);
-   }
-
-#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-   png_set_read_user_transform_fn(read_ptr, read_user_callback);
-#endif
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-   zero_samples = 0;
-   png_set_write_user_transform_fn(write_ptr, count_zero_samples);
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-   /* Preserve all the unknown chunks, if possible.  If this is disabled then,
-    * even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use
-    * libpng to *save* the unknown chunks on read (because we can't switch the
-    * save option on!)
-    *
-    * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all
-    * unknown chunks and write will write them all.
-    */
-#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
-   png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
-      NULL, 0);
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-   png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
-      NULL, 0);
-#endif
-#endif
-
-   pngtest_debug("Reading info struct");
-   png_read_info(read_ptr, read_info_ptr);
-
-#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-   /* This is a bit of a hack; there is no obvious way in the callback function
-    * to determine that the chunks before the first IDAT have been read, so
-    * remove the info_ptr (which is only used to determine position relative to
-    * PLTE) here to indicate that we are after the IDAT.
-    */
-   user_chunk_data.info_ptr = NULL;
-#endif
-
-   pngtest_debug("Transferring info struct");
-   {
-      int interlace_type, compression_type, filter_type;
-
-      if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,
-          &color_type, &interlace_type, &compression_type, &filter_type) != 0)
-      {
-         png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
-            color_type, interlace_type, compression_type, filter_type);
-         /* num_passes may not be available below if interlace support is not
-          * provided by libpng for both read and write.
-          */
-         switch (interlace_type)
-         {
-            case PNG_INTERLACE_NONE:
-               num_passes = 1;
-               break;
-
-            case PNG_INTERLACE_ADAM7:
-               num_passes = 7;
-               break;
-
-            default:
-               png_error(read_ptr, "invalid interlace type");
-               /*NOT REACHED*/
-         }
-      }
-
-      else
-         png_error(read_ptr, "png_get_IHDR failed");
-   }
-#ifdef PNG_FIXED_POINT_SUPPORTED
-#ifdef PNG_cHRM_SUPPORTED
-   {
-      png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
-         blue_y;
-
-      if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
-         &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
-      {
-         png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
-            red_y, green_x, green_y, blue_x, blue_y);
-      }
-   }
-#endif
-#ifdef PNG_gAMA_SUPPORTED
-   {
-      png_fixed_point gamma;
-
-      if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma) != 0)
-         png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
-   }
-#endif
-#else /* Use floating point versions */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-#ifdef PNG_cHRM_SUPPORTED
-   {
-      double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
-         blue_y;
-
-      if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
-         &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
-      {
-         png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
-            red_y, green_x, green_y, blue_x, blue_y);
-      }
-   }
-#endif
-#ifdef PNG_gAMA_SUPPORTED
-   {
-      double gamma;
-
-      if (png_get_gAMA(read_ptr, read_info_ptr, &gamma) != 0)
-         png_set_gAMA(write_ptr, write_info_ptr, gamma);
-   }
-#endif
-#endif /* Floating point */
-#endif /* Fixed point */
-#ifdef PNG_iCCP_SUPPORTED
-   {
-      png_charp name;
-      png_bytep profile;
-      png_uint_32 proflen;
-      int compression_type;
-
-      if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
-                      &profile, &proflen) != 0)
-      {
-         png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
-                      profile, proflen);
-      }
-   }
-#endif
-#ifdef PNG_sRGB_SUPPORTED
-   {
-      int intent;
-
-      if (png_get_sRGB(read_ptr, read_info_ptr, &intent) != 0)
-         png_set_sRGB(write_ptr, write_info_ptr, intent);
-   }
-#endif
-   {
-      png_colorp palette;
-      int num_palette;
-
-      if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette) != 0)
-         png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
-   }
-#ifdef PNG_bKGD_SUPPORTED
-   {
-      png_color_16p background;
-
-      if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0)
-      {
-         png_set_bKGD(write_ptr, write_info_ptr, background);
-      }
-   }
-#endif
-#ifdef PNG_hIST_SUPPORTED
-   {
-      png_uint_16p hist;
-
-      if (png_get_hIST(read_ptr, read_info_ptr, &hist) != 0)
-         png_set_hIST(write_ptr, write_info_ptr, hist);
-   }
-#endif
-#ifdef PNG_oFFs_SUPPORTED
-   {
-      png_int_32 offset_x, offset_y;
-      int unit_type;
-
-      if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
-          &unit_type) != 0)
-      {
-         png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
-      }
-   }
-#endif
-#ifdef PNG_pCAL_SUPPORTED
-   {
-      png_charp purpose, units;
-      png_charpp params;
-      png_int_32 X0, X1;
-      int type, nparams;
-
-      if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
-         &nparams, &units, &params) != 0)
-      {
-         png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
-            nparams, units, params);
-      }
-   }
-#endif
-#ifdef PNG_pHYs_SUPPORTED
-   {
-      png_uint_32 res_x, res_y;
-      int unit_type;
-
-      if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y,
-          &unit_type) != 0)
-         png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
-   }
-#endif
-#ifdef PNG_sBIT_SUPPORTED
-   {
-      png_color_8p sig_bit;
-
-      if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit) != 0)
-         png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
-   }
-#endif
-#ifdef PNG_sCAL_SUPPORTED
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
-   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
-   {
-      int unit;
-      double scal_width, scal_height;
-
-      if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
-         &scal_height) != 0)
-      {
-         png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
-      }
-   }
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-   {
-      int unit;
-      png_charp scal_width, scal_height;
-
-      if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
-          &scal_height) != 0)
-      {
-         png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
-             scal_height);
-      }
-   }
-#endif
-#endif
-#endif
-
-#ifdef PNG_sPLT_SUPPORTED
-   {
-       png_sPLT_tp entries;
-
-       int num_entries = (int) png_get_sPLT(read_ptr, read_info_ptr, &entries);
-       if (num_entries)
-       {
-           png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries);
-       }
-   }
-#endif
-
-#ifdef PNG_TEXT_SUPPORTED
-   {
-      png_textp text_ptr;
-      int num_text;
-
-      if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
-      {
-         pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
-
-         pngtest_check_text_support(read_ptr, text_ptr, num_text);
-
-         if (verbose != 0)
-         {
-            int i;
-
-            printf("\n");
-            for (i=0; i<num_text; i++)
-            {
-               printf("   Text compression[%d]=%d\n",
-                     i, text_ptr[i].compression);
-            }
-         }
-
-         png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
-      }
-   }
-#endif
-#ifdef PNG_tIME_SUPPORTED
-   {
-      png_timep mod_time;
-
-      if (png_get_tIME(read_ptr, read_info_ptr, &mod_time) != 0)
-      {
-         png_set_tIME(write_ptr, write_info_ptr, mod_time);
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-         if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
-            tIME_string[(sizeof tIME_string) - 1] = '\0';
-
-         else
-         {
-            strncpy(tIME_string, "*** invalid time ***", (sizeof tIME_string));
-            tIME_string[(sizeof tIME_string) - 1] = '\0';
-         }
-
-         tIME_chunk_present++;
-#endif /* TIME_RFC1123 */
-      }
-   }
-#endif
-#ifdef PNG_tRNS_SUPPORTED
-   {
-      png_bytep trans_alpha;
-      int num_trans;
-      png_color_16p trans_color;
-
-      if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
-         &trans_color) != 0)
-      {
-         int sample_max = (1 << bit_depth);
-         /* libpng doesn't reject a tRNS chunk with out-of-range samples */
-         if (!((color_type == PNG_COLOR_TYPE_GRAY &&
-             (int)trans_color->gray > sample_max) ||
-             (color_type == PNG_COLOR_TYPE_RGB &&
-             ((int)trans_color->red > sample_max ||
-             (int)trans_color->green > sample_max ||
-             (int)trans_color->blue > sample_max))))
-            png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans,
-               trans_color);
-      }
-   }
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-   {
-      png_unknown_chunkp unknowns;
-      int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
-         &unknowns);
-
-      if (num_unknowns != 0)
-      {
-         png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
-           num_unknowns);
-#if PNG_LIBPNG_VER < 10600
-         /* Copy the locations from the read_info_ptr.  The automatically
-          * generated locations in write_end_info_ptr are wrong prior to 1.6.0
-          * because they are reset from the write pointer (removed in 1.6.0).
-          */
-         {
-            int i;
-            for (i = 0; i < num_unknowns; i++)
-              png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
-                unknowns[i].location);
-         }
-#endif
-      }
-   }
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-   pngtest_debug("Writing info struct");
-
-   /* Write the info in two steps so that if we write the 'unknown' chunks here
-    * they go to the correct place.
-    */
-   png_write_info_before_PLTE(write_ptr, write_info_ptr);
-
-   write_chunks(write_ptr, before_PLTE); /* before PLTE */
-
-   png_write_info(write_ptr, write_info_ptr);
-
-   write_chunks(write_ptr, before_IDAT); /* after PLTE */
-#endif
-
-#ifdef SINGLE_ROWBUF_ALLOC
-   pngtest_debug("Allocating row buffer...");
-   row_buf = (png_bytep)png_malloc(read_ptr,
-      png_get_rowbytes(read_ptr, read_info_ptr));
-
-   pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
-#endif /* SINGLE_ROWBUF_ALLOC */
-   pngtest_debug("Writing row data");
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED) &&\
-   defined(PNG_WRITE_INTERLACING_SUPPORTED)
-   /* Both must be defined for libpng to be able to handle the interlace,
-    * otherwise it gets handled below by simply reading and writing the passes
-    * directly.
-    */
-   if (png_set_interlace_handling(read_ptr) != num_passes)
-      png_error(write_ptr,
-            "png_set_interlace_handling(read): wrong pass count ");
-   if (png_set_interlace_handling(write_ptr) != num_passes)
-      png_error(write_ptr,
-            "png_set_interlace_handling(write): wrong pass count ");
-#else /* png_set_interlace_handling not called on either read or write */
-#  define calc_pass_height
-#endif /* not using libpng interlace handling */
-
-#ifdef PNGTEST_TIMING
-   t_stop = (float)clock();
-   t_misc += (t_stop - t_start);
-   t_start = t_stop;
-#endif
-   for (pass = 0; pass < num_passes; pass++)
-   {
-#     ifdef calc_pass_height
-         png_uint_32 pass_height;
-
-         if (num_passes == 7) /* interlaced */
-         {
-            if (PNG_PASS_COLS(width, pass) > 0)
-               pass_height = PNG_PASS_ROWS(height, pass);
-
-            else
-               pass_height = 0;
-         }
-
-         else /* not interlaced */
-            pass_height = height;
-#     else
-#        define pass_height height
-#     endif
-
-      pngtest_debug1("Writing row data for pass %d", pass);
-      for (y = 0; y < pass_height; y++)
-      {
-#ifndef SINGLE_ROWBUF_ALLOC
-         pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
-
-         row_buf = (png_bytep)png_malloc(read_ptr,
-            png_get_rowbytes(read_ptr, read_info_ptr));
-
-         pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
-            (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
-
-#endif /* !SINGLE_ROWBUF_ALLOC */
-         png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
-
-#ifdef PNG_WRITE_SUPPORTED
-#ifdef PNGTEST_TIMING
-         t_stop = (float)clock();
-         t_decode += (t_stop - t_start);
-         t_start = t_stop;
-#endif
-         png_write_rows(write_ptr, (png_bytepp)&row_buf, 1);
-#ifdef PNGTEST_TIMING
-         t_stop = (float)clock();
-         t_encode += (t_stop - t_start);
-         t_start = t_stop;
-#endif
-#endif /* WRITE */
-
-#ifndef SINGLE_ROWBUF_ALLOC
-         pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
-         png_free(read_ptr, row_buf);
-         row_buf = NULL;
-#endif /* !SINGLE_ROWBUF_ALLOC */
-      }
-   }
-
-#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-#  ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
-      png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);
-#  endif
-#  ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-      png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
-#  endif
-#endif
-
-   pngtest_debug("Reading and writing end_info data");
-
-   png_read_end(read_ptr, end_info_ptr);
-#ifdef PNG_TEXT_SUPPORTED
-   {
-      png_textp text_ptr;
-      int num_text;
-
-      if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
-      {
-         pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
-
-         pngtest_check_text_support(read_ptr, text_ptr, num_text);
-
-         if (verbose != 0)
-         {
-            int i;
-
-            printf("\n");
-            for (i=0; i<num_text; i++)
-            {
-               printf("   Text compression[%d]=%d\n",
-                     i, text_ptr[i].compression);
-            }
-         }
-
-         png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
-      }
-   }
-#endif
-#ifdef PNG_tIME_SUPPORTED
-   {
-      png_timep mod_time;
-
-      if (png_get_tIME(read_ptr, end_info_ptr, &mod_time) != 0)
-      {
-         png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-         if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
-            tIME_string[(sizeof tIME_string) - 1] = '\0';
-
-         else
-         {
-            strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string);
-            tIME_string[(sizeof tIME_string)-1] = '\0';
-         }
-
-         tIME_chunk_present++;
-#endif /* TIME_RFC1123 */
-      }
-   }
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-   {
-      png_unknown_chunkp unknowns;
-      int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
-         &unknowns);
-
-      if (num_unknowns != 0)
-      {
-         png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
-           num_unknowns);
-#if PNG_LIBPNG_VER < 10600
-         /* Copy the locations from the read_info_ptr.  The automatically
-          * generated locations in write_end_info_ptr are wrong prior to 1.6.0
-          * because they are reset from the write pointer (removed in 1.6.0).
-          */
-         {
-            int i;
-            for (i = 0; i < num_unknowns; i++)
-              png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
-                unknowns[i].location);
-         }
-#endif
-      }
-   }
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-   /* Normally one would use Z_DEFAULT_STRATEGY for text compression.
-    * This is here just to make pngtest replicate the results from libpng
-    * versions prior to 1.5.4, and to test this new API.
-    */
-   png_set_text_compression_strategy(write_ptr, Z_FILTERED);
-#endif
-
-   /* When the unknown vpAg/sTER chunks are written by pngtest the only way to
-    * do it is to write them *before* calling png_write_end.  When unknown
-    * chunks are written by libpng, however, they are written just before IEND.
-    * There seems to be no way round this, however vpAg/sTER are not expected
-    * after IDAT.
-    */
-   write_chunks(write_ptr, after_IDAT);
-
-   png_write_end(write_ptr, write_end_info_ptr);
-#endif
-
-#ifdef PNG_EASY_ACCESS_SUPPORTED
-   if (verbose != 0)
-   {
-      png_uint_32 iwidth, iheight;
-      iwidth = png_get_image_width(write_ptr, write_info_ptr);
-      iheight = png_get_image_height(write_ptr, write_info_ptr);
-      fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
-         (unsigned long)iwidth, (unsigned long)iheight);
-   }
-#endif
-
-   pngtest_debug("Destroying data structs");
-#ifdef SINGLE_ROWBUF_ALLOC
-   pngtest_debug("destroying row_buf for read_ptr");
-   png_free(read_ptr, row_buf);
-   row_buf = NULL;
-#endif /* SINGLE_ROWBUF_ALLOC */
-   pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr");
-   png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
-#ifdef PNG_WRITE_SUPPORTED
-   pngtest_debug("destroying write_end_info_ptr");
-   png_destroy_info_struct(write_ptr, &write_end_info_ptr);
-   pngtest_debug("destroying write_ptr, write_info_ptr");
-   png_destroy_write_struct(&write_ptr, &write_info_ptr);
-#endif
-   pngtest_debug("Destruction complete.");
-
-   FCLOSE(fpin);
-   FCLOSE(fpout);
-
-   /* Summarize any warnings or errors and in 'strict' mode fail the test.
-    * Unsupported chunks can result in warnings, in that case ignore the strict
-    * setting, otherwise fail the test on warnings as well as errors.
-    */
-   if (error_count > 0)
-   {
-      /* We don't really expect to get here because of the setjmp handling
-       * above, but this is safe.
-       */
-      fprintf(STDERR, "\n  %s: %d libpng errors found (%d warnings)",
-         inname, error_count, warning_count);
-
-      if (strict != 0)
-         return (1);
-   }
-
-#  ifdef PNG_WRITE_SUPPORTED
-      /* If there is no write support nothing was written! */
-      else if (unsupported_chunks > 0)
-      {
-         fprintf(STDERR, "\n  %s: unsupported chunks (%d)%s",
-            inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
-      }
-#  endif
-
-   else if (warning_count > 0)
-   {
-      fprintf(STDERR, "\n  %s: %d libpng warnings found",
-         inname, warning_count);
-
-      if (strict != 0)
-         return (1);
-   }
-
-   pngtest_debug("Opening files for comparison");
-   if ((fpin = fopen(inname, "rb")) == NULL)
-   {
-      fprintf(STDERR, "Could not find file %s\n", inname);
-      return (1);
-   }
-
-   if ((fpout = fopen(outname, "rb")) == NULL)
-   {
-      fprintf(STDERR, "Could not find file %s\n", outname);
-      FCLOSE(fpin);
-      return (1);
-   }
-
-#if defined (PNG_WRITE_SUPPORTED) /* else nothing was written */ &&\
-    defined (PNG_WRITE_FILTER_SUPPORTED)
-   if (interlace_preserved != 0) /* else the files will be changed */
-   {
-      for (;;)
-      {
-         static int wrote_question = 0;
-         png_size_t num_in, num_out;
-         char inbuf[256], outbuf[256];
-
-         num_in = fread(inbuf, 1, sizeof inbuf, fpin);
-         num_out = fread(outbuf, 1, sizeof outbuf, fpout);
-
-         if (num_in != num_out)
-         {
-            fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
-                    inname, outname);
-
-            if (wrote_question == 0 && unsupported_chunks == 0)
-            {
-               fprintf(STDERR,
-         "   Was %s written with the same maximum IDAT chunk size (%d bytes),",
-                 inname, PNG_ZBUF_SIZE);
-               fprintf(STDERR,
-                 "\n   filtering heuristic (libpng default), compression");
-               fprintf(STDERR,
-                 " level (zlib default),\n   and zlib version (%s)?\n\n",
-                 ZLIB_VERSION);
-               wrote_question = 1;
-            }
-
-            FCLOSE(fpin);
-            FCLOSE(fpout);
-
-            if (strict != 0 && unsupported_chunks == 0)
-              return (1);
-
-            else
-              return (0);
-         }
-
-         if (num_in == 0)
-            break;
-
-         if (memcmp(inbuf, outbuf, num_in))
-         {
-            fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
-               outname);
-
-            if (wrote_question == 0 && unsupported_chunks == 0)
-            {
-               fprintf(STDERR,
-         "   Was %s written with the same maximum IDAT chunk size (%d bytes),",
-                    inname, PNG_ZBUF_SIZE);
-               fprintf(STDERR,
-                 "\n   filtering heuristic (libpng default), compression");
-               fprintf(STDERR,
-                 " level (zlib default),\n   and zlib version (%s)?\n\n",
-                 ZLIB_VERSION);
-               wrote_question = 1;
-            }
-
-            FCLOSE(fpin);
-            FCLOSE(fpout);
-
-            /* NOTE: the unsupported_chunks escape is permitted here because
-             * unsupported text chunk compression will result in the compression
-             * mode being changed (to NONE) yet, in the test case, the result
-             * can be exactly the same size!
-             */
-            if (strict != 0 && unsupported_chunks == 0)
-              return (1);
-
-            else
-              return (0);
-         }
-      }
-   }
-#endif /* WRITE && WRITE_FILTER */
-
-   FCLOSE(fpin);
-   FCLOSE(fpout);
-
-   return (0);
-}
-
-/* Input and output filenames */
-#ifdef RISCOS
-static PNG_CONST char *inname = "pngtest/png";
-static PNG_CONST char *outname = "pngout/png";
-#else
-static PNG_CONST char *inname = "pngtest.png";
-static PNG_CONST char *outname = "pngout.png";
-#endif
-
-int
-main(int argc, char *argv[])
-{
-   int multiple = 0;
-   int ierror = 0;
-
-   png_structp dummy_ptr;
-
-   fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
-   fprintf(STDERR, "   with zlib   version %s\n", ZLIB_VERSION);
-   fprintf(STDERR, "%s", png_get_copyright(NULL));
-   /* Show the version of libpng used in building the library */
-   fprintf(STDERR, " library (%lu):%s",
-      (unsigned long)png_access_version_number(),
-      png_get_header_version(NULL));
-
-   /* Show the version of libpng used in building the application */
-   fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
-      PNG_HEADER_VERSION_STRING);
-
-   /* Do some consistency checking on the memory allocation settings, I'm
-    * not sure this matters, but it is nice to know, the first of these
-    * tests should be impossible because of the way the macros are set
-    * in pngconf.h
-    */
-#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
-      fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
-#endif
-   /* I think the following can happen. */
-#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
-      fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n");
-#endif
-
-   if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
-   {
-      fprintf(STDERR,
-         "Warning: versions are different between png.h and png.c\n");
-      fprintf(STDERR, "  png.h version: %s\n", PNG_LIBPNG_VER_STRING);
-      fprintf(STDERR, "  png.c version: %s\n\n", png_libpng_ver);
-      ++ierror;
-   }
-
-   if (argc > 1)
-   {
-      if (strcmp(argv[1], "-m") == 0)
-      {
-         multiple = 1;
-         status_dots_requested = 0;
-      }
-
-      else if (strcmp(argv[1], "-mv") == 0 ||
-               strcmp(argv[1], "-vm") == 0 )
-      {
-         multiple = 1;
-         verbose = 1;
-         status_dots_requested = 1;
-      }
-
-      else if (strcmp(argv[1], "-v") == 0)
-      {
-         verbose = 1;
-         status_dots_requested = 1;
-         inname = argv[2];
-      }
-
-      else if (strcmp(argv[1], "--strict") == 0)
-      {
-         status_dots_requested = 0;
-         verbose = 1;
-         inname = argv[2];
-         strict++;
-         relaxed = 0;
-      }
-
-      else if (strcmp(argv[1], "--relaxed") == 0)
-      {
-         status_dots_requested = 0;
-         verbose = 1;
-         inname = argv[2];
-         strict = 0;
-         relaxed++;
-      }
-
-      else
-      {
-         inname = argv[1];
-         status_dots_requested = 0;
-      }
-   }
-
-   if (multiple == 0 && argc == 3 + verbose)
-     outname = argv[2 + verbose];
-
-   if ((multiple == 0 && argc > 3 + verbose) ||
-       (multiple != 0 && argc < 2))
-   {
-     fprintf(STDERR,
-       "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
-        argv[0], argv[0]);
-     fprintf(STDERR,
-       "  reads/writes one PNG file (without -m) or multiple files (-m)\n");
-     fprintf(STDERR,
-       "  with -m %s is used as a temporary file\n", outname);
-     exit(1);
-   }
-
-   if (multiple != 0)
-   {
-      int i;
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-      int allocation_now = current_allocation;
-#endif
-      for (i=2; i<argc; ++i)
-      {
-         int kerror;
-         fprintf(STDERR, "\n Testing %s:", argv[i]);
-#if PNG_DEBUG > 0
-         fprintf(STDERR, "\n");
-#endif
-         kerror = test_one_file(argv[i], outname);
-         if (kerror == 0)
-         {
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-            fprintf(STDERR, "\n PASS (%lu zero samples)\n",
-               (unsigned long)zero_samples);
-#else
-            fprintf(STDERR, " PASS\n");
-#endif
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-            if (tIME_chunk_present != 0)
-               fprintf(STDERR, " tIME = %s\n", tIME_string);
-
-            tIME_chunk_present = 0;
-#endif /* TIME_RFC1123 */
-         }
-
-         else
-         {
-            fprintf(STDERR, " FAIL\n");
-            ierror += kerror;
-         }
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-         if (allocation_now != current_allocation)
-            fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
-               current_allocation - allocation_now);
-
-         if (current_allocation != 0)
-         {
-            memory_infop pinfo = pinformation;
-
-            fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
-               current_allocation);
-
-            while (pinfo != NULL)
-            {
-               fprintf(STDERR, " %lu bytes at %p\n",
-                 (unsigned long)pinfo->size,
-                 pinfo->pointer);
-               pinfo = pinfo->next;
-            }
-         }
-#endif
-      }
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-         fprintf(STDERR, " Current memory allocation: %10d bytes\n",
-            current_allocation);
-         fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
-            maximum_allocation);
-         fprintf(STDERR, " Total   memory allocation: %10d bytes\n",
-            total_allocation);
-         fprintf(STDERR, "     Number of allocations: %10d\n",
-            num_allocations);
-#endif
-   }
-
-   else
-   {
-      int i;
-      for (i = 0; i<3; ++i)
-      {
-         int kerror;
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-         int allocation_now = current_allocation;
-#endif
-         if (i == 1)
-            status_dots_requested = 1;
-
-         else if (verbose == 0)
-            status_dots_requested = 0;
-
-         if (i == 0 || verbose == 1 || ierror != 0)
-         {
-            fprintf(STDERR, "\n Testing %s:", inname);
-#if PNG_DEBUG > 0
-            fprintf(STDERR, "\n");
-#endif
-         }
-
-         kerror = test_one_file(inname, outname);
-
-         if (kerror == 0)
-         {
-            if (verbose == 1 || i == 2)
-            {
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-                fprintf(STDERR, "\n PASS (%lu zero samples)\n",
-                   (unsigned long)zero_samples);
-#else
-                fprintf(STDERR, " PASS\n");
-#endif
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-             if (tIME_chunk_present != 0)
-                fprintf(STDERR, " tIME = %s\n", tIME_string);
-#endif /* TIME_RFC1123 */
-            }
-         }
-
-         else
-         {
-            if (verbose == 0 && i != 2)
-            {
-               fprintf(STDERR, "\n Testing %s:", inname);
-#if PNG_DEBUG > 0
-               fprintf(STDERR, "\n");
-#endif
-            }
-
-            fprintf(STDERR, " FAIL\n");
-            ierror += kerror;
-         }
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-         if (allocation_now != current_allocation)
-             fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
-               current_allocation - allocation_now);
-
-         if (current_allocation != 0)
-         {
-             memory_infop pinfo = pinformation;
-
-             fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
-                current_allocation);
-
-             while (pinfo != NULL)
-             {
-                fprintf(STDERR, " %lu bytes at %p\n",
-                   (unsigned long)pinfo->size, pinfo->pointer);
-                pinfo = pinfo->next;
-             }
-          }
-#endif
-       }
-#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
-       fprintf(STDERR, " Current memory allocation: %10d bytes\n",
-          current_allocation);
-       fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
-          maximum_allocation);
-       fprintf(STDERR, " Total   memory allocation: %10d bytes\n",
-          total_allocation);
-       fprintf(STDERR, "     Number of allocations: %10d\n",
-            num_allocations);
-#endif
-   }
-
-#ifdef PNGTEST_TIMING
-   t_stop = (float)clock();
-   t_misc += (t_stop - t_start);
-   t_start = t_stop;
-   fprintf(STDERR, " CPU time used = %.3f seconds",
-      (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
-   fprintf(STDERR, " (decoding %.3f,\n",
-      t_decode/(float)CLOCKS_PER_SEC);
-   fprintf(STDERR, "        encoding %.3f ,",
-      t_encode/(float)CLOCKS_PER_SEC);
-   fprintf(STDERR, " other %.3f seconds)\n\n",
-      t_misc/(float)CLOCKS_PER_SEC);
-#endif
-
-   if (ierror == 0)
-      fprintf(STDERR, " libpng passes test\n");
-
-   else
-      fprintf(STDERR, " libpng FAILS test\n");
-
-   dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-   fprintf(STDERR, " Default limits:\n");
-   fprintf(STDERR, "  width_max  = %lu\n",
-      (unsigned long) png_get_user_width_max(dummy_ptr));
-   fprintf(STDERR, "  height_max = %lu\n",
-      (unsigned long) png_get_user_height_max(dummy_ptr));
-   if (png_get_chunk_cache_max(dummy_ptr) == 0)
-      fprintf(STDERR, "  cache_max  = unlimited\n");
-   else
-      fprintf(STDERR, "  cache_max  = %lu\n",
-         (unsigned long) png_get_chunk_cache_max(dummy_ptr));
-   if (png_get_chunk_malloc_max(dummy_ptr) == 0)
-      fprintf(STDERR, "  malloc_max = unlimited\n");
-   else
-      fprintf(STDERR, "  malloc_max = %lu\n",
-         (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
-   png_destroy_read_struct(&dummy_ptr, NULL, NULL);
-
-   return (int)(ierror != 0);
-}
-#else
-int
-main(void)
-{
-   fprintf(STDERR,
-      " test ignored because libpng was not built with read support\n");
-   /* And skip this test */
-   return SKIP;
-}
-#endif
-
-/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c	Wed Jul 05 22:46:04 2017 +0200
@@ -29,8 +29,8 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.18 [July 23, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -200,13 +200,14 @@
                    * size!
                    */
                   png_app_error(png_ptr,
-                     "png_set_filler is invalid for low bit depth gray output");
+                      "png_set_filler is invalid for"
+                      " low bit depth gray output");
                   return;
                }
 
             default:
                png_app_error(png_ptr,
-                  "png_set_filler: inappropriate color type");
+                   "png_set_filler: inappropriate color type");
                return;
          }
 #     else
@@ -622,7 +623,7 @@
       return; /* The filler channel has gone already */
 
    /* Fix the rowbytes value. */
-   row_info->rowbytes = dp-row;
+   row_info->rowbytes = (unsigned int)(dp-row);
 }
 #endif
 
@@ -720,7 +721,7 @@
        * and this calculation is used because it avoids warnings that other
        * forms produced on either GCC or MSVC.
        */
-      int padding = (-row_info->pixel_depth * row_info->width) & 7;
+      int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
       png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
 
       switch (row_info->bit_depth)
@@ -825,7 +826,7 @@
       (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
    {
       png_app_error(png_ptr,
-            "info change after png_start_read_image or png_read_update_info");
+          "info change after png_start_read_image or png_read_update_info");
       return;
    }
 #endif
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwio.c	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +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.
- */
-
-/* pngwio.c - functions for data output
- *
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.6.15 [November 20, 2014]
- * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- *
- * This file provides a location for all output.  Users who need
- * special handling are expected to write functions that have the same
- * arguments as these and perform similar functions, but that possibly
- * use different output methods.  Note that you shouldn't change these
- * functions, but rather write replacement functions and then change
- * them at run time with png_set_write_fn(...).
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-
-/* Write the data to whatever output you are using.  The default routine
- * writes to a file pointer.  Note that this routine sometimes gets called
- * with very small lengths, so you should implement some kind of simple
- * buffering if you are using unbuffered writes.  This should never be asked
- * to write more than 64K on a 16-bit machine.
- */
-
-void /* PRIVATE */
-png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
-{
-   /* NOTE: write_data_fn must not change the buffer! */
-   if (png_ptr->write_data_fn != NULL )
-      (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
-         length);
-
-   else
-      png_error(png_ptr, "Call to NULL write function");
-}
-
-#ifdef PNG_STDIO_SUPPORTED
-/* This is the function that does the actual writing of data.  If you are
- * not writing to a standard C stream, you should create a replacement
- * write_data function and use it at run time with png_set_write_fn(), rather
- * than changing the library.
- */
-void PNGCBAPI
-png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
-   png_size_t check;
-
-   if (png_ptr == NULL)
-      return;
-
-   check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
-
-   if (check != length)
-      png_error(png_ptr, "Write Error");
-}
-#endif
-
-/* This function is called to output any data pending writing (normally
- * to disk).  After png_flush is called, there should be no data pending
- * writing in any buffers.
- */
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-void /* PRIVATE */
-png_flush(png_structrp png_ptr)
-{
-   if (png_ptr->output_flush_fn != NULL)
-      (*(png_ptr->output_flush_fn))(png_ptr);
-}
-
-#  ifdef PNG_STDIO_SUPPORTED
-void PNGCBAPI
-png_default_flush(png_structp png_ptr)
-{
-   png_FILE_p io_ptr;
-
-   if (png_ptr == NULL)
-      return;
-
-   io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
-   fflush(io_ptr);
-}
-#  endif
-#endif
-
-/* This function allows the application to supply new output functions for
- * libpng if standard C streams aren't being used.
- *
- * This function takes as its arguments:
- * png_ptr       - pointer to a png output data structure
- * io_ptr        - pointer to user supplied structure containing info about
- *                 the output functions.  May be NULL.
- * write_data_fn - pointer to a new output function that takes as its
- *                 arguments a pointer to a png_struct, a pointer to
- *                 data to be written, and a 32-bit unsigned int that is
- *                 the number of bytes to be written.  The new write
- *                 function should call png_error(png_ptr, "Error msg")
- *                 to exit and output any fatal error messages.  May be
- *                 NULL, in which case libpng's default function will
- *                 be used.
- * flush_data_fn - pointer to a new flush function that takes as its
- *                 arguments a pointer to a png_struct.  After a call to
- *                 the flush function, there should be no data in any buffers
- *                 or pending transmission.  If the output method doesn't do
- *                 any buffering of output, a function prototype must still be
- *                 supplied although it doesn't have to do anything.  If
- *                 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
- *                 time, output_flush_fn will be ignored, although it must be
- *                 supplied for compatibility.  May be NULL, in which case
- *                 libpng's default function will be used, if
- *                 PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not
- *                 a good idea if io_ptr does not point to a standard
- *                 *FILE structure.
- */
-void PNGAPI
-png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
-    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
-{
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->io_ptr = io_ptr;
-
-#ifdef PNG_STDIO_SUPPORTED
-   if (write_data_fn != NULL)
-      png_ptr->write_data_fn = write_data_fn;
-
-   else
-      png_ptr->write_data_fn = png_default_write_data;
-#else
-   png_ptr->write_data_fn = write_data_fn;
-#endif
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-#  ifdef PNG_STDIO_SUPPORTED
-
-   if (output_flush_fn != NULL)
-      png_ptr->output_flush_fn = output_flush_fn;
-
-   else
-      png_ptr->output_flush_fn = png_default_flush;
-
-#  else
-   png_ptr->output_flush_fn = output_flush_fn;
-#  endif
-#else
-   PNG_UNUSED(output_flush_fn)
-#endif /* WRITE_FLUSH */
-
-#ifdef PNG_READ_SUPPORTED
-   /* It is an error to read while writing a png file */
-   if (png_ptr->read_data_fn != NULL)
-   {
-      png_ptr->read_data_fn = NULL;
-
-      png_warning(png_ptr,
-          "Can't set both read_data_fn and write_data_fn in the"
-          " same structure");
-   }
-#endif
-}
-#endif /* WRITE */
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwrite.c	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2411 +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.
- */
-
-/* pngwrite.c - general routines to write a PNG file
- *
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.6.19 [November 12, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-#  include <errno.h>
-#endif /* SIMPLIFIED_WRITE_STDIO */
-
-#ifdef PNG_WRITE_SUPPORTED
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-/* Write out all the unknown chunks for the current given location */
-static void
-write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
-   unsigned int where)
-{
-   if (info_ptr->unknown_chunks_num != 0)
-   {
-      png_const_unknown_chunkp up;
-
-      png_debug(5, "writing extra chunks");
-
-      for (up = info_ptr->unknown_chunks;
-           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
-           ++up)
-         if ((up->location & where) != 0)
-      {
-         /* If per-chunk unknown chunk handling is enabled use it, otherwise
-          * just write the chunks the application has set.
-          */
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-         int keep = png_handle_as_unknown(png_ptr, up->name);
-
-         /* NOTE: this code is radically different from the read side in the
-          * matter of handling an ancillary unknown chunk.  In the read side
-          * the default behavior is to discard it, in the code below the default
-          * behavior is to write it.  Critical chunks are, however, only
-          * written if explicitly listed or if the default is set to write all
-          * unknown chunks.
-          *
-          * The default handling is also slightly weird - it is not possible to
-          * stop the writing of all unsafe-to-copy chunks!
-          *
-          * TODO: REVIEW: this would seem to be a bug.
-          */
-         if (keep != PNG_HANDLE_CHUNK_NEVER &&
-             ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ ||
-              keep == PNG_HANDLE_CHUNK_ALWAYS ||
-              (keep == PNG_HANDLE_CHUNK_AS_DEFAULT &&
-               png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS)))
-#endif
-         {
-            /* TODO: review, what is wrong with a zero length unknown chunk? */
-            if (up->size == 0)
-               png_warning(png_ptr, "Writing zero-length unknown chunk");
-
-            png_write_chunk(png_ptr, up->name, up->data, up->size);
-         }
-      }
-   }
-}
-#endif /* WRITE_UNKNOWN_CHUNKS */
-
-/* Writes all the PNG information.  This is the suggested way to use the
- * library.  If you have a new chunk to add, make a function to write it,
- * and put it in the correct location here.  If you want the chunk written
- * after the image data, put it in png_write_end().  I strongly encourage
- * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
- * the chunk, as that will keep the code from breaking if you want to just
- * write a plain PNG file.  If you have long comments, I suggest writing
- * them in png_write_end(), and compressing them.
- */
-void PNGAPI
-png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
-{
-   png_debug(1, "in png_write_info_before_PLTE");
-
-   if (png_ptr == NULL || info_ptr == NULL)
-      return;
-
-   if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
-   {
-      /* Write PNG signature */
-      png_write_sig(png_ptr);
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-      if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
-          png_ptr->mng_features_permitted != 0)
-      {
-         png_warning(png_ptr,
-             "MNG features are not allowed in a PNG datastream");
-         png_ptr->mng_features_permitted = 0;
-      }
-#endif
-
-      /* Write IHDR information. */
-      png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
-          info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
-          info_ptr->filter_type,
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-          info_ptr->interlace_type
-#else
-          0
-#endif
-         );
-
-      /* The rest of these check to see if the valid field has the appropriate
-       * flag set, and if it does, writes the chunk.
-       *
-       * 1.6.0: COLORSPACE support controls the writing of these chunks too, and
-       * the chunks will be written if the WRITE routine is there and
-       * information * is available in the COLORSPACE. (See
-       * png_colorspace_sync_info in png.c for where the valid flags get set.)
-       *
-       * Under certain circumstances the colorspace can be invalidated without
-       * syncing the info_struct 'valid' flags; this happens if libpng detects
-       * an error and calls png_error while the color space is being set, yet
-       * the application continues writing the PNG.  So check the 'invalid'
-       * flag here too.
-       */
-#ifdef PNG_GAMMA_SUPPORTED
-#  ifdef PNG_WRITE_gAMA_SUPPORTED
-      if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-          (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
-          (info_ptr->valid & PNG_INFO_gAMA) != 0)
-         png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
-#  endif
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-      /* Write only one of sRGB or an ICC profile.  If a profile was supplied
-       * and it matches one of the known sRGB ones issue a warning.
-       */
-#  ifdef PNG_WRITE_iCCP_SUPPORTED
-         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-             (info_ptr->valid & PNG_INFO_iCCP) != 0)
-         {
-#    ifdef PNG_WRITE_sRGB_SUPPORTED
-               if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
-                  png_app_warning(png_ptr,
-                     "profile matches sRGB but writing iCCP instead");
-#     endif
-
-            png_write_iCCP(png_ptr, info_ptr->iccp_name,
-               info_ptr->iccp_profile);
-         }
-#     ifdef PNG_WRITE_sRGB_SUPPORTED
-         else
-#     endif
-#  endif
-
-#  ifdef PNG_WRITE_sRGB_SUPPORTED
-         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-             (info_ptr->valid & PNG_INFO_sRGB) != 0)
-            png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
-#  endif /* WRITE_sRGB */
-#endif /* COLORSPACE */
-
-#ifdef PNG_WRITE_sBIT_SUPPORTED
-         if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
-            png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-#  ifdef PNG_WRITE_cHRM_SUPPORTED
-         if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
-             (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
-             (info_ptr->valid & PNG_INFO_cHRM) != 0)
-            png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
-#  endif
-#endif
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-         write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
-#endif
-
-      png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
-   }
-}
-
-void PNGAPI
-png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
-{
-#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
-   int i;
-#endif
-
-   png_debug(1, "in png_write_info");
-
-   if (png_ptr == NULL || info_ptr == NULL)
-      return;
-
-   png_write_info_before_PLTE(png_ptr, info_ptr);
-
-   if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
-      png_write_PLTE(png_ptr, info_ptr->palette,
-          (png_uint_32)info_ptr->num_palette);
-
-   else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-      png_error(png_ptr, "Valid palette required for paletted images");
-
-#ifdef PNG_WRITE_tRNS_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
-   {
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
-      /* Invert the alpha channel (in tRNS) */
-      if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
-          info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-      {
-         int j, jend;
-
-         jend = info_ptr->num_trans;
-         if (jend > PNG_MAX_PALETTE_LENGTH)
-            jend = PNG_MAX_PALETTE_LENGTH;
-
-         for (j = 0; j<jend; ++j)
-            info_ptr->trans_alpha[j] =
-               (png_byte)(255 - info_ptr->trans_alpha[j]);
-      }
-#endif
-      png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
-          info_ptr->num_trans, info_ptr->color_type);
-   }
-#endif
-#ifdef PNG_WRITE_bKGD_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
-      png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
-#endif
-
-#ifdef PNG_WRITE_hIST_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_hIST) != 0)
-      png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
-#endif
-
-#ifdef PNG_WRITE_oFFs_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
-      png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
-          info_ptr->offset_unit_type);
-#endif
-
-#ifdef PNG_WRITE_pCAL_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
-      png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
-          info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
-          info_ptr->pcal_units, info_ptr->pcal_params);
-#endif
-
-#ifdef PNG_WRITE_sCAL_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
-      png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
-          info_ptr->scal_s_width, info_ptr->scal_s_height);
-#endif /* sCAL */
-
-#ifdef PNG_WRITE_pHYs_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
-      png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
-          info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
-#endif /* pHYs */
-
-#ifdef PNG_WRITE_tIME_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_tIME) != 0)
-   {
-      png_write_tIME(png_ptr, &(info_ptr->mod_time));
-      png_ptr->mode |= PNG_WROTE_tIME;
-   }
-#endif /* tIME */
-
-#ifdef PNG_WRITE_sPLT_SUPPORTED
-   if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
-      for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
-         png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
-#endif /* sPLT */
-
-#ifdef PNG_WRITE_TEXT_SUPPORTED
-   /* Check to see if we need to write text chunks */
-   for (i = 0; i < info_ptr->num_text; i++)
-   {
-      png_debug2(2, "Writing header text chunk %d, type %d", i,
-          info_ptr->text[i].compression);
-      /* An internationalized chunk? */
-      if (info_ptr->text[i].compression > 0)
-      {
-#ifdef PNG_WRITE_iTXt_SUPPORTED
-         /* Write international chunk */
-         png_write_iTXt(png_ptr,
-             info_ptr->text[i].compression,
-             info_ptr->text[i].key,
-             info_ptr->text[i].lang,
-             info_ptr->text[i].lang_key,
-             info_ptr->text[i].text);
-         /* Mark this chunk as written */
-         if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
-            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-         else
-            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
-         png_warning(png_ptr, "Unable to write international text");
-#endif
-      }
-
-      /* If we want a compressed text chunk */
-      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)
-      {
-#ifdef PNG_WRITE_zTXt_SUPPORTED
-         /* Write compressed chunk */
-         png_write_zTXt(png_ptr, info_ptr->text[i].key,
-             info_ptr->text[i].text, info_ptr->text[i].compression);
-         /* Mark this chunk as written */
-         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
-         png_warning(png_ptr, "Unable to write compressed text");
-#endif
-      }
-
-      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
-      {
-#ifdef PNG_WRITE_tEXt_SUPPORTED
-         /* Write uncompressed chunk */
-         png_write_tEXt(png_ptr, info_ptr->text[i].key,
-             info_ptr->text[i].text,
-             0);
-         /* Mark this chunk as written */
-         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-#else
-         /* Can't get here */
-         png_warning(png_ptr, "Unable to write uncompressed text");
-#endif
-      }
-   }
-#endif /* tEXt */
-
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-   write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE);
-#endif
-}
-
-/* Writes the end of the PNG file.  If you don't want to write comments or
- * time information, you can pass NULL for info.  If you already wrote these
- * in png_write_info(), do not write them again here.  If you have long
- * comments, I suggest writing them here, and compressing them.
- */
-void PNGAPI
-png_write_end(png_structrp png_ptr, png_inforp info_ptr)
-{
-   png_debug(1, "in png_write_end");
-
-   if (png_ptr == NULL)
-      return;
-
-   if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
-      png_error(png_ptr, "No IDATs written into file");
-
-#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
-   if (png_ptr->num_palette_max > png_ptr->num_palette)
-      png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
-#endif
-
-   /* See if user wants us to write information chunks */
-   if (info_ptr != NULL)
-   {
-#ifdef PNG_WRITE_TEXT_SUPPORTED
-      int i; /* local index variable */
-#endif
-#ifdef PNG_WRITE_tIME_SUPPORTED
-      /* Check to see if user has supplied a time chunk */
-      if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
-          (png_ptr->mode & PNG_WROTE_tIME) == 0)
-         png_write_tIME(png_ptr, &(info_ptr->mod_time));
-
-#endif
-#ifdef PNG_WRITE_TEXT_SUPPORTED
-      /* Loop through comment chunks */
-      for (i = 0; i < info_ptr->num_text; i++)
-      {
-         png_debug2(2, "Writing trailer text chunk %d, type %d", i,
-            info_ptr->text[i].compression);
-         /* An internationalized chunk? */
-         if (info_ptr->text[i].compression > 0)
-         {
-#ifdef PNG_WRITE_iTXt_SUPPORTED
-            /* Write international chunk */
-            png_write_iTXt(png_ptr,
-                info_ptr->text[i].compression,
-                info_ptr->text[i].key,
-                info_ptr->text[i].lang,
-                info_ptr->text[i].lang_key,
-                info_ptr->text[i].text);
-            /* Mark this chunk as written */
-            if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
-               info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-            else
-               info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
-            png_warning(png_ptr, "Unable to write international text");
-#endif
-         }
-
-         else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
-         {
-#ifdef PNG_WRITE_zTXt_SUPPORTED
-            /* Write compressed chunk */
-            png_write_zTXt(png_ptr, info_ptr->text[i].key,
-                info_ptr->text[i].text, info_ptr->text[i].compression);
-            /* Mark this chunk as written */
-            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
-#else
-            png_warning(png_ptr, "Unable to write compressed text");
-#endif
-         }
-
-         else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
-         {
-#ifdef PNG_WRITE_tEXt_SUPPORTED
-            /* Write uncompressed chunk */
-            png_write_tEXt(png_ptr, info_ptr->text[i].key,
-                info_ptr->text[i].text, 0);
-            /* Mark this chunk as written */
-            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
-#else
-            png_warning(png_ptr, "Unable to write uncompressed text");
-#endif
-         }
-      }
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-      write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
-#endif
-   }
-
-   png_ptr->mode |= PNG_AFTER_IDAT;
-
-   /* Write end of PNG file */
-   png_write_IEND(png_ptr);
-
-   /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
-    * and restored again in libpng-1.2.30, may cause some applications that
-    * do not set png_ptr->output_flush_fn to crash.  If your application
-    * experiences a problem, please try building libpng with
-    * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to
-    * png-mng-implement at lists.sf.net .
-    */
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-#  ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED
-   png_flush(png_ptr);
-#  endif
-#endif
-}
-
-#ifdef PNG_CONVERT_tIME_SUPPORTED
-void PNGAPI
-png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
-{
-   png_debug(1, "in png_convert_from_struct_tm");
-
-   ptime->year = (png_uint_16)(1900 + ttime->tm_year);
-   ptime->month = (png_byte)(ttime->tm_mon + 1);
-   ptime->day = (png_byte)ttime->tm_mday;
-   ptime->hour = (png_byte)ttime->tm_hour;
-   ptime->minute = (png_byte)ttime->tm_min;
-   ptime->second = (png_byte)ttime->tm_sec;
-}
-
-void PNGAPI
-png_convert_from_time_t(png_timep ptime, time_t ttime)
-{
-   struct tm *tbuf;
-
-   png_debug(1, "in png_convert_from_time_t");
-
-   tbuf = gmtime(&ttime);
-   png_convert_from_struct_tm(ptime, tbuf);
-}
-#endif
-
-/* Initialize png_ptr structure, and allocate any memory needed */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
-    png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)
-{
-#ifndef PNG_USER_MEM_SUPPORTED
-   png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
-       error_fn, warn_fn, NULL, NULL, NULL);
-#else
-   return png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
-       warn_fn, NULL, NULL, NULL);
-}
-
-/* Alternate initialize png_ptr structure, and allocate any memory needed */
-PNG_FUNCTION(png_structp,PNGAPI
-png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
-    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
-    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
-{
-   png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
-       error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
-#endif /* USER_MEM */
-   if (png_ptr != NULL)
-   {
-      /* Set the zlib control values to defaults; they can be overridden by the
-       * application after the struct has been created.
-       */
-      png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
-
-      /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
-       * pngwutil.c defaults it according to whether or not filters will be
-       * used, and ignores this setting.
-       */
-      png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
-      png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
-      png_ptr->zlib_mem_level = 8;
-      png_ptr->zlib_window_bits = 15;
-      png_ptr->zlib_method = 8;
-
-#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
-      png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
-      png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
-      png_ptr->zlib_text_mem_level = 8;
-      png_ptr->zlib_text_window_bits = 15;
-      png_ptr->zlib_text_method = 8;
-#endif /* WRITE_COMPRESSED_TEXT */
-
-      /* This is a highly dubious configuration option; by default it is off,
-       * but it may be appropriate for private builds that are testing
-       * extensions not conformant to the current specification, or of
-       * applications that must not fail to write at all costs!
-       */
-#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
-      /* In stable builds only warn if an application error can be completely
-       * handled.
-       */
-      png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
-#endif
-
-      /* App warnings are warnings in release (or release candidate) builds but
-       * are errors during development.
-       */
-#if PNG_RELEASE_BUILD
-      png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
-#endif
-
-      /* TODO: delay this, it can be done in png_init_io() (if the app doesn't
-       * do it itself) avoiding setting the default function if it is not
-       * required.
-       */
-      png_set_write_fn(png_ptr, NULL, NULL, NULL);
-   }
-
-   return png_ptr;
-}
-
-
-/* Write a few rows of image data.  If the image is interlaced,
- * either you will have to write the 7 sub images, or, if you
- * have called png_set_interlace_handling(), you will have to
- * "write" the image seven times.
- */
-void PNGAPI
-png_write_rows(png_structrp png_ptr, png_bytepp row,
-    png_uint_32 num_rows)
-{
-   png_uint_32 i; /* row counter */
-   png_bytepp rp; /* row pointer */
-
-   png_debug(1, "in png_write_rows");
-
-   if (png_ptr == NULL)
-      return;
-
-   /* Loop through the rows */
-   for (i = 0, rp = row; i < num_rows; i++, rp++)
-   {
-      png_write_row(png_ptr, *rp);
-   }
-}
-
-/* Write the image.  You only need to call this function once, even
- * if you are writing an interlaced image.
- */
-void PNGAPI
-png_write_image(png_structrp png_ptr, png_bytepp image)
-{
-   png_uint_32 i; /* row index */
-   int pass, num_pass; /* pass variables */
-   png_bytepp rp; /* points to current row */
-
-   if (png_ptr == NULL)
-      return;
-
-   png_debug(1, "in png_write_image");
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* Initialize interlace handling.  If image is not interlaced,
-    * this will set pass to 1
-    */
-   num_pass = png_set_interlace_handling(png_ptr);
-#else
-   num_pass = 1;
-#endif
-   /* Loop through passes */
-   for (pass = 0; pass < num_pass; pass++)
-   {
-      /* Loop through image */
-      for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
-      {
-         png_write_row(png_ptr, *rp);
-      }
-   }
-}
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-/* Performs intrapixel differencing  */
-static void
-png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
-{
-   png_debug(1, "in png_do_write_intrapixel");
-
-   if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
-   {
-      int bytes_per_pixel;
-      png_uint_32 row_width = row_info->width;
-      if (row_info->bit_depth == 8)
-      {
-         png_bytep rp;
-         png_uint_32 i;
-
-         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
-            bytes_per_pixel = 3;
-
-         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-            bytes_per_pixel = 4;
-
-         else
-            return;
-
-         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
-         {
-            *(rp)     = (png_byte)(*rp       - *(rp + 1));
-            *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1));
-         }
-      }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-      else if (row_info->bit_depth == 16)
-      {
-         png_bytep rp;
-         png_uint_32 i;
-
-         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
-            bytes_per_pixel = 6;
-
-         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-            bytes_per_pixel = 8;
-
-         else
-            return;
-
-         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
-         {
-            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);
-            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);
-            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);
-            png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);
-            png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
-            *(rp    ) = (png_byte)(red >> 8);
-            *(rp + 1) = (png_byte)red;
-            *(rp + 4) = (png_byte)(blue >> 8);
-            *(rp + 5) = (png_byte)blue;
-         }
-      }
-#endif /* WRITE_16BIT */
-   }
-}
-#endif /* MNG_FEATURES */
-
-/* Called by user to write a row of image data */
-void PNGAPI
-png_write_row(png_structrp png_ptr, png_const_bytep row)
-{
-   /* 1.5.6: moved from png_struct to be a local structure: */
-   png_row_info row_info;
-
-   if (png_ptr == NULL)
-      return;
-
-   png_debug2(1, "in png_write_row (row %u, pass %d)",
-      png_ptr->row_number, png_ptr->pass);
-
-   /* Initialize transformations and other stuff if first time */
-   if (png_ptr->row_number == 0 && png_ptr->pass == 0)
-   {
-      /* Make sure we wrote the header info */
-      if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
-         png_error(png_ptr,
-             "png_write_info was never called before png_write_row");
-
-      /* Check for transforms that have been set but were defined out */
-#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
-      if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
-         png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
-      if ((png_ptr->transformations & PNG_FILLER) != 0)
-         png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
-#endif
-#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
-    defined(PNG_READ_PACKSWAP_SUPPORTED)
-      if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
-         png_warning(png_ptr,
-             "PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
-      if ((png_ptr->transformations & PNG_PACK) != 0)
-         png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
-      if ((png_ptr->transformations & PNG_SHIFT) != 0)
-         png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
-      if ((png_ptr->transformations & PNG_BGR) != 0)
-         png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
-#endif
-
-#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
-      if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
-         png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
-#endif
-
-      png_write_start_row(png_ptr);
-   }
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* If interlaced and not interested in row, return */
-   if (png_ptr->interlaced != 0 &&
-       (png_ptr->transformations & PNG_INTERLACE) != 0)
-   {
-      switch (png_ptr->pass)
-      {
-         case 0:
-            if ((png_ptr->row_number & 0x07) != 0)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 1:
-            if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 2:
-            if ((png_ptr->row_number & 0x07) != 4)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 3:
-            if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 4:
-            if ((png_ptr->row_number & 0x03) != 2)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 5:
-            if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         case 6:
-            if ((png_ptr->row_number & 0x01) == 0)
-            {
-               png_write_finish_row(png_ptr);
-               return;
-            }
-            break;
-
-         default: /* error: ignore it */
-            break;
-      }
-   }
-#endif
-
-   /* Set up row info for transformations */
-   row_info.color_type = png_ptr->color_type;
-   row_info.width = png_ptr->usr_width;
-   row_info.channels = png_ptr->usr_channels;
-   row_info.bit_depth = png_ptr->usr_bit_depth;
-   row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
-   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
-
-   png_debug1(3, "row_info->color_type = %d", row_info.color_type);
-   png_debug1(3, "row_info->width = %u", row_info.width);
-   png_debug1(3, "row_info->channels = %d", row_info.channels);
-   png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth);
-   png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth);
-   png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
-
-   /* Copy user's row into buffer, leaving room for filter byte. */
-   memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* Handle interlacing */
-   if (png_ptr->interlaced && png_ptr->pass < 6 &&
-       (png_ptr->transformations & PNG_INTERLACE) != 0)
-   {
-      png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
-      /* This should always get caught above, but still ... */
-      if (row_info.width == 0)
-      {
-         png_write_finish_row(png_ptr);
-         return;
-      }
-   }
-#endif
-
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-   /* Handle other transformations */
-   if (png_ptr->transformations != 0)
-      png_do_write_transformations(png_ptr, &row_info);
-#endif
-
-   /* At this point the row_info pixel depth must match the 'transformed' depth,
-    * which is also the output depth.
-    */
-   if (row_info.pixel_depth != png_ptr->pixel_depth ||
-       row_info.pixel_depth != png_ptr->transformed_pixel_depth)
-      png_error(png_ptr, "internal write transform logic error");
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-   /* Write filter_method 64 (intrapixel differencing) only if
-    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
-    * 2. Libpng did not write a PNG signature (this filter_method is only
-    *    used in PNG datastreams that are embedded in MNG datastreams) and
-    * 3. The application called png_permit_mng_features with a mask that
-    *    included PNG_FLAG_MNG_FILTER_64 and
-    * 4. The filter_method is 64 and
-    * 5. The color_type is RGB or RGBA
-    */
-   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
-       (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
-   {
-      /* Intrapixel differencing */
-      png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
-   }
-#endif
-
-/* Added at libpng-1.5.10 */
-#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
-   /* Check for out-of-range palette index */
-   if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
-       png_ptr->num_palette_max >= 0)
-      png_do_check_palette_indexes(png_ptr, &row_info);
-#endif
-
-   /* Find a filter if necessary, filter the row and write it out. */
-   png_write_find_filter(png_ptr, &row_info);
-
-   if (png_ptr->write_row_fn != NULL)
-      (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
-}
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-/* Set the automatic flush interval or 0 to turn flushing off */
-void PNGAPI
-png_set_flush(png_structrp png_ptr, int nrows)
-{
-   png_debug(1, "in png_set_flush");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
-}
-
-/* Flush the current output buffers now */
-void PNGAPI
-png_write_flush(png_structrp png_ptr)
-{
-   png_debug(1, "in png_write_flush");
-
-   if (png_ptr == NULL)
-      return;
-
-   /* We have already written out all of the data */
-   if (png_ptr->row_number >= png_ptr->num_rows)
-      return;
-
-   png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH);
-   png_ptr->flush_rows = 0;
-   png_flush(png_ptr);
-}
-#endif /* WRITE_FLUSH */
-
-/* Free any memory used in png_ptr struct without freeing the struct itself. */
-static void
-png_write_destroy(png_structrp png_ptr)
-{
-   png_debug(1, "in png_write_destroy");
-
-   /* Free any memory zlib uses */
-   if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
-      deflateEnd(&png_ptr->zstream);
-
-   /* Free our memory.  png_free checks NULL for us. */
-   png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
-   png_free(png_ptr, png_ptr->row_buf);
-   png_ptr->row_buf = NULL;
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   png_free(png_ptr, png_ptr->prev_row);
-   png_free(png_ptr, png_ptr->try_row);
-   png_free(png_ptr, png_ptr->tst_row);
-   png_ptr->prev_row = NULL;
-   png_ptr->try_row = NULL;
-   png_ptr->tst_row = NULL;
-#endif
-
-#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
-   png_free(png_ptr, png_ptr->chunk_list);
-   png_ptr->chunk_list = NULL;
-#endif
-
-   /* The error handling and memory handling information is left intact at this
-    * point: the jmp_buf may still have to be freed.  See png_destroy_png_struct
-    * for how this happens.
-    */
-}
-
-/* Free all memory used by the write.
- * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for
- * *png_ptr_ptr.  Prior to 1.6.0 it would accept such a value and it would free
- * the passed in info_structs but it would quietly fail to free any of the data
- * inside them.  In 1.6.0 it quietly does nothing (it has to be quiet because it
- * has no png_ptr.)
- */
-void PNGAPI
-png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
-{
-   png_debug(1, "in png_destroy_write_struct");
-
-   if (png_ptr_ptr != NULL)
-   {
-      png_structrp png_ptr = *png_ptr_ptr;
-
-      if (png_ptr != NULL) /* added in libpng 1.6.0 */
-      {
-         png_destroy_info_struct(png_ptr, info_ptr_ptr);
-
-         *png_ptr_ptr = NULL;
-         png_write_destroy(png_ptr);
-         png_destroy_png_struct(png_ptr);
-      }
-   }
-}
-
-/* Allow the application to select one or more row filters to use. */
-void PNGAPI
-png_set_filter(png_structrp png_ptr, int method, int filters)
-{
-   png_debug(1, "in png_set_filter");
-
-   if (png_ptr == NULL)
-      return;
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
-       (method == PNG_INTRAPIXEL_DIFFERENCING))
-      method = PNG_FILTER_TYPE_BASE;
-
-#endif
-   if (method == PNG_FILTER_TYPE_BASE)
-   {
-      switch (filters & (PNG_ALL_FILTERS | 0x07))
-      {
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-         case 5:
-         case 6:
-         case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
-            /* FALL THROUGH */
-#endif /* WRITE_FILTER */
-         case PNG_FILTER_VALUE_NONE:
-            png_ptr->do_filter = PNG_FILTER_NONE; break;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-         case PNG_FILTER_VALUE_SUB:
-            png_ptr->do_filter = PNG_FILTER_SUB; break;
-
-         case PNG_FILTER_VALUE_UP:
-            png_ptr->do_filter = PNG_FILTER_UP; break;
-
-         case PNG_FILTER_VALUE_AVG:
-            png_ptr->do_filter = PNG_FILTER_AVG; break;
-
-         case PNG_FILTER_VALUE_PAETH:
-            png_ptr->do_filter = PNG_FILTER_PAETH; break;
-
-         default:
-            png_ptr->do_filter = (png_byte)filters; break;
-#else
-         default:
-            png_app_error(png_ptr, "Unknown row filter for method 0");
-#endif /* WRITE_FILTER */
-      }
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-      /* If we have allocated the row_buf, this means we have already started
-       * with the image and we should have allocated all of the filter buffers
-       * that have been selected.  If prev_row isn't already allocated, then
-       * it is too late to start using the filters that need it, since we
-       * will be missing the data in the previous row.  If an application
-       * wants to start and stop using particular filters during compression,
-       * it should start out with all of the filters, and then remove them
-       * or add them back after the start of compression.
-       *
-       * NOTE: this is a nasty constraint on the code, because it means that the
-       * prev_row buffer must be maintained even if there are currently no
-       * 'prev_row' requiring filters active.
-       */
-      if (png_ptr->row_buf != NULL)
-      {
-         int num_filters;
-         png_alloc_size_t buf_size;
-
-         /* Repeat the checks in png_write_start_row; 1 pixel high or wide
-          * images cannot benefit from certain filters.  If this isn't done here
-          * the check below will fire on 1 pixel high images.
-          */
-         if (png_ptr->height == 1)
-            filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
-         if (png_ptr->width == 1)
-            filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
-         if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
-            && png_ptr->prev_row == NULL)
-         {
-            /* This is the error case, however it is benign - the previous row
-             * is not available so the filter can't be used.  Just warn here.
-             */
-            png_app_warning(png_ptr,
-               "png_set_filter: UP/AVG/PAETH cannot be added after start");
-            filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-         }
-
-         num_filters = 0;
-
-         if (filters & PNG_FILTER_SUB)
-            num_filters++;
-
-         if (filters & PNG_FILTER_UP)
-            num_filters++;
-
-         if (filters & PNG_FILTER_AVG)
-            num_filters++;
-
-         if (filters & PNG_FILTER_PAETH)
-            num_filters++;
-
-         /* Allocate needed row buffers if they have not already been
-          * allocated.
-          */
-         buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
-             png_ptr->width) + 1;
-
-         if (png_ptr->try_row == NULL)
-            png_ptr->try_row = png_voidcast(png_bytep,
-               png_malloc(png_ptr, buf_size));
-
-         if (num_filters > 1)
-         {
-            if (png_ptr->tst_row == NULL)
-               png_ptr->tst_row = png_voidcast(png_bytep,
-                  png_malloc(png_ptr, buf_size));
-         }
-      }
-      png_ptr->do_filter = (png_byte)filters;
-#endif
-   }
-   else
-      png_error(png_ptr, "Unknown custom filter method");
-}
-
-#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
-/* Provide floating and fixed point APIs */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
-    int num_weights, png_const_doublep filter_weights,
-    png_const_doublep filter_costs)
-{
-   PNG_UNUSED(png_ptr)
-   PNG_UNUSED(heuristic_method)
-   PNG_UNUSED(num_weights)
-   PNG_UNUSED(filter_weights)
-   PNG_UNUSED(filter_costs)
-}
-#endif /* FLOATING_POINT */
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-void PNGAPI
-png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
-    int num_weights, png_const_fixed_point_p filter_weights,
-    png_const_fixed_point_p filter_costs)
-{
-   PNG_UNUSED(png_ptr)
-   PNG_UNUSED(heuristic_method)
-   PNG_UNUSED(num_weights)
-   PNG_UNUSED(filter_weights)
-   PNG_UNUSED(filter_costs)
-}
-#endif /* FIXED_POINT */
-#endif /* WRITE_WEIGHTED_FILTER */
-
-#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-void PNGAPI
-png_set_compression_level(png_structrp png_ptr, int level)
-{
-   png_debug(1, "in png_set_compression_level");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->zlib_level = level;
-}
-
-void PNGAPI
-png_set_compression_mem_level(png_structrp png_ptr, int mem_level)
-{
-   png_debug(1, "in png_set_compression_mem_level");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->zlib_mem_level = mem_level;
-}
-
-void PNGAPI
-png_set_compression_strategy(png_structrp png_ptr, int strategy)
-{
-   png_debug(1, "in png_set_compression_strategy");
-
-   if (png_ptr == NULL)
-      return;
-
-   /* The flag setting here prevents the libpng dynamic selection of strategy.
-    */
-   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
-   png_ptr->zlib_strategy = strategy;
-}
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-void PNGAPI
-png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
-{
-   if (png_ptr == NULL)
-      return;
-
-   /* Prior to 1.6.0 this would warn but then set the window_bits value. This
-    * meant that negative window bits values could be selected that would cause
-    * libpng to write a non-standard PNG file with raw deflate or gzip
-    * compressed IDAT or ancillary chunks.  Such files can be read and there is
-    * no warning on read, so this seems like a very bad idea.
-    */
-   if (window_bits > 15)
-   {
-      png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
-      window_bits = 15;
-   }
-
-   else if (window_bits < 8)
-   {
-      png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
-      window_bits = 8;
-   }
-
-   png_ptr->zlib_window_bits = window_bits;
-}
-
-void PNGAPI
-png_set_compression_method(png_structrp png_ptr, int method)
-{
-   png_debug(1, "in png_set_compression_method");
-
-   if (png_ptr == NULL)
-      return;
-
-   /* This would produce an invalid PNG file if it worked, but it doesn't and
-    * deflate will fault it, so it is harmless to just warn here.
-    */
-   if (method != 8)
-      png_warning(png_ptr, "Only compression method 8 is supported by PNG");
-
-   png_ptr->zlib_method = method;
-}
-#endif /* WRITE_CUSTOMIZE_COMPRESSION */
-
-/* The following were added to libpng-1.5.4 */
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-void PNGAPI
-png_set_text_compression_level(png_structrp png_ptr, int level)
-{
-   png_debug(1, "in png_set_text_compression_level");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->zlib_text_level = level;
-}
-
-void PNGAPI
-png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level)
-{
-   png_debug(1, "in png_set_text_compression_mem_level");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->zlib_text_mem_level = mem_level;
-}
-
-void PNGAPI
-png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
-{
-   png_debug(1, "in png_set_text_compression_strategy");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->zlib_text_strategy = strategy;
-}
-
-/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
- * smaller value of window_bits if it can do so safely.
- */
-void PNGAPI
-png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
-{
-   if (png_ptr == NULL)
-      return;
-
-   if (window_bits > 15)
-   {
-      png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
-      window_bits = 15;
-   }
-
-   else if (window_bits < 8)
-   {
-      png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
-      window_bits = 8;
-   }
-
-   png_ptr->zlib_text_window_bits = window_bits;
-}
-
-void PNGAPI
-png_set_text_compression_method(png_structrp png_ptr, int method)
-{
-   png_debug(1, "in png_set_text_compression_method");
-
-   if (png_ptr == NULL)
-      return;
-
-   if (method != 8)
-      png_warning(png_ptr, "Only compression method 8 is supported by PNG");
-
-   png_ptr->zlib_text_method = method;
-}
-#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
-/* end of API added to libpng-1.5.4 */
-
-void PNGAPI
-png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
-{
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->write_row_fn = write_row_fn;
-}
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-void PNGAPI
-png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
-    write_user_transform_fn)
-{
-   png_debug(1, "in png_set_write_user_transform_fn");
-
-   if (png_ptr == NULL)
-      return;
-
-   png_ptr->transformations |= PNG_USER_TRANSFORM;
-   png_ptr->write_user_transform_fn = write_user_transform_fn;
-}
-#endif
-
-
-#ifdef PNG_INFO_IMAGE_SUPPORTED
-void PNGAPI
-png_write_png(png_structrp png_ptr, png_inforp info_ptr,
-    int transforms, voidp params)
-{
-   if (png_ptr == NULL || info_ptr == NULL)
-      return;
-
-   if ((info_ptr->valid & PNG_INFO_IDAT) == 0)
-   {
-      png_app_error(png_ptr, "no rows for png_write_image to write");
-      return;
-   }
-
-   /* Write the file header information. */
-   png_write_info(png_ptr, info_ptr);
-
-   /* ------ these transformations don't touch the info structure ------- */
-
-   /* Invert monochrome pixels */
-   if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
-#ifdef PNG_WRITE_INVERT_SUPPORTED
-      png_set_invert_mono(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
-#endif
-
-   /* Shift the pixels up to a legal bit depth and fill in
-    * as appropriate to correctly scale the image.
-    */
-   if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
-      if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
-         png_set_shift(png_ptr, &info_ptr->sig_bit);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
-#endif
-
-   /* Pack pixels into bytes */
-   if ((transforms & PNG_TRANSFORM_PACKING) != 0)
-#ifdef PNG_WRITE_PACK_SUPPORTED
-      png_set_packing(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
-#endif
-
-   /* Swap location of alpha bytes from ARGB to RGBA */
-   if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
-      png_set_swap_alpha(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
-#endif
-
-   /* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into
-    * RGB, note that the code expects the input color type to be G or RGB; no
-    * alpha channel.
-    */
-   if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER|
-       PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
-   {
-#ifdef PNG_WRITE_FILLER_SUPPORTED
-      if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
-      {
-         if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
-            png_app_error(png_ptr,
-                "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
-
-         /* Continue if ignored - this is the pre-1.6.10 behavior */
-         png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
-      }
-
-      else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
-         png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
-#endif
-   }
-
-   /* Flip BGR pixels to RGB */
-   if ((transforms & PNG_TRANSFORM_BGR) != 0)
-#ifdef PNG_WRITE_BGR_SUPPORTED
-      png_set_bgr(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
-#endif
-
-   /* Swap bytes of 16-bit files to most significant byte first */
-   if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
-#ifdef PNG_WRITE_SWAP_SUPPORTED
-      png_set_swap(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
-#endif
-
-   /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
-   if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
-#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
-      png_set_packswap(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
-#endif
-
-   /* Invert the alpha channel from opacity to transparency */
-   if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
-      png_set_invert_alpha(png_ptr);
-#else
-      png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
-#endif
-
-   /* ----------------------- end of transformations ------------------- */
-
-   /* Write the bits */
-   png_write_image(png_ptr, info_ptr->row_pointers);
-
-   /* It is REQUIRED to call this to finish writing the rest of the file */
-   png_write_end(png_ptr, info_ptr);
-
-   PNG_UNUSED(params)
-}
-#endif
-
-
-#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
-/* Initialize the write structure - general purpose utility. */
-static int
-png_image_write_init(png_imagep image)
-{
-   png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,
-       png_safe_error, png_safe_warning);
-
-   if (png_ptr != NULL)
-   {
-      png_infop info_ptr = png_create_info_struct(png_ptr);
-
-      if (info_ptr != NULL)
-      {
-         png_controlp control = png_voidcast(png_controlp,
-             png_malloc_warn(png_ptr, (sizeof *control)));
-
-         if (control != NULL)
-         {
-            memset(control, 0, (sizeof *control));
-
-            control->png_ptr = png_ptr;
-            control->info_ptr = info_ptr;
-            control->for_write = 1;
-
-            image->opaque = control;
-            return 1;
-         }
-
-         /* Error clean up */
-         png_destroy_info_struct(png_ptr, &info_ptr);
-      }
-
-      png_destroy_write_struct(&png_ptr, NULL);
-   }
-
-   return png_image_error(image, "png_image_write_: out of memory");
-}
-
-/* Arguments to png_image_write_main: */
-typedef struct
-{
-   /* Arguments: */
-   png_imagep      image;
-   png_const_voidp buffer;
-   png_int_32      row_stride;
-   png_const_voidp colormap;
-   int             convert_to_8bit;
-   /* Local variables: */
-   png_const_voidp first_row;
-   ptrdiff_t       row_bytes;
-   png_voidp       local_row;
-   /* Byte count for memory writing */
-   png_bytep        memory;
-   png_alloc_size_t memory_bytes; /* not used for STDIO */
-   png_alloc_size_t output_bytes; /* running total */
-} png_image_write_control;
-
-/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
- * do any necessary byte swapping.  The component order is defined by the
- * png_image format value.
- */
-static int
-png_write_image_16bit(png_voidp argument)
-{
-   png_image_write_control *display = png_voidcast(png_image_write_control*,
-       argument);
-   png_imagep image = display->image;
-   png_structrp png_ptr = image->opaque->png_ptr;
-
-   png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
-       display->first_row);
-   png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
-   png_uint_16p row_end;
-   const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
-   int aindex = 0;
-   png_uint_32 y = image->height;
-
-   if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
-   {
-#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-      if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
-      {
-         aindex = -1;
-         ++input_row; /* To point to the first component */
-         ++output_row;
-      }
-         else
-            aindex = channels;
-#     else
-         aindex = channels;
-#     endif
-   }
-
-   else
-      png_error(png_ptr, "png_write_image: internal call error");
-
-   /* Work out the output row end and count over this, note that the increment
-    * above to 'row' means that row_end can actually be beyond the end of the
-    * row; this is correct.
-    */
-   row_end = output_row + image->width * (channels+1);
-
-   while (y-- > 0)
-   {
-      png_const_uint_16p in_ptr = input_row;
-      png_uint_16p out_ptr = output_row;
-
-      while (out_ptr < row_end)
-      {
-         const png_uint_16 alpha = in_ptr[aindex];
-         png_uint_32 reciprocal = 0;
-         int c;
-
-         out_ptr[aindex] = alpha;
-
-         /* Calculate a reciprocal.  The correct calculation is simply
-          * component/alpha*65535 << 15. (I.e. 15 bits of precision); this
-          * allows correct rounding by adding .5 before the shift.  'reciprocal'
-          * is only initialized when required.
-          */
-         if (alpha > 0 && alpha < 65535)
-            reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;
-
-         c = channels;
-         do /* always at least one channel */
-         {
-            png_uint_16 component = *in_ptr++;
-
-            /* The following gives 65535 for an alpha of 0, which is fine,
-             * otherwise if 0/0 is represented as some other value there is more
-             * likely to be a discontinuity which will probably damage
-             * compression when moving from a fully transparent area to a
-             * nearly transparent one.  (The assumption here is that opaque
-             * areas tend not to be 0 intensity.)
-             */
-            if (component >= alpha)
-               component = 65535;
-
-            /* component<alpha, so component/alpha is less than one and
-             * component*reciprocal is less than 2^31.
-             */
-            else if (component > 0 && alpha < 65535)
-            {
-               png_uint_32 calc = component * reciprocal;
-               calc += 16384; /* round to nearest */
-               component = (png_uint_16)(calc >> 15);
-            }
-
-            *out_ptr++ = component;
-         }
-         while (--c > 0);
-
-         /* Skip to next component (skip the intervening alpha channel) */
-         ++in_ptr;
-         ++out_ptr;
-      }
-
-      png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
-      input_row += display->row_bytes/(sizeof (png_uint_16));
-   }
-
-   return 1;
-}
-
-/* Given 16-bit input (1 to 4 channels) write 8-bit output.  If an alpha channel
- * is present it must be removed from the components, the components are then
- * written in sRGB encoding.  No components are added or removed.
- *
- * Calculate an alpha reciprocal to reverse pre-multiplication.  As above the
- * calculation can be done to 15 bits of accuracy; however, the output needs to
- * be scaled in the range 0..255*65535, so include that scaling here.
- */
-#   define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)
-
-static png_byte
-png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
-   png_uint_32 reciprocal/*from the above macro*/)
-{
-   /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0
-    * is represented as some other value there is more likely to be a
-    * discontinuity which will probably damage compression when moving from a
-    * fully transparent area to a nearly transparent one.  (The assumption here
-    * is that opaque areas tend not to be 0 intensity.)
-    *
-    * There is a rounding problem here; if alpha is less than 128 it will end up
-    * as 0 when scaled to 8 bits.  To avoid introducing spurious colors into the
-    * output change for this too.
-    */
-   if (component >= alpha || alpha < 128)
-      return 255;
-
-   /* component<alpha, so component/alpha is less than one and
-    * component*reciprocal is less than 2^31.
-    */
-   else if (component > 0)
-   {
-      /* The test is that alpha/257 (rounded) is less than 255, the first value
-       * that becomes 255 is 65407.
-       * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore,
-       * be exact!)  [Could also test reciprocal != 0]
-       */
-      if (alpha < 65407)
-      {
-         component *= reciprocal;
-         component += 64; /* round to nearest */
-         component >>= 7;
-      }
-
-      else
-         component *= 255;
-
-      /* Convert the component to sRGB. */
-      return (png_byte)PNG_sRGB_FROM_LINEAR(component);
-   }
-
-   else
-      return 0;
-}
-
-static int
-png_write_image_8bit(png_voidp argument)
-{
-   png_image_write_control *display = png_voidcast(png_image_write_control*,
-       argument);
-   png_imagep image = display->image;
-   png_structrp png_ptr = image->opaque->png_ptr;
-
-   png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
-       display->first_row);
-   png_bytep output_row = png_voidcast(png_bytep, display->local_row);
-   png_uint_32 y = image->height;
-   const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
-
-   if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
-   {
-      png_bytep row_end;
-      int aindex;
-
-#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-      if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
-      {
-         aindex = -1;
-         ++input_row; /* To point to the first component */
-         ++output_row;
-      }
-
-      else
-#   endif
-      aindex = channels;
-
-      /* Use row_end in place of a loop counter: */
-      row_end = output_row + image->width * (channels+1);
-
-      while (y-- > 0)
-      {
-         png_const_uint_16p in_ptr = input_row;
-         png_bytep out_ptr = output_row;
-
-         while (out_ptr < row_end)
-         {
-            png_uint_16 alpha = in_ptr[aindex];
-            png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
-            png_uint_32 reciprocal = 0;
-            int c;
-
-            /* Scale and write the alpha channel. */
-            out_ptr[aindex] = alphabyte;
-
-            if (alphabyte > 0 && alphabyte < 255)
-               reciprocal = UNP_RECIPROCAL(alpha);
-
-            c = channels;
-            do /* always at least one channel */
-               *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);
-            while (--c > 0);
-
-            /* Skip to next component (skip the intervening alpha channel) */
-            ++in_ptr;
-            ++out_ptr;
-         } /* while out_ptr < row_end */
-
-         png_write_row(png_ptr, png_voidcast(png_const_bytep,
-             display->local_row));
-         input_row += display->row_bytes/(sizeof (png_uint_16));
-      } /* while y */
-   }
-
-   else
-   {
-      /* No alpha channel, so the row_end really is the end of the row and it
-       * is sufficient to loop over the components one by one.
-       */
-      png_bytep row_end = output_row + image->width * channels;
-
-      while (y-- > 0)
-      {
-         png_const_uint_16p in_ptr = input_row;
-         png_bytep out_ptr = output_row;
-
-         while (out_ptr < row_end)
-         {
-            png_uint_32 component = *in_ptr++;
-
-            component *= 255;
-            *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component);
-         }
-
-         png_write_row(png_ptr, output_row);
-         input_row += display->row_bytes/(sizeof (png_uint_16));
-      }
-   }
-
-   return 1;
-}
-
-static void
-png_image_set_PLTE(png_image_write_control *display)
-{
-   const png_imagep image = display->image;
-   const void *cmap = display->colormap;
-   const int entries = image->colormap_entries > 256 ? 256 :
-       (int)image->colormap_entries;
-
-   /* NOTE: the caller must check for cmap != NULL and entries != 0 */
-   const png_uint_32 format = image->format;
-   const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
-
-#   if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
-      defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
-      const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
-          (format & PNG_FORMAT_FLAG_ALPHA) != 0;
-#   else
-#     define afirst 0
-#   endif
-
-#   ifdef PNG_FORMAT_BGR_SUPPORTED
-      const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
-#   else
-#     define bgr 0
-#   endif
-
-   int i, num_trans;
-   png_color palette[256];
-   png_byte tRNS[256];
-
-   memset(tRNS, 255, (sizeof tRNS));
-   memset(palette, 0, (sizeof palette));
-
-   for (i=num_trans=0; i<entries; ++i)
-   {
-      /* This gets automatically converted to sRGB with reversal of the
-       * pre-multiplication if the color-map has an alpha channel.
-       */
-      if ((format & PNG_FORMAT_FLAG_LINEAR) != 0)
-      {
-         png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
-
-         entry += i * channels;
-
-         if ((channels & 1) != 0) /* no alpha */
-         {
-            if (channels >= 3) /* RGB */
-            {
-               palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                   entry[(2 ^ bgr)]);
-               palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                   entry[1]);
-               palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
-                   entry[bgr]);
-            }
-
-            else /* Gray */
-               palette[i].blue = palette[i].red = palette[i].green =
-                  (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry);
-         }
-
-         else /* alpha */
-         {
-            png_uint_16 alpha = entry[afirst ? 0 : channels-1];
-            png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
-            png_uint_32 reciprocal = 0;
-
-            /* Calculate a reciprocal, as in the png_write_image_8bit code above
-             * this is designed to produce a value scaled to 255*65535 when
-             * divided by 128 (i.e. asr 7).
-             */
-            if (alphabyte > 0 && alphabyte < 255)
-               reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha;
-
-            tRNS[i] = alphabyte;
-            if (alphabyte < 255)
-               num_trans = i+1;
-
-            if (channels >= 3) /* RGB */
-            {
-               palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)],
-                  alpha, reciprocal);
-               palette[i].green = png_unpremultiply(entry[afirst + 1], alpha,
-                  reciprocal);
-               palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha,
-                  reciprocal);
-            }
-
-            else /* gray */
-               palette[i].blue = palette[i].red = palette[i].green =
-                  png_unpremultiply(entry[afirst], alpha, reciprocal);
-         }
-      }
-
-      else /* Color-map has sRGB values */
-      {
-         png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
-
-         entry += i * channels;
-
-         switch (channels)
-         {
-            case 4:
-               tRNS[i] = entry[afirst ? 0 : 3];
-               if (tRNS[i] < 255)
-                  num_trans = i+1;
-               /* FALL THROUGH */
-            case 3:
-               palette[i].blue = entry[afirst + (2 ^ bgr)];
-               palette[i].green = entry[afirst + 1];
-               palette[i].red = entry[afirst + bgr];
-               break;
-
-            case 2:
-               tRNS[i] = entry[1 ^ afirst];
-               if (tRNS[i] < 255)
-                  num_trans = i+1;
-               /* FALL THROUGH */
-            case 1:
-               palette[i].blue = palette[i].red = palette[i].green =
-                  entry[afirst];
-               break;
-
-            default:
-               break;
-         }
-      }
-   }
-
-#   ifdef afirst
-#     undef afirst
-#   endif
-#   ifdef bgr
-#     undef bgr
-#   endif
-
-   png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,
-      entries);
-
-   if (num_trans > 0)
-      png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
-         num_trans, NULL);
-
-   image->colormap_entries = entries;
-}
-
-static int
-png_image_write_main(png_voidp argument)
-{
-   png_image_write_control *display = png_voidcast(png_image_write_control*,
-      argument);
-   png_imagep image = display->image;
-   png_structrp png_ptr = image->opaque->png_ptr;
-   png_inforp info_ptr = image->opaque->info_ptr;
-   png_uint_32 format = image->format;
-
-   /* The following four ints are actually booleans */
-   int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
-   int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
-   int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
-   int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
-
-#   ifdef PNG_BENIGN_ERRORS_SUPPORTED
-      /* Make sure we error out on any bad situation */
-      png_set_benign_errors(png_ptr, 0/*error*/);
-#   endif
-
-   /* Default the 'row_stride' parameter if required, also check the row stride
-    * and total image size to ensure that they are within the system limits.
-    */
-   {
-      const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
-
-      if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
-      {
-         png_uint_32 check;
-         const png_uint_32 png_row_stride = image->width * channels;
-
-         if (display->row_stride == 0)
-            display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
-
-         if (display->row_stride < 0)
-            check = -display->row_stride;
-
-         else
-            check = display->row_stride;
-
-         if (check >= png_row_stride)
-         {
-            /* Now check for overflow of the image buffer calculation; this
-             * limits the whole image size to 32 bits for API compatibility with
-             * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
-             */
-            if (image->height > 0xFFFFFFFF/png_row_stride)
-               png_error(image->opaque->png_ptr, "memory image too large");
-         }
-
-         else
-            png_error(image->opaque->png_ptr, "supplied row stride too small");
-      }
-
-      else
-         png_error(image->opaque->png_ptr, "image row stride too large");
-   }
-
-   /* Set the required transforms then write the rows in the correct order. */
-   if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
-   {
-      if (display->colormap != NULL && image->colormap_entries > 0)
-      {
-         png_uint_32 entries = image->colormap_entries;
-
-         png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
-            entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
-            PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
-            PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
-         png_image_set_PLTE(display);
-      }
-
-      else
-         png_error(image->opaque->png_ptr,
-            "no color-map for color-mapped image");
-   }
-
-   else
-      png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
-         write_16bit ? 16 : 8,
-         ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
-         ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
-         PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
-   /* Counter-intuitively the data transformations must be called *after*
-    * png_write_info, not before as in the read code, but the 'set' functions
-    * must still be called before.  Just set the color space information, never
-    * write an interlaced image.
-    */
-
-   if (write_16bit != 0)
-   {
-      /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */
-      png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);
-
-      if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
-         png_set_cHRM_fixed(png_ptr, info_ptr,
-            /* color      x       y */
-            /* white */ 31270, 32900,
-            /* red   */ 64000, 33000,
-            /* green */ 30000, 60000,
-            /* blue  */ 15000,  6000
-         );
-   }
-
-   else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
-      png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);
-
-   /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit
-    * space must still be gamma encoded.
-    */
-   else
-      png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
-
-   /* Write the file header. */
-   png_write_info(png_ptr, info_ptr);
-
-   /* Now set up the data transformations (*after* the header is written),
-    * remove the handled transformations from the 'format' flags for checking.
-    *
-    * First check for a little endian system if writing 16-bit files.
-    */
-   if (write_16bit != 0)
-   {
-      PNG_CONST png_uint_16 le = 0x0001;
-
-      if ((*(png_const_bytep) & le) != 0)
-         png_set_swap(png_ptr);
-   }
-
-#   ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
-      if ((format & PNG_FORMAT_FLAG_BGR) != 0)
-      {
-         if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0)
-            png_set_bgr(png_ptr);
-         format &= ~PNG_FORMAT_FLAG_BGR;
-      }
-#   endif
-
-#   ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
-      if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
-      {
-         if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
-            png_set_swap_alpha(png_ptr);
-         format &= ~PNG_FORMAT_FLAG_AFIRST;
-      }
-#   endif
-
-   /* If there are 16 or fewer color-map entries we wrote a lower bit depth
-    * above, but the application data is still byte packed.
-    */
-   if (colormap != 0 && image->colormap_entries <= 16)
-      png_set_packing(png_ptr);
-
-   /* That should have handled all (both) the transforms. */
-   if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR |
-         PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0)
-      png_error(png_ptr, "png_write_image: unsupported transformation");
-
-   {
-      png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);
-      ptrdiff_t row_bytes = display->row_stride;
-
-      if (linear != 0)
-         row_bytes *= (sizeof (png_uint_16));
-
-      if (row_bytes < 0)
-         row += (image->height-1) * (-row_bytes);
-
-      display->first_row = row;
-      display->row_bytes = row_bytes;
-   }
-
-   /* Apply 'fast' options if the flag is set. */
-   if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)
-   {
-      png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
-      /* NOTE: determined by experiment using pngstest, this reflects some
-       * balance between the time to write the image once and the time to read
-       * it about 50 times.  The speed-up in pngstest was about 10-20% of the
-       * total (user) time on a heavily loaded system.
-       */
-#   ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-      png_set_compression_level(png_ptr, 3);
-#   endif
-   }
-
-   /* Check for the cases that currently require a pre-transform on the row
-    * before it is written.  This only applies when the input is 16-bit and
-    * either there is an alpha channel or it is converted to 8-bit.
-    */
-   if ((linear != 0 && alpha != 0 ) ||
-       (colormap == 0 && display->convert_to_8bit != 0))
-   {
-      png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
-         png_get_rowbytes(png_ptr, info_ptr)));
-      int result;
-
-      display->local_row = row;
-      if (write_16bit != 0)
-         result = png_safe_execute(image, png_write_image_16bit, display);
-      else
-         result = png_safe_execute(image, png_write_image_8bit, display);
-      display->local_row = NULL;
-
-      png_free(png_ptr, row);
-
-      /* Skip the 'write_end' on error: */
-      if (result == 0)
-         return 0;
-   }
-
-   /* Otherwise this is the case where the input is in a format currently
-    * supported by the rest of the libpng write code; call it directly.
-    */
-   else
-   {
-      png_const_bytep row = png_voidcast(png_const_bytep, display->first_row);
-      ptrdiff_t row_bytes = display->row_bytes;
-      png_uint_32 y = image->height;
-
-      while (y-- > 0)
-      {
-         png_write_row(png_ptr, row);
-         row += row_bytes;
-      }
-   }
-
-   png_write_end(png_ptr, info_ptr);
-   return 1;
-}
-
-
-static void (PNGCBAPI
-image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
-   png_size_t size)
-{
-   png_image_write_control *display = png_voidcast(png_image_write_control*,
-      png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
-   const png_alloc_size_t ob = display->output_bytes;
-
-   /* Check for overflow; this should never happen: */
-   if (size <= ((png_alloc_size_t)-1) - ob)
-   {
-      /* I don't think libpng ever does this, but just in case: */
-      if (size > 0)
-      {
-         if (display->memory_bytes >= ob+size) /* writing */
-            memcpy(display->memory+ob, data, size);
-
-         /* Always update the size: */
-         display->output_bytes = ob+size;
-      }
-   }
-
-   else
-      png_error(png_ptr, "png_image_write_to_memory: PNG too big");
-}
-
-static void (PNGCBAPI
-image_memory_flush)(png_structp png_ptr)
-{
-   PNG_UNUSED(png_ptr)
-}
-
-static int
-png_image_write_memory(png_voidp argument)
-{
-   png_image_write_control *display = png_voidcast(png_image_write_control*,
-      argument);
-
-   /* The rest of the memory-specific init and write_main in an error protected
-    * environment.  This case needs to use callbacks for the write operations
-    * since libpng has no built in support for writing to memory.
-    */
-   png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
-         image_memory_write, image_memory_flush);
-
-   return png_image_write_main(display);
-}
-
-int PNGAPI
-png_image_write_to_memory(png_imagep image, void *memory,
-   png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
-   const void *buffer, png_int_32 row_stride, const void *colormap)
-{
-   /* Write the image to the given buffer, or count the bytes if it is NULL */
-   if (image != NULL && image->version == PNG_IMAGE_VERSION)
-   {
-      if (memory_bytes != NULL && buffer != NULL)
-      {
-         /* This is to give the caller an easier error detection in the NULL
-          * case and guard against uninitialized variable problems:
-          */
-         if (memory == NULL)
-            *memory_bytes = 0;
-
-         if (png_image_write_init(image) != 0)
-         {
-            png_image_write_control display;
-            int result;
-
-            memset(&display, 0, (sizeof display));
-            display.image = image;
-            display.buffer = buffer;
-            display.row_stride = row_stride;
-            display.colormap = colormap;
-            display.convert_to_8bit = convert_to_8bit;
-            display.memory = png_voidcast(png_bytep, memory);
-            display.memory_bytes = *memory_bytes;
-            display.output_bytes = 0;
-
-            result = png_safe_execute(image, png_image_write_memory, &display);
-            png_image_free(image);
-
-            /* write_memory returns true even if we ran out of buffer. */
-            if (result)
-            {
-               /* On out-of-buffer this function returns '0' but still updates
-                * memory_bytes:
-                */
-               if (memory != NULL && display.output_bytes > *memory_bytes)
-                  result = 0;
-
-               *memory_bytes = display.output_bytes;
-            }
-
-            return result;
-         }
-
-         else
-            return 0;
-      }
-
-      else
-         return png_image_error(image,
-            "png_image_write_to_memory: invalid argument");
-   }
-
-   else if (image != NULL)
-      return png_image_error(image,
-         "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
-
-   else
-      return 0;
-}
-
-#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-int PNGAPI
-png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
-   const void *buffer, png_int_32 row_stride, const void *colormap)
-{
-   /* Write the image to the given (FILE*). */
-   if (image != NULL && image->version == PNG_IMAGE_VERSION)
-   {
-      if (file != NULL && buffer != NULL)
-      {
-         if (png_image_write_init(image) != 0)
-         {
-            png_image_write_control display;
-            int result;
-
-            /* This is slightly evil, but png_init_io doesn't do anything other
-             * than this and we haven't changed the standard IO functions so
-             * this saves a 'safe' function.
-             */
-            image->opaque->png_ptr->io_ptr = file;
-
-            memset(&display, 0, (sizeof display));
-            display.image = image;
-            display.buffer = buffer;
-            display.row_stride = row_stride;
-            display.colormap = colormap;
-            display.convert_to_8bit = convert_to_8bit;
-
-            result = png_safe_execute(image, png_image_write_main, &display);
-            png_image_free(image);
-            return result;
-         }
-
-         else
-            return 0;
-      }
-
-      else
-         return png_image_error(image,
-            "png_image_write_to_stdio: invalid argument");
-   }
-
-   else if (image != NULL)
-      return png_image_error(image,
-         "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
-
-   else
-      return 0;
-}
-
-int PNGAPI
-png_image_write_to_file(png_imagep image, const char *file_name,
-   int convert_to_8bit, const void *buffer, png_int_32 row_stride,
-   const void *colormap)
-{
-   /* Write the image to the named file. */
-   if (image != NULL && image->version == PNG_IMAGE_VERSION)
-   {
-      if (file_name != NULL && buffer != NULL)
-      {
-         FILE *fp = fopen(file_name, "wb");
-
-         if (fp != NULL)
-         {
-            if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
-               row_stride, colormap) != 0)
-            {
-               int error; /* from fflush/fclose */
-
-               /* Make sure the file is flushed correctly. */
-               if (fflush(fp) == 0 && ferror(fp) == 0)
-               {
-                  if (fclose(fp) == 0)
-                     return 1;
-
-                  error = errno; /* from fclose */
-               }
-
-               else
-               {
-                  error = errno; /* from fflush or ferror */
-                  (void)fclose(fp);
-               }
-
-               (void)remove(file_name);
-               /* The image has already been cleaned up; this is just used to
-                * set the error (because the original write succeeded).
-                */
-               return png_image_error(image, strerror(error));
-            }
-
-            else
-            {
-               /* Clean up: just the opened file. */
-               (void)fclose(fp);
-               (void)remove(file_name);
-               return 0;
-            }
-         }
-
-         else
-            return png_image_error(image, strerror(errno));
-      }
-
-      else
-         return png_image_error(image,
-            "png_image_write_to_file: invalid argument");
-   }
-
-   else if (image != NULL)
-      return png_image_error(image,
-         "png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
-
-   else
-      return 0;
-}
-#endif /* SIMPLIFIED_WRITE_STDIO */
-#endif /* SIMPLIFIED_WRITE */
-#endif /* WRITE */
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwtran.c	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,604 +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.
- */
-
-/* pngwtran.c - transforms the data in a row for PNG writers
- *
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.6.18 [July 23, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-
-#ifdef PNG_WRITE_PACK_SUPPORTED
-/* Pack pixels into bytes.  Pass the true bit depth in bit_depth.  The
- * row_info bit depth should be 8 (one pixel per byte).  The channels
- * should be 1 (this only happens on grayscale and paletted images).
- */
-static void
-png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
-{
-   png_debug(1, "in png_do_pack");
-
-   if (row_info->bit_depth == 8 &&
-      row_info->channels == 1)
-   {
-      switch ((int)bit_depth)
-      {
-         case 1:
-         {
-            png_bytep sp, dp;
-            int mask, v;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            sp = row;
-            dp = row;
-            mask = 0x80;
-            v = 0;
-
-            for (i = 0; i < row_width; i++)
-            {
-               if (*sp != 0)
-                  v |= mask;
-
-               sp++;
-
-               if (mask > 1)
-                  mask >>= 1;
-
-               else
-               {
-                  mask = 0x80;
-                  *dp = (png_byte)v;
-                  dp++;
-                  v = 0;
-               }
-            }
-
-            if (mask != 0x80)
-               *dp = (png_byte)v;
-
-            break;
-         }
-
-         case 2:
-         {
-            png_bytep sp, dp;
-            unsigned int shift;
-            int v;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            sp = row;
-            dp = row;
-            shift = 6;
-            v = 0;
-
-            for (i = 0; i < row_width; i++)
-            {
-               png_byte value;
-
-               value = (png_byte)(*sp & 0x03);
-               v |= (value << shift);
-
-               if (shift == 0)
-               {
-                  shift = 6;
-                  *dp = (png_byte)v;
-                  dp++;
-                  v = 0;
-               }
-
-               else
-                  shift -= 2;
-
-               sp++;
-            }
-
-            if (shift != 6)
-               *dp = (png_byte)v;
-
-            break;
-         }
-
-         case 4:
-         {
-            png_bytep sp, dp;
-            unsigned int shift;
-            int v;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            sp = row;
-            dp = row;
-            shift = 4;
-            v = 0;
-
-            for (i = 0; i < row_width; i++)
-            {
-               png_byte value;
-
-               value = (png_byte)(*sp & 0x0f);
-               v |= (value << shift);
-
-               if (shift == 0)
-               {
-                  shift = 4;
-                  *dp = (png_byte)v;
-                  dp++;
-                  v = 0;
-               }
-
-               else
-                  shift -= 4;
-
-               sp++;
-            }
-
-            if (shift != 4)
-               *dp = (png_byte)v;
-
-            break;
-         }
-
-         default:
-            break;
-      }
-
-      row_info->bit_depth = (png_byte)bit_depth;
-      row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
-      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
-          row_info->width);
-   }
-}
-#endif
-
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
-/* Shift pixel values to take advantage of whole range.  Pass the
- * true number of bits in bit_depth.  The row should be packed
- * according to row_info->bit_depth.  Thus, if you had a row of
- * bit depth 4, but the pixels only had values from 0 to 7, you
- * would pass 3 as bit_depth, and this routine would translate the
- * data to 0 to 15.
- */
-static void
-png_do_shift(png_row_infop row_info, png_bytep row,
-    png_const_color_8p bit_depth)
-{
-   png_debug(1, "in png_do_shift");
-
-   if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
-   {
-      int shift_start[4], shift_dec[4];
-      int channels = 0;
-
-      if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
-      {
-         shift_start[channels] = row_info->bit_depth - bit_depth->red;
-         shift_dec[channels] = bit_depth->red;
-         channels++;
-
-         shift_start[channels] = row_info->bit_depth - bit_depth->green;
-         shift_dec[channels] = bit_depth->green;
-         channels++;
-
-         shift_start[channels] = row_info->bit_depth - bit_depth->blue;
-         shift_dec[channels] = bit_depth->blue;
-         channels++;
-      }
-
-      else
-      {
-         shift_start[channels] = row_info->bit_depth - bit_depth->gray;
-         shift_dec[channels] = bit_depth->gray;
-         channels++;
-      }
-
-      if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
-      {
-         shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
-         shift_dec[channels] = bit_depth->alpha;
-         channels++;
-      }
-
-      /* With low row depths, could only be grayscale, so one channel */
-      if (row_info->bit_depth < 8)
-      {
-         png_bytep bp = row;
-         png_size_t i;
-         unsigned int mask;
-         png_size_t row_bytes = row_info->rowbytes;
-
-         if (bit_depth->gray == 1 && row_info->bit_depth == 2)
-            mask = 0x55;
-
-         else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
-            mask = 0x11;
-
-         else
-            mask = 0xff;
-
-         for (i = 0; i < row_bytes; i++, bp++)
-         {
-            int j;
-            unsigned int v, out;
-
-            v = *bp;
-            out = 0;
-
-            for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
-            {
-               if (j > 0)
-                  out |= v << j;
-
-               else
-                  out |= (v >> (-j)) & mask;
-            }
-
-            *bp = (png_byte)(out & 0xff);
-         }
-      }
-
-      else if (row_info->bit_depth == 8)
-      {
-         png_bytep bp = row;
-         png_uint_32 i;
-         png_uint_32 istop = channels * row_info->width;
-
-         for (i = 0; i < istop; i++, bp++)
-         {
-
-            const unsigned int c = i%channels;
-            int j;
-            unsigned int v, out;
-
-            v = *bp;
-            out = 0;
-
-            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
-            {
-               if (j > 0)
-                  out |= v << j;
-
-               else
-                  out |= v >> (-j);
-            }
-
-            *bp = (png_byte)(out & 0xff);
-         }
-      }
-
-      else
-      {
-         png_bytep bp;
-         png_uint_32 i;
-         png_uint_32 istop = channels * row_info->width;
-
-         for (bp = row, i = 0; i < istop; i++)
-         {
-            const unsigned int c = i%channels;
-            int j;
-            unsigned int value, v;
-
-            v = png_get_uint_16(bp);
-            value = 0;
-
-            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
-            {
-               if (j > 0)
-                  value |= v << j;
-
-               else
-                  value |= v >> (-j);
-            }
-            *bp++ = (png_byte)((value >> 8) & 0xff);
-            *bp++ = (png_byte)(value & 0xff);
-         }
-      }
-   }
-}
-#endif
-
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
-static void
-png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
-{
-   png_debug(1, "in png_do_write_swap_alpha");
-
-   {
-      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-      {
-         if (row_info->bit_depth == 8)
-         {
-            /* This converts from ARGB to RGBA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               png_byte save = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = save;
-            }
-         }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         else
-         {
-            /* This converts from AARRGGBB to RRGGBBAA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               png_byte save[2];
-               save[0] = *(sp++);
-               save[1] = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = save[0];
-               *(dp++) = save[1];
-            }
-         }
-#endif /* WRITE_16BIT */
-      }
-
-      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-      {
-         if (row_info->bit_depth == 8)
-         {
-            /* This converts from AG to GA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               png_byte save = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = save;
-            }
-         }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         else
-         {
-            /* This converts from AAGG to GGAA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               png_byte save[2];
-               save[0] = *(sp++);
-               save[1] = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = save[0];
-               *(dp++) = save[1];
-            }
-         }
-#endif /* WRITE_16BIT */
-      }
-   }
-}
-#endif
-
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
-static void
-png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
-{
-   png_debug(1, "in png_do_write_invert_alpha");
-
-   {
-      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-      {
-         if (row_info->bit_depth == 8)
-         {
-            /* This inverts the alpha channel in RGBA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               /* Does nothing
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               */
-               sp+=3; dp = sp;
-               *dp = (png_byte)(255 - *(sp++));
-            }
-         }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         else
-         {
-            /* This inverts the alpha channel in RRGGBBAA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               /* Does nothing
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               */
-               sp+=6; dp = sp;
-               *(dp++) = (png_byte)(255 - *(sp++));
-               *dp     = (png_byte)(255 - *(sp++));
-            }
-         }
-#endif /* WRITE_16BIT */
-      }
-
-      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-      {
-         if (row_info->bit_depth == 8)
-         {
-            /* This inverts the alpha channel in GA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               *(dp++) = *(sp++);
-               *(dp++) = (png_byte)(255 - *(sp++));
-            }
-         }
-
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         else
-         {
-            /* This inverts the alpha channel in GGAA */
-            png_bytep sp, dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            for (i = 0, sp = dp = row; i < row_width; i++)
-            {
-               /* Does nothing
-               *(dp++) = *(sp++);
-               *(dp++) = *(sp++);
-               */
-               sp+=2; dp = sp;
-               *(dp++) = (png_byte)(255 - *(sp++));
-               *dp     = (png_byte)(255 - *(sp++));
-            }
-         }
-#endif /* WRITE_16BIT */
-      }
-   }
-}
-#endif
-
-/* Transform the data according to the user's wishes.  The order of
- * transformations is significant.
- */
-void /* PRIVATE */
-png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
-{
-   png_debug(1, "in png_do_write_transformations");
-
-   if (png_ptr == NULL)
-      return;
-
-#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-   if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
-      if (png_ptr->write_user_transform_fn != NULL)
-         (*(png_ptr->write_user_transform_fn)) /* User write transform
-                                                 function */
-             (png_ptr,  /* png_ptr */
-             row_info,  /* row_info: */
-                /*  png_uint_32 width;       width of row */
-                /*  png_size_t rowbytes;     number of bytes in row */
-                /*  png_byte color_type;     color type of pixels */
-                /*  png_byte bit_depth;      bit depth of samples */
-                /*  png_byte channels;       number of channels (1-4) */
-                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */
-             png_ptr->row_buf + 1);      /* start of pixel data for row */
-#endif
-
-#ifdef PNG_WRITE_FILLER_SUPPORTED
-   if ((png_ptr->transformations & PNG_FILLER) != 0)
-      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
-         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
-#endif
-
-#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
-   if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
-      png_do_packswap(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_PACK_SUPPORTED
-   if ((png_ptr->transformations & PNG_PACK) != 0)
-      png_do_pack(row_info, png_ptr->row_buf + 1,
-          (png_uint_32)png_ptr->bit_depth);
-#endif
-
-#ifdef PNG_WRITE_SWAP_SUPPORTED
-#  ifdef PNG_16BIT_SUPPORTED
-   if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
-      png_do_swap(row_info, png_ptr->row_buf + 1);
-#  endif
-#endif
-
-#ifdef PNG_WRITE_SHIFT_SUPPORTED
-   if ((png_ptr->transformations & PNG_SHIFT) != 0)
-      png_do_shift(row_info, png_ptr->row_buf + 1,
-          &(png_ptr->shift));
-#endif
-
-#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
-   if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
-      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
-   if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
-      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_BGR_SUPPORTED
-   if ((png_ptr->transformations & PNG_BGR) != 0)
-      png_do_bgr(row_info, png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_WRITE_INVERT_SUPPORTED
-   if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
-      png_do_invert(row_info, png_ptr->row_buf + 1);
-#endif
-}
-#endif /* WRITE_TRANSFORMS */
-#endif /* WRITE */
--- a/jdk/src/java.desktop/share/native/libsplashscreen/libpng/pngwutil.c	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2653 +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.
- */
-
-/* pngwutil.c - utilities to write a PNG file
- *
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file and, per its terms, should not be removed:
- *
- * Last changed in libpng 1.6.22 [May 26, 2016]
- * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This code is released under the libpng license.
- * For conditions of distribution and use, see the disclaimer
- * and license in png.h
- */
-
-#include "pngpriv.h"
-
-#ifdef PNG_WRITE_SUPPORTED
-
-#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-/* Place a 32-bit number into a buffer in PNG byte order.  We work
- * with unsigned numbers for convenience, although one supported
- * ancillary chunk uses signed (two's complement) numbers.
- */
-void PNGAPI
-png_save_uint_32(png_bytep buf, png_uint_32 i)
-{
-   buf[0] = (png_byte)((i >> 24) & 0xffU);
-   buf[1] = (png_byte)((i >> 16) & 0xffU);
-   buf[2] = (png_byte)((i >>  8) & 0xffU);
-   buf[3] = (png_byte)( i        & 0xffU);
-}
-
-/* Place a 16-bit number into a buffer in PNG byte order.
- * The parameter is declared unsigned int, not png_uint_16,
- * just to avoid potential problems on pre-ANSI C compilers.
- */
-void PNGAPI
-png_save_uint_16(png_bytep buf, unsigned int i)
-{
-   buf[0] = (png_byte)((i >> 8) & 0xffU);
-   buf[1] = (png_byte)( i       & 0xffU);
-}
-#endif
-
-/* Simple function to write the signature.  If we have already written
- * the magic bytes of the signature, or more likely, the PNG stream is
- * being embedded into another stream and doesn't need its own signature,
- * we should call png_set_sig_bytes() to tell libpng how many of the
- * bytes have already been written.
- */
-void PNGAPI
-png_write_sig(png_structrp png_ptr)
-{
-   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   /* Inform the I/O callback that the signature is being written */
-   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;
-#endif
-
-   /* Write the rest of the 8 byte signature */
-   png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
-      (png_size_t)(8 - png_ptr->sig_bytes));
-
-   if (png_ptr->sig_bytes < 3)
-      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
-}
-
-/* Write the start of a PNG chunk.  The type is the chunk type.
- * The total_length is the sum of the lengths of all the data you will be
- * passing in png_write_chunk_data().
- */
-static void
-png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name,
-    png_uint_32 length)
-{
-   png_byte buf[8];
-
-#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
-   PNG_CSTRING_FROM_CHUNK(buf, chunk_name);
-   png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length);
-#endif
-
-   if (png_ptr == NULL)
-      return;
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   /* Inform the I/O callback that the chunk header is being written.
-    * PNG_IO_CHUNK_HDR requires a single I/O call.
-    */
-   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;
-#endif
-
-   /* Write the length and the chunk name */
-   png_save_uint_32(buf, length);
-   png_save_uint_32(buf + 4, chunk_name);
-   png_write_data(png_ptr, buf, 8);
-
-   /* Put the chunk name into png_ptr->chunk_name */
-   png_ptr->chunk_name = chunk_name;
-
-   /* Reset the crc and run it over the chunk name */
-   png_reset_crc(png_ptr);
-
-   png_calculate_crc(png_ptr, buf + 4, 4);
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   /* Inform the I/O callback that chunk data will (possibly) be written.
-    * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
-    */
-   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA;
-#endif
-}
-
-void PNGAPI
-png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string,
-    png_uint_32 length)
-{
-   png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);
-}
-
-/* Write the data of a PNG chunk started with png_write_chunk_header().
- * Note that multiple calls to this function are allowed, and that the
- * sum of the lengths from these calls *must* add up to the total_length
- * given to png_write_chunk_header().
- */
-void PNGAPI
-png_write_chunk_data(png_structrp png_ptr, png_const_bytep data,
-    png_size_t length)
-{
-   /* Write the data, and run the CRC over it */
-   if (png_ptr == NULL)
-      return;
-
-   if (data != NULL && length > 0)
-   {
-      png_write_data(png_ptr, data, length);
-
-      /* Update the CRC after writing the data,
-       * in case the user I/O routine alters it.
-       */
-      png_calculate_crc(png_ptr, data, length);
-   }
-}
-
-/* Finish a chunk started with png_write_chunk_header(). */
-void PNGAPI
-png_write_chunk_end(png_structrp png_ptr)
-{
-   png_byte buf[4];
-
-   if (png_ptr == NULL) return;
-
-#ifdef PNG_IO_STATE_SUPPORTED
-   /* Inform the I/O callback that the chunk CRC is being written.
-    * PNG_IO_CHUNK_CRC requires a single I/O function call.
-    */
-   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;
-#endif
-
-   /* Write the crc in a single operation */
-   png_save_uint_32(buf, png_ptr->crc);
-
-   png_write_data(png_ptr, buf, (png_size_t)4);
-}
-
-/* Write a PNG chunk all at once.  The type is an array of ASCII characters
- * representing the chunk name.  The array must be at least 4 bytes in
- * length, and does not need to be null terminated.  To be safe, pass the
- * pre-defined chunk names here, and if you need a new one, define it
- * where the others are defined.  The length is the length of the data.
- * All the data must be present.  If that is not possible, use the
- * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
- * functions instead.
- */
-static void
-png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
-   png_const_bytep data, png_size_t length)
-{
-   if (png_ptr == NULL)
-      return;
-
-   /* On 64-bit architectures 'length' may not fit in a png_uint_32. */
-   if (length > PNG_UINT_31_MAX)
-      png_error(png_ptr, "length exceeds PNG maximum");
-
-   png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
-   png_write_chunk_data(png_ptr, data, length);
-   png_write_chunk_end(png_ptr);
-}
-
-/* This is the API that calls the internal function above. */
-void PNGAPI
-png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
-   png_const_bytep data, png_size_t length)
-{
-   png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
-      length);
-}
-
-/* This is used below to find the size of an image to pass to png_deflate_claim,
- * so it only needs to be accurate if the size is less than 16384 bytes (the
- * point at which a lower LZ window size can be used.)
- */
-static png_alloc_size_t
-png_image_size(png_structrp png_ptr)
-{
-   /* Only return sizes up to the maximum of a png_uint_32; do this by limiting
-    * the width and height used to 15 bits.
-    */
-   png_uint_32 h = png_ptr->height;
-
-   if (png_ptr->rowbytes < 32768 && h < 32768)
-   {
-      if (png_ptr->interlaced != 0)
-      {
-         /* Interlacing makes the image larger because of the replication of
-          * both the filter byte and the padding to a byte boundary.
-          */
-         png_uint_32 w = png_ptr->width;
-         unsigned int pd = png_ptr->pixel_depth;
-         png_alloc_size_t cb_base;
-         int pass;
-
-         for (cb_base=0, pass=0; pass<=6; ++pass)
-         {
-            png_uint_32 pw = PNG_PASS_COLS(w, pass);
-
-            if (pw > 0)
-               cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass);
-         }
-
-         return cb_base;
-      }
-
-      else
-         return (png_ptr->rowbytes+1) * h;
-   }
-
-   else
-      return 0xffffffffU;
-}
-
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
-   /* This is the code to hack the first two bytes of the deflate stream (the
-    * deflate header) to correct the windowBits value to match the actual data
-    * size.  Note that the second argument is the *uncompressed* size but the
-    * first argument is the *compressed* data (and it must be deflate
-    * compressed.)
-    */
-static void
-optimize_cmf(png_bytep data, png_alloc_size_t data_size)
-{
-   /* Optimize the CMF field in the zlib stream.  The resultant zlib stream is
-    * still compliant to the stream specification.
-    */
-   if (data_size <= 16384) /* else windowBits must be 15 */
-   {
-      unsigned int z_cmf = data[0];  /* zlib compression method and flags */
-
-      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
-      {
-         unsigned int z_cinfo;
-         unsigned int half_z_window_size;
-
-         z_cinfo = z_cmf >> 4;
-         half_z_window_size = 1U << (z_cinfo + 7);
-
-         if (data_size <= half_z_window_size) /* else no change */
-         {
-            unsigned int tmp;
-
-            do
-            {
-               half_z_window_size >>= 1;
-               --z_cinfo;
-            }
-            while (z_cinfo > 0 && data_size <= half_z_window_size);
-
-            z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
-
-            data[0] = (png_byte)z_cmf;
-            tmp = data[1] & 0xe0;
-            tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
-            data[1] = (png_byte)tmp;
-         }
-      }
-   }
-}
-#endif /* WRITE_OPTIMIZE_CMF */
-
-/* Initialize the compressor for the appropriate type of compression. */
-static int
-png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
-   png_alloc_size_t data_size)
-{
-   if (png_ptr->zowner != 0)
-   {
-#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
-      char msg[64];
-
-      PNG_STRING_FROM_CHUNK(msg, owner);
-      msg[4] = ':';
-      msg[5] = ' ';
-      PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner);
-      /* So the message that results is "<chunk> using zstream"; this is an
-       * internal error, but is very useful for debugging.  i18n requirements
-       * are minimal.
-       */
-      (void)png_safecat(msg, (sizeof msg), 10, " using zstream");
-#endif
-#if PNG_RELEASE_BUILD
-         png_warning(png_ptr, msg);
-
-         /* Attempt sane error recovery */
-         if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */
-         {
-            png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT");
-            return Z_STREAM_ERROR;
-         }
-
-         png_ptr->zowner = 0;
-#else
-         png_error(png_ptr, msg);
-#endif
-   }
-
-   {
-      int level = png_ptr->zlib_level;
-      int method = png_ptr->zlib_method;
-      int windowBits = png_ptr->zlib_window_bits;
-      int memLevel = png_ptr->zlib_mem_level;
-      int strategy; /* set below */
-      int ret; /* zlib return code */
-
-      if (owner == png_IDAT)
-      {
-         if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0)
-            strategy = png_ptr->zlib_strategy;
-
-         else if (png_ptr->do_filter != PNG_FILTER_NONE)
-            strategy = PNG_Z_DEFAULT_STRATEGY;
-
-         else
-            strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY;
-      }
-
-      else
-      {
-#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-            level = png_ptr->zlib_text_level;
-            method = png_ptr->zlib_text_method;
-            windowBits = png_ptr->zlib_text_window_bits;
-            memLevel = png_ptr->zlib_text_mem_level;
-            strategy = png_ptr->zlib_text_strategy;
-#else
-            /* If customization is not supported the values all come from the
-             * IDAT values except for the strategy, which is fixed to the
-             * default.  (This is the pre-1.6.0 behavior too, although it was
-             * implemented in a very different way.)
-             */
-            strategy = Z_DEFAULT_STRATEGY;
-#endif
-      }
-
-      /* Adjust 'windowBits' down if larger than 'data_size'; to stop this
-       * happening just pass 32768 as the data_size parameter.  Notice that zlib
-       * requires an extra 262 bytes in the window in addition to the data to be
-       * able to see the whole of the data, so if data_size+262 takes us to the
-       * next windowBits size we need to fix up the value later.  (Because even
-       * though deflate needs the extra window, inflate does not!)
-       */
-      if (data_size <= 16384)
-      {
-         /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to
-          * work round a Microsoft Visual C misbehavior which, contrary to C-90,
-          * widens the result of the following shift to 64-bits if (and,
-          * apparently, only if) it is used in a test.
-          */
-         unsigned int half_window_size = 1U << (windowBits-1);
-
-         while (data_size + 262 <= half_window_size)
-         {
-            half_window_size >>= 1;
-            --windowBits;
-         }
-      }
-
-      /* Check against the previous initialized values, if any. */
-      if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 &&
-         (png_ptr->zlib_set_level != level ||
-         png_ptr->zlib_set_method != method ||
-         png_ptr->zlib_set_window_bits != windowBits ||
-         png_ptr->zlib_set_mem_level != memLevel ||
-         png_ptr->zlib_set_strategy != strategy))
-      {
-         if (deflateEnd(&png_ptr->zstream) != Z_OK)
-            png_warning(png_ptr, "deflateEnd failed (ignored)");
-
-         png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED;
-      }
-
-      /* For safety clear out the input and output pointers (currently zlib
-       * doesn't use them on Init, but it might in the future).
-       */
-      png_ptr->zstream.next_in = NULL;
-      png_ptr->zstream.avail_in = 0;
-      png_ptr->zstream.next_out = NULL;
-      png_ptr->zstream.avail_out = 0;
-
-      /* Now initialize if required, setting the new parameters, otherwise just
-       * to a simple reset to the previous parameters.
-       */
-      if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
-         ret = deflateReset(&png_ptr->zstream);
-
-      else
-      {
-         ret = deflateInit2(&png_ptr->zstream, level, method, windowBits,
-            memLevel, strategy);
-
-         if (ret == Z_OK)
-            png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
-      }
-
-      /* The return code is from either deflateReset or deflateInit2; they have
-       * pretty much the same set of error codes.
-       */
-      if (ret == Z_OK)
-         png_ptr->zowner = owner;
-
-      else
-         png_zstream_error(png_ptr, ret);
-
-      return ret;
-   }
-}
-
-/* Clean up (or trim) a linked list of compression buffers. */
-void /* PRIVATE */
-png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp)
-{
-   png_compression_bufferp list = *listp;
-
-   if (list != NULL)
-   {
-      *listp = NULL;
-
-      do
-      {
-         png_compression_bufferp next = list->next;
-
-         png_free(png_ptr, list);
-         list = next;
-      }
-      while (list != NULL);
-   }
-}
-
-#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
-/* This pair of functions encapsulates the operation of (a) compressing a
- * text string, and (b) issuing it later as a series of chunk data writes.
- * The compression_state structure is shared context for these functions
- * set up by the caller to allow access to the relevant local variables.
- *
- * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size
- * temporary buffers.  From 1.6.0 it is retained in png_struct so that it will
- * be correctly freed in the event of a write error (previous implementations
- * just leaked memory.)
- */
-typedef struct
-{
-   png_const_bytep      input;        /* The uncompressed input data */
-   png_alloc_size_t     input_len;    /* Its length */
-   png_uint_32          output_len;   /* Final compressed length */
-   png_byte             output[1024]; /* First block of output */
-} compression_state;
-
-static void
-png_text_compress_init(compression_state *comp, png_const_bytep input,
-   png_alloc_size_t input_len)
-{
-   comp->input = input;
-   comp->input_len = input_len;
-   comp->output_len = 0;
-}
-
-/* Compress the data in the compression state input */
-static int
-png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
-   compression_state *comp, png_uint_32 prefix_len)
-{
-   int ret;
-
-   /* To find the length of the output it is necessary to first compress the
-    * input. The result is buffered rather than using the two-pass algorithm
-    * that is used on the inflate side; deflate is assumed to be slower and a
-    * PNG writer is assumed to have more memory available than a PNG reader.
-    *
-    * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an
-    * upper limit on the output size, but it is always bigger than the input
-    * size so it is likely to be more efficient to use this linked-list
-    * approach.
-    */
-   ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len);
-
-   if (ret != Z_OK)
-      return ret;
-
-   /* Set up the compression buffers, we need a loop here to avoid overflowing a
-    * uInt.  Use ZLIB_IO_MAX to limit the input.  The output is always limited
-    * by the output buffer size, so there is no need to check that.  Since this
-    * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits
-    * in size.
-    */
-   {
-      png_compression_bufferp *end = &png_ptr->zbuffer_list;
-      png_alloc_size_t input_len = comp->input_len; /* may be zero! */
-      png_uint_32 output_len;
-
-      /* zlib updates these for us: */
-      png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input);
-      png_ptr->zstream.avail_in = 0; /* Set below */
-      png_ptr->zstream.next_out = comp->output;
-      png_ptr->zstream.avail_out = (sizeof comp->output);
-
-      output_len = png_ptr->zstream.avail_out;
-
-      do
-      {
-         uInt avail_in = ZLIB_IO_MAX;
-
-         if (avail_in > input_len)
-            avail_in = (uInt)input_len;
-
-         input_len -= avail_in;
-
-         png_ptr->zstream.avail_in = avail_in;
-
-         if (png_ptr->zstream.avail_out == 0)
-         {
-            png_compression_buffer *next;
-
-            /* Chunk data is limited to 2^31 bytes in length, so the prefix
-             * length must be counted here.
-             */
-            if (output_len + prefix_len > PNG_UINT_31_MAX)
-            {
-               ret = Z_MEM_ERROR;
-               break;
-            }
-
-            /* Need a new (malloc'ed) buffer, but there may be one present
-             * already.
-             */
-            next = *end;
-            if (next == NULL)
-            {
-               next = png_voidcast(png_compression_bufferp, png_malloc_base
-                  (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));
-
-               if (next == NULL)
-               {
-                  ret = Z_MEM_ERROR;
-                  break;
-               }
-
-               /* Link in this buffer (so that it will be freed later) */
-               next->next = NULL;
-               *end = next;
-            }
-
-            png_ptr->zstream.next_out = next->output;
-            png_ptr->zstream.avail_out = png_ptr->zbuffer_size;
-            output_len += png_ptr->zstream.avail_out;
-
-            /* Move 'end' to the next buffer pointer. */
-            end = &next->next;
-         }
-
-         /* Compress the data */
-         ret = deflate(&png_ptr->zstream,
-            input_len > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-         /* Claw back input data that was not consumed (because avail_in is
-          * reset above every time round the loop).
-          */
-         input_len += png_ptr->zstream.avail_in;
-         png_ptr->zstream.avail_in = 0; /* safety */
-      }
-      while (ret == Z_OK);
-
-      /* There may be some space left in the last output buffer. This needs to
-       * be subtracted from output_len.
-       */
-      output_len -= png_ptr->zstream.avail_out;
-      png_ptr->zstream.avail_out = 0; /* safety */
-      comp->output_len = output_len;
-
-      /* Now double check the output length, put in a custom message if it is
-       * too long.  Otherwise ensure the z_stream::msg pointer is set to
-       * something.
-       */
-      if (output_len + prefix_len >= PNG_UINT_31_MAX)
-      {
-         png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long");
-         ret = Z_MEM_ERROR;
-      }
-
-      else
-         png_zstream_error(png_ptr, ret);
-
-      /* Reset zlib for another zTXt/iTXt or image data */
-      png_ptr->zowner = 0;
-
-      /* The only success case is Z_STREAM_END, input_len must be 0; if not this
-       * is an internal error.
-       */
-      if (ret == Z_STREAM_END && input_len == 0)
-      {
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
-         /* Fix up the deflate header, if required */
-         optimize_cmf(comp->output, comp->input_len);
-#endif
-         /* But Z_OK is returned, not Z_STREAM_END; this allows the claim
-          * function above to return Z_STREAM_END on an error (though it never
-          * does in the current versions of zlib.)
-          */
-         return Z_OK;
-      }
-
-      else
-         return ret;
-   }
-}
-
-/* Ship the compressed text out via chunk writes */
-static void
-png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
-{
-   png_uint_32 output_len = comp->output_len;
-   png_const_bytep output = comp->output;
-   png_uint_32 avail = (sizeof comp->output);
-   png_compression_buffer *next = png_ptr->zbuffer_list;
-
-   for (;;)
-   {
-      if (avail > output_len)
-         avail = output_len;
-
-      png_write_chunk_data(png_ptr, output, avail);
-
-      output_len -= avail;
-
-      if (output_len == 0 || next == NULL)
-         break;
-
-      avail = png_ptr->zbuffer_size;
-      output = next->output;
-      next = next->next;
-   }
-
-   /* This is an internal error; 'next' must have been NULL! */
-   if (output_len > 0)
-      png_error(png_ptr, "error writing ancillary chunked compressed data");
-}
-#endif /* WRITE_COMPRESSED_TEXT */
-
-/* Write the IHDR chunk, and update the png_struct with the necessary
- * information.  Note that the rest of this code depends upon this
- * information being correct.
- */
-void /* PRIVATE */
-png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
-    int bit_depth, int color_type, int compression_type, int filter_type,
-    int interlace_type)
-{
-   png_byte buf[13]; /* Buffer to store the IHDR info */
-
-   png_debug(1, "in png_write_IHDR");
-
-   /* Check that we have valid input data from the application info */
-   switch (color_type)
-   {
-      case PNG_COLOR_TYPE_GRAY:
-         switch (bit_depth)
-         {
-            case 1:
-            case 2:
-            case 4:
-            case 8:
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-            case 16:
-#endif
-               png_ptr->channels = 1; break;
-
-            default:
-               png_error(png_ptr,
-                   "Invalid bit depth for grayscale image");
-         }
-         break;
-
-      case PNG_COLOR_TYPE_RGB:
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         if (bit_depth != 8 && bit_depth != 16)
-#else
-         if (bit_depth != 8)
-#endif
-            png_error(png_ptr, "Invalid bit depth for RGB image");
-
-         png_ptr->channels = 3;
-         break;
-
-      case PNG_COLOR_TYPE_PALETTE:
-         switch (bit_depth)
-         {
-            case 1:
-            case 2:
-            case 4:
-            case 8:
-               png_ptr->channels = 1;
-               break;
-
-            default:
-               png_error(png_ptr, "Invalid bit depth for paletted image");
-         }
-         break;
-
-      case PNG_COLOR_TYPE_GRAY_ALPHA:
-         if (bit_depth != 8 && bit_depth != 16)
-            png_error(png_ptr, "Invalid bit depth for grayscale+alpha image");
-
-         png_ptr->channels = 2;
-         break;
-
-      case PNG_COLOR_TYPE_RGB_ALPHA:
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-         if (bit_depth != 8 && bit_depth != 16)
-#else
-         if (bit_depth != 8)
-#endif
-            png_error(png_ptr, "Invalid bit depth for RGBA image");
-
-         png_ptr->channels = 4;
-         break;
-
-      default:
-         png_error(png_ptr, "Invalid image color type specified");
-   }
-
-   if (compression_type != PNG_COMPRESSION_TYPE_BASE)
-   {
-      png_warning(png_ptr, "Invalid compression type specified");
-      compression_type = PNG_COMPRESSION_TYPE_BASE;
-   }
-
-   /* Write filter_method 64 (intrapixel differencing) only if
-    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
-    * 2. Libpng did not write a PNG signature (this filter_method is only
-    *    used in PNG datastreams that are embedded in MNG datastreams) and
-    * 3. The application called png_permit_mng_features with a mask that
-    *    included PNG_FLAG_MNG_FILTER_64 and
-    * 4. The filter_method is 64 and
-    * 5. The color_type is RGB or RGBA
-    */
-   if (
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-       !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
-       ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
-       (color_type == PNG_COLOR_TYPE_RGB ||
-        color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
-       (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
-#endif
-       filter_type != PNG_FILTER_TYPE_BASE)
-   {
-      png_warning(png_ptr, "Invalid filter type specified");
-      filter_type = PNG_FILTER_TYPE_BASE;
-   }
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   if (interlace_type != PNG_INTERLACE_NONE &&
-       interlace_type != PNG_INTERLACE_ADAM7)
-   {
-      png_warning(png_ptr, "Invalid interlace type specified");
-      interlace_type = PNG_INTERLACE_ADAM7;
-   }
-#else
-   interlace_type=PNG_INTERLACE_NONE;
-#endif
-
-   /* Save the relevant information */
-   png_ptr->bit_depth = (png_byte)bit_depth;
-   png_ptr->color_type = (png_byte)color_type;
-   png_ptr->interlaced = (png_byte)interlace_type;
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-   png_ptr->filter_type = (png_byte)filter_type;
-#endif
-   png_ptr->compression_type = (png_byte)compression_type;
-   png_ptr->width = width;
-   png_ptr->height = height;
-
-   png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
-   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
-   /* Set the usr info, so any transformations can modify it */
-   png_ptr->usr_width = png_ptr->width;
-   png_ptr->usr_bit_depth = png_ptr->bit_depth;
-   png_ptr->usr_channels = png_ptr->channels;
-
-   /* Pack the header information into the buffer */
-   png_save_uint_32(buf, width);
-   png_save_uint_32(buf + 4, height);
-   buf[8] = (png_byte)bit_depth;
-   buf[9] = (png_byte)color_type;
-   buf[10] = (png_byte)compression_type;
-   buf[11] = (png_byte)filter_type;
-   buf[12] = (png_byte)interlace_type;
-
-   /* Write the chunk */
-   png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
-
-   if ((png_ptr->do_filter) == PNG_NO_FILTERS)
-   {
-      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
-          png_ptr->bit_depth < 8)
-         png_ptr->do_filter = PNG_FILTER_NONE;
-
-      else
-         png_ptr->do_filter = PNG_ALL_FILTERS;
-   }
-
-   png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */
-}
-
-/* Write the palette.  We are careful not to trust png_color to be in the
- * correct order for PNG, so people can redefine it to any convenient
- * structure.
- */
-void /* PRIVATE */
-png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
-    png_uint_32 num_pal)
-{
-   png_uint_32 max_palette_length, i;
-   png_const_colorp pal_ptr;
-   png_byte buf[3];
-
-   png_debug(1, "in png_write_PLTE");
-
-   max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
-      (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
-
-   if ((
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-       (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
-#endif
-       num_pal == 0) || num_pal > max_palette_length)
-   {
-      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-      {
-         png_error(png_ptr, "Invalid number of colors in palette");
-      }
-
-      else
-      {
-         png_warning(png_ptr, "Invalid number of colors in palette");
-         return;
-      }
-   }
-
-   if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
-   {
-      png_warning(png_ptr,
-          "Ignoring request to write a PLTE chunk in grayscale PNG");
-
-      return;
-   }
-
-   png_ptr->num_palette = (png_uint_16)num_pal;
-   png_debug1(3, "num_palette = %d", png_ptr->num_palette);
-
-   png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
-
-   for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
-   {
-      buf[0] = pal_ptr->red;
-      buf[1] = pal_ptr->green;
-      buf[2] = pal_ptr->blue;
-      png_write_chunk_data(png_ptr, buf, (png_size_t)3);
-   }
-
-#else
-   /* This is a little slower but some buggy compilers need to do this
-    * instead
-    */
-   pal_ptr=palette;
-
-   for (i = 0; i < num_pal; i++)
-   {
-      buf[0] = pal_ptr[i].red;
-      buf[1] = pal_ptr[i].green;
-      buf[2] = pal_ptr[i].blue;
-      png_write_chunk_data(png_ptr, buf, (png_size_t)3);
-   }
-
-#endif
-   png_write_chunk_end(png_ptr);
-   png_ptr->mode |= PNG_HAVE_PLTE;
-}
-
-/* This is similar to png_text_compress, above, except that it does not require
- * all of the data at once and, instead of buffering the compressed result,
- * writes it as IDAT chunks.  Unlike png_text_compress it *can* png_error out
- * because it calls the write interface.  As a result it does its own error
- * reporting and does not return an error code.  In the event of error it will
- * just call png_error.  The input data length may exceed 32-bits.  The 'flush'
- * parameter is exactly the same as that to deflate, with the following
- * meanings:
- *
- * Z_NO_FLUSH: normal incremental output of compressed data
- * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush
- * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
- *
- * The routine manages the acquire and release of the png_ptr->zstream by
- * checking and (at the end) clearing png_ptr->zowner; it does some sanity
- * checks on the 'mode' flags while doing this.
- */
-void /* PRIVATE */
-png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
-   png_alloc_size_t input_len, int flush)
-{
-   if (png_ptr->zowner != png_IDAT)
-   {
-      /* First time.   Ensure we have a temporary buffer for compression and
-       * trim the buffer list if it has more than one entry to free memory.
-       * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been
-       * created at this point, but the check here is quick and safe.
-       */
-      if (png_ptr->zbuffer_list == NULL)
-      {
-         png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp,
-            png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));
-         png_ptr->zbuffer_list->next = NULL;
-      }
-
-      else
-         png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next);
-
-      /* It is a terminal error if we can't claim the zstream. */
-      if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK)
-         png_error(png_ptr, png_ptr->zstream.msg);
-
-      /* The output state is maintained in png_ptr->zstream, so it must be
-       * initialized here after the claim.
-       */
-      png_ptr->zstream.next_out = png_ptr->zbuffer_list->output;
-      png_ptr->zstream.avail_out = png_ptr->zbuffer_size;
-   }
-
-   /* Now loop reading and writing until all the input is consumed or an error
-    * terminates the operation.  The _out values are maintained across calls to
-    * this function, but the input must be reset each time.
-    */
-   png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);
-   png_ptr->zstream.avail_in = 0; /* set below */
-   for (;;)
-   {
-      int ret;
-
-      /* INPUT: from the row data */
-      uInt avail = ZLIB_IO_MAX;
-
-      if (avail > input_len)
-         avail = (uInt)input_len; /* safe because of the check */
-
-      png_ptr->zstream.avail_in = avail;
-      input_len -= avail;
-
-      ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush);
-
-      /* Include as-yet unconsumed input */
-      input_len += png_ptr->zstream.avail_in;
-      png_ptr->zstream.avail_in = 0;
-
-      /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
-       * that these two zstream fields are preserved across the calls, therefore
-       * there is no need to set these up on entry to the loop.
-       */
-      if (png_ptr->zstream.avail_out == 0)
-      {
-         png_bytep data = png_ptr->zbuffer_list->output;
-         uInt size = png_ptr->zbuffer_size;
-
-         /* Write an IDAT containing the data then reset the buffer.  The
-          * first IDAT may need deflate header optimization.
-          */
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
-            if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
-                png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
-               optimize_cmf(data, png_image_size(png_ptr));
-#endif
-
-         png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-         png_ptr->mode |= PNG_HAVE_IDAT;
-
-         png_ptr->zstream.next_out = data;
-         png_ptr->zstream.avail_out = size;
-
-         /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with
-          * the same flush parameter until it has finished output, for NO_FLUSH
-          * it doesn't matter.
-          */
-         if (ret == Z_OK && flush != Z_NO_FLUSH)
-            continue;
-      }
-
-      /* The order of these checks doesn't matter much; it just affects which
-       * possible error might be detected if multiple things go wrong at once.
-       */
-      if (ret == Z_OK) /* most likely return code! */
-      {
-         /* If all the input has been consumed then just return.  If Z_FINISH
-          * was used as the flush parameter something has gone wrong if we get
-          * here.
-          */
-         if (input_len == 0)
-         {
-            if (flush == Z_FINISH)
-               png_error(png_ptr, "Z_OK on Z_FINISH with output space");
-
-            return;
-         }
-      }
-
-      else if (ret == Z_STREAM_END && flush == Z_FINISH)
-      {
-         /* This is the end of the IDAT data; any pending output must be
-          * flushed.  For small PNG files we may still be at the beginning.
-          */
-         png_bytep data = png_ptr->zbuffer_list->output;
-         uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;
-
-#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
-         if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
-             png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
-            optimize_cmf(data, png_image_size(png_ptr));
-#endif
-
-         png_write_complete_chunk(png_ptr, png_IDAT, data, size);
-         png_ptr->zstream.avail_out = 0;
-         png_ptr->zstream.next_out = NULL;
-         png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
-
-         png_ptr->zowner = 0; /* Release the stream */
-         return;
-      }
-
-      else
-      {
-         /* This is an error condition. */
-         png_zstream_error(png_ptr, ret);
-         png_error(png_ptr, png_ptr->zstream.msg);
-      }
-   }
-}
-
-/* Write an IEND chunk */
-void /* PRIVATE */
-png_write_IEND(png_structrp png_ptr)
-{
-   png_debug(1, "in png_write_IEND");
-
-   png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);
-   png_ptr->mode |= PNG_HAVE_IEND;
-}
-
-#ifdef PNG_WRITE_gAMA_SUPPORTED
-/* Write a gAMA chunk */
-void /* PRIVATE */
-png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma)
-{
-   png_byte buf[4];
-
-   png_debug(1, "in png_write_gAMA");
-
-   /* file_gamma is saved in 1/100,000ths */
-   png_save_uint_32(buf, (png_uint_32)file_gamma);
-   png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
-}
-#endif
-
-#ifdef PNG_WRITE_sRGB_SUPPORTED
-/* Write a sRGB chunk */
-void /* PRIVATE */
-png_write_sRGB(png_structrp png_ptr, int srgb_intent)
-{
-   png_byte buf[1];
-
-   png_debug(1, "in png_write_sRGB");
-
-   if (srgb_intent >= PNG_sRGB_INTENT_LAST)
-      png_warning(png_ptr,
-          "Invalid sRGB rendering intent specified");
-
-   buf[0]=(png_byte)srgb_intent;
-   png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
-}
-#endif
-
-#ifdef PNG_WRITE_iCCP_SUPPORTED
-/* Write an iCCP chunk */
-void /* PRIVATE */
-png_write_iCCP(png_structrp png_ptr, png_const_charp name,
-    png_const_bytep profile)
-{
-   png_uint_32 name_len;
-   png_uint_32 profile_len;
-   png_byte new_name[81]; /* 1 byte for the compression byte */
-   compression_state comp;
-   png_uint_32 temp;
-
-   png_debug(1, "in png_write_iCCP");
-
-   /* These are all internal problems: the profile should have been checked
-    * before when it was stored.
-    */
-   if (profile == NULL)
-      png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */
-
-   profile_len = png_get_uint_32(profile);
-
-   if (profile_len < 132)
-      png_error(png_ptr, "ICC profile too short");
-
-   temp = (png_uint_32) (*(profile+8));
-   if (temp > 3 && (profile_len & 0x03))
-      png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)");
-
-   {
-      png_uint_32 embedded_profile_len = png_get_uint_32(profile);
-
-      if (profile_len != embedded_profile_len)
-         png_error(png_ptr, "Profile length does not match profile");
-   }
-
-   name_len = png_check_keyword(png_ptr, name, new_name);
-
-   if (name_len == 0)
-      png_error(png_ptr, "iCCP: invalid keyword");
-
-   new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE;
-
-   /* Make sure we include the NULL after the name and the compression type */
-   ++name_len;
-
-   png_text_compress_init(&comp, profile, profile_len);
-
-   /* Allow for keyword terminator and compression byte */
-   if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK)
-      png_error(png_ptr, png_ptr->zstream.msg);
-
-   png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len);
-
-   png_write_chunk_data(png_ptr, new_name, name_len);
-
-   png_write_compressed_data_out(png_ptr, &comp);
-
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sPLT_SUPPORTED
-/* Write a sPLT chunk */
-void /* PRIVATE */
-png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
-{
-   png_uint_32 name_len;
-   png_byte new_name[80];
-   png_byte entrybuf[10];
-   png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);
-   png_size_t palette_size = entry_size * spalette->nentries;
-   png_sPLT_entryp ep;
-#ifndef PNG_POINTER_INDEXING_SUPPORTED
-   int i;
-#endif
-
-   png_debug(1, "in png_write_sPLT");
-
-   name_len = png_check_keyword(png_ptr, spalette->name, new_name);
-
-   if (name_len == 0)
-      png_error(png_ptr, "sPLT: invalid keyword");
-
-   /* Make sure we include the NULL after the name */
-   png_write_chunk_header(png_ptr, png_sPLT,
-       (png_uint_32)(name_len + 2 + palette_size));
-
-   png_write_chunk_data(png_ptr, (png_bytep)new_name,
-       (png_size_t)(name_len + 1));
-
-   png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1);
-
-   /* Loop through each palette entry, writing appropriately */
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
-   for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)
-   {
-      if (spalette->depth == 8)
-      {
-         entrybuf[0] = (png_byte)ep->red;
-         entrybuf[1] = (png_byte)ep->green;
-         entrybuf[2] = (png_byte)ep->blue;
-         entrybuf[3] = (png_byte)ep->alpha;
-         png_save_uint_16(entrybuf + 4, ep->frequency);
-      }
-
-      else
-      {
-         png_save_uint_16(entrybuf + 0, ep->red);
-         png_save_uint_16(entrybuf + 2, ep->green);
-         png_save_uint_16(entrybuf + 4, ep->blue);
-         png_save_uint_16(entrybuf + 6, ep->alpha);
-         png_save_uint_16(entrybuf + 8, ep->frequency);
-      }
-
-      png_write_chunk_data(png_ptr, entrybuf, entry_size);
-   }
-#else
-   ep=spalette->entries;
-   for (i = 0; i>spalette->nentries; i++)
-   {
-      if (spalette->depth == 8)
-      {
-         entrybuf[0] = (png_byte)ep[i].red;
-         entrybuf[1] = (png_byte)ep[i].green;
-         entrybuf[2] = (png_byte)ep[i].blue;
-         entrybuf[3] = (png_byte)ep[i].alpha;
-         png_save_uint_16(entrybuf + 4, ep[i].frequency);
-      }
-
-      else
-      {
-         png_save_uint_16(entrybuf + 0, ep[i].red);
-         png_save_uint_16(entrybuf + 2, ep[i].green);
-         png_save_uint_16(entrybuf + 4, ep[i].blue);
-         png_save_uint_16(entrybuf + 6, ep[i].alpha);
-         png_save_uint_16(entrybuf + 8, ep[i].frequency);
-      }
-
-      png_write_chunk_data(png_ptr, entrybuf, entry_size);
-   }
-#endif
-
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sBIT_SUPPORTED
-/* Write the sBIT chunk */
-void /* PRIVATE */
-png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
-{
-   png_byte buf[4];
-   png_size_t size;
-
-   png_debug(1, "in png_write_sBIT");
-
-   /* Make sure we don't depend upon the order of PNG_COLOR_8 */
-   if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
-   {
-      png_byte maxbits;
-
-      maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
-          png_ptr->usr_bit_depth);
-
-      if (sbit->red == 0 || sbit->red > maxbits ||
-          sbit->green == 0 || sbit->green > maxbits ||
-          sbit->blue == 0 || sbit->blue > maxbits)
-      {
-         png_warning(png_ptr, "Invalid sBIT depth specified");
-         return;
-      }
-
-      buf[0] = sbit->red;
-      buf[1] = sbit->green;
-      buf[2] = sbit->blue;
-      size = 3;
-   }
-
-   else
-   {
-      if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth)
-      {
-         png_warning(png_ptr, "Invalid sBIT depth specified");
-         return;
-      }
-
-      buf[0] = sbit->gray;
-      size = 1;
-   }
-
-   if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
-   {
-      if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)
-      {
-         png_warning(png_ptr, "Invalid sBIT depth specified");
-         return;
-      }
-
-      buf[size++] = sbit->alpha;
-   }
-
-   png_write_complete_chunk(png_ptr, png_sBIT, buf, size);
-}
-#endif
-
-#ifdef PNG_WRITE_cHRM_SUPPORTED
-/* Write the cHRM chunk */
-void /* PRIVATE */
-png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy)
-{
-   png_byte buf[32];
-
-   png_debug(1, "in png_write_cHRM");
-
-   /* Each value is saved in 1/100,000ths */
-   png_save_int_32(buf,      xy->whitex);
-   png_save_int_32(buf +  4, xy->whitey);
-
-   png_save_int_32(buf +  8, xy->redx);
-   png_save_int_32(buf + 12, xy->redy);
-
-   png_save_int_32(buf + 16, xy->greenx);
-   png_save_int_32(buf + 20, xy->greeny);
-
-   png_save_int_32(buf + 24, xy->bluex);
-   png_save_int_32(buf + 28, xy->bluey);
-
-   png_write_complete_chunk(png_ptr, png_cHRM, buf, 32);
-}
-#endif
-
-#ifdef PNG_WRITE_tRNS_SUPPORTED
-/* Write the tRNS chunk */
-void /* PRIVATE */
-png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
-    png_const_color_16p tran, int num_trans, int color_type)
-{
-   png_byte buf[6];
-
-   png_debug(1, "in png_write_tRNS");
-
-   if (color_type == PNG_COLOR_TYPE_PALETTE)
-   {
-      if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
-      {
-         png_app_warning(png_ptr,
-             "Invalid number of transparent colors specified");
-         return;
-      }
-
-      /* Write the chunk out as it is */
-      png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha,
-         (png_size_t)num_trans);
-   }
-
-   else if (color_type == PNG_COLOR_TYPE_GRAY)
-   {
-      /* One 16-bit value */
-      if (tran->gray >= (1 << png_ptr->bit_depth))
-      {
-         png_app_warning(png_ptr,
-             "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
-
-         return;
-      }
-
-      png_save_uint_16(buf, tran->gray);
-      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
-   }
-
-   else if (color_type == PNG_COLOR_TYPE_RGB)
-   {
-      /* Three 16-bit values */
-      png_save_uint_16(buf, tran->red);
-      png_save_uint_16(buf + 2, tran->green);
-      png_save_uint_16(buf + 4, tran->blue);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
-#else
-      if ((buf[0] | buf[2] | buf[4]) != 0)
-#endif
-      {
-         png_app_warning(png_ptr,
-           "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
-         return;
-      }
-
-      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
-   }
-
-   else
-   {
-      png_app_warning(png_ptr, "Can't write tRNS with an alpha channel");
-   }
-}
-#endif
-
-#ifdef PNG_WRITE_bKGD_SUPPORTED
-/* Write the background chunk */
-void /* PRIVATE */
-png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
-{
-   png_byte buf[6];
-
-   png_debug(1, "in png_write_bKGD");
-
-   if (color_type == PNG_COLOR_TYPE_PALETTE)
-   {
-      if (
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-          (png_ptr->num_palette != 0 ||
-          (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) &&
-#endif
-         back->index >= png_ptr->num_palette)
-      {
-         png_warning(png_ptr, "Invalid background palette index");
-         return;
-      }
-
-      buf[0] = back->index;
-      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
-   }
-
-   else if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
-   {
-      png_save_uint_16(buf, back->red);
-      png_save_uint_16(buf + 2, back->green);
-      png_save_uint_16(buf + 4, back->blue);
-#ifdef PNG_WRITE_16BIT_SUPPORTED
-      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
-#else
-      if ((buf[0] | buf[2] | buf[4]) != 0)
-#endif
-      {
-         png_warning(png_ptr,
-             "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
-
-         return;
-      }
-
-      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
-   }
-
-   else
-   {
-      if (back->gray >= (1 << png_ptr->bit_depth))
-      {
-         png_warning(png_ptr,
-             "Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
-
-         return;
-      }
-
-      png_save_uint_16(buf, back->gray);
-      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
-   }
-}
-#endif
-
-#ifdef PNG_WRITE_hIST_SUPPORTED
-/* Write the histogram */
-void /* PRIVATE */
-png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist)
-{
-   int i;
-   png_byte buf[3];
-
-   png_debug(1, "in png_write_hIST");
-
-   if (num_hist > (int)png_ptr->num_palette)
-   {
-      png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
-          png_ptr->num_palette);
-
-      png_warning(png_ptr, "Invalid number of histogram entries specified");
-      return;
-   }
-
-   png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
-
-   for (i = 0; i < num_hist; i++)
-   {
-      png_save_uint_16(buf, hist[i]);
-      png_write_chunk_data(png_ptr, buf, (png_size_t)2);
-   }
-
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_tEXt_SUPPORTED
-/* Write a tEXt chunk */
-void /* PRIVATE */
-png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
-    png_size_t text_len)
-{
-   png_uint_32 key_len;
-   png_byte new_key[80];
-
-   png_debug(1, "in png_write_tEXt");
-
-   key_len = png_check_keyword(png_ptr, key, new_key);
-
-   if (key_len == 0)
-      png_error(png_ptr, "tEXt: invalid keyword");
-
-   if (text == NULL || *text == '\0')
-      text_len = 0;
-
-   else
-      text_len = strlen(text);
-
-   if (text_len > PNG_UINT_31_MAX - (key_len+1))
-      png_error(png_ptr, "tEXt: text too long");
-
-   /* Make sure we include the 0 after the key */
-   png_write_chunk_header(png_ptr, png_tEXt,
-       (png_uint_32)/*checked above*/(key_len + text_len + 1));
-   /*
-    * We leave it to the application to meet PNG-1.0 requirements on the
-    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of
-    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.
-    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
-    */
-   png_write_chunk_data(png_ptr, new_key, key_len + 1);
-
-   if (text_len != 0)
-      png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len);
-
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_zTXt_SUPPORTED
-/* Write a compressed text chunk */
-void /* PRIVATE */
-png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
-    int compression)
-{
-   png_uint_32 key_len;
-   png_byte new_key[81];
-   compression_state comp;
-
-   png_debug(1, "in png_write_zTXt");
-
-   if (compression == PNG_TEXT_COMPRESSION_NONE)
-   {
-      png_write_tEXt(png_ptr, key, text, 0);
-      return;
-   }
-
-   if (compression != PNG_TEXT_COMPRESSION_zTXt)
-      png_error(png_ptr, "zTXt: invalid compression type");
-
-   key_len = png_check_keyword(png_ptr, key, new_key);
-
-   if (key_len == 0)
-      png_error(png_ptr, "zTXt: invalid keyword");
-
-   /* Add the compression method and 1 for the keyword separator. */
-   new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;
-   ++key_len;
-
-   /* Compute the compressed data; do it now for the length */
-   png_text_compress_init(&comp, (png_const_bytep)text,
-      text == NULL ? 0 : strlen(text));
-
-   if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK)
-      png_error(png_ptr, png_ptr->zstream.msg);
-
-   /* Write start of chunk */
-   png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len);
-
-   /* Write key */
-   png_write_chunk_data(png_ptr, new_key, key_len);
-
-   /* Write the compressed data */
-   png_write_compressed_data_out(png_ptr, &comp);
-
-   /* Close the chunk */
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_iTXt_SUPPORTED
-/* Write an iTXt chunk */
-void /* PRIVATE */
-png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
-    png_const_charp lang, png_const_charp lang_key, png_const_charp text)
-{
-   png_uint_32 key_len, prefix_len;
-   png_size_t lang_len, lang_key_len;
-   png_byte new_key[82];
-   compression_state comp;
-
-   png_debug(1, "in png_write_iTXt");
-
-   key_len = png_check_keyword(png_ptr, key, new_key);
-
-   if (key_len == 0)
-      png_error(png_ptr, "iTXt: invalid keyword");
-
-   /* Set the compression flag */
-   switch (compression)
-   {
-      case PNG_ITXT_COMPRESSION_NONE:
-      case PNG_TEXT_COMPRESSION_NONE:
-         compression = new_key[++key_len] = 0; /* no compression */
-         break;
-
-      case PNG_TEXT_COMPRESSION_zTXt:
-      case PNG_ITXT_COMPRESSION_zTXt:
-         compression = new_key[++key_len] = 1; /* compressed */
-         break;
-
-      default:
-         png_error(png_ptr, "iTXt: invalid compression");
-   }
-
-   new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;
-   ++key_len; /* for the keywod separator */
-
-   /* We leave it to the application to meet PNG-1.0 requirements on the
-    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of
-    * any non-Latin-1 characters except for NEWLINE.  ISO PNG, however,
-    * specifies that the text is UTF-8 and this really doesn't require any
-    * checking.
-    *
-    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
-    *
-    * TODO: validate the language tag correctly (see the spec.)
-    */
-   if (lang == NULL) lang = ""; /* empty language is valid */
-   lang_len = strlen(lang)+1;
-   if (lang_key == NULL) lang_key = ""; /* may be empty */
-   lang_key_len = strlen(lang_key)+1;
-   if (text == NULL) text = ""; /* may be empty */
-
-   prefix_len = key_len;
-   if (lang_len > PNG_UINT_31_MAX-prefix_len)
-      prefix_len = PNG_UINT_31_MAX;
-   else
-      prefix_len = (png_uint_32)(prefix_len + lang_len);
-
-   if (lang_key_len > PNG_UINT_31_MAX-prefix_len)
-      prefix_len = PNG_UINT_31_MAX;
-   else
-      prefix_len = (png_uint_32)(prefix_len + lang_key_len);
-
-   png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));
-
-   if (compression != 0)
-   {
-      if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK)
-         png_error(png_ptr, png_ptr->zstream.msg);
-   }
-
-   else
-   {
-      if (comp.input_len > PNG_UINT_31_MAX-prefix_len)
-         png_error(png_ptr, "iTXt: uncompressed text too long");
-
-      /* So the string will fit in a chunk: */
-      comp.output_len = (png_uint_32)/*SAFE*/comp.input_len;
-   }
-
-   png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len);
-
-   png_write_chunk_data(png_ptr, new_key, key_len);
-
-   png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len);
-
-   png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len);
-
-   if (compression != 0)
-      png_write_compressed_data_out(png_ptr, &comp);
-
-   else
-      png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
-
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_oFFs_SUPPORTED
-/* Write the oFFs chunk */
-void /* PRIVATE */
-png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
-    int unit_type)
-{
-   png_byte buf[9];
-
-   png_debug(1, "in png_write_oFFs");
-
-   if (unit_type >= PNG_OFFSET_LAST)
-      png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
-
-   png_save_int_32(buf, x_offset);
-   png_save_int_32(buf + 4, y_offset);
-   buf[8] = (png_byte)unit_type;
-
-   png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
-}
-#endif
-#ifdef PNG_WRITE_pCAL_SUPPORTED
-/* Write the pCAL chunk (described in the PNG extensions document) */
-void /* PRIVATE */
-png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
-    png_int_32 X1, int type, int nparams, png_const_charp units,
-    png_charpp params)
-{
-   png_uint_32 purpose_len;
-   png_size_t units_len, total_len;
-   png_size_tp params_len;
-   png_byte buf[10];
-   png_byte new_purpose[80];
-   int i;
-
-   png_debug1(1, "in png_write_pCAL (%d parameters)", nparams);
-
-   if (type >= PNG_EQUATION_LAST)
-      png_error(png_ptr, "Unrecognized equation type for pCAL chunk");
-
-   purpose_len = png_check_keyword(png_ptr, purpose, new_purpose);
-
-   if (purpose_len == 0)
-      png_error(png_ptr, "pCAL: invalid keyword");
-
-   ++purpose_len; /* terminator */
-
-   png_debug1(3, "pCAL purpose length = %d", (int)purpose_len);
-   units_len = strlen(units) + (nparams == 0 ? 0 : 1);
-   png_debug1(3, "pCAL units length = %d", (int)units_len);
-   total_len = purpose_len + units_len + 10;
-
-   params_len = (png_size_tp)png_malloc(png_ptr,
-       (png_alloc_size_t)(nparams * (sizeof (png_size_t))));
-
-   /* Find the length of each parameter, making sure we don't count the
-    * null terminator for the last parameter.
-    */
-   for (i = 0; i < nparams; i++)
-   {
-      params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
-      png_debug2(3, "pCAL parameter %d length = %lu", i,
-          (unsigned long)params_len[i]);
-      total_len += params_len[i];
-   }
-
-   png_debug1(3, "pCAL total length = %d", (int)total_len);
-   png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len);
-   png_write_chunk_data(png_ptr, new_purpose, purpose_len);
-   png_save_int_32(buf, X0);
-   png_save_int_32(buf + 4, X1);
-   buf[8] = (png_byte)type;
-   buf[9] = (png_byte)nparams;
-   png_write_chunk_data(png_ptr, buf, (png_size_t)10);
-   png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);
-
-   for (i = 0; i < nparams; i++)
-   {
-      png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]);
-   }
-
-   png_free(png_ptr, params_len);
-   png_write_chunk_end(png_ptr);
-}
-#endif
-
-#ifdef PNG_WRITE_sCAL_SUPPORTED
-/* Write the sCAL chunk */
-void /* PRIVATE */
-png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
-    png_const_charp height)
-{
-   png_byte buf[64];
-   png_size_t wlen, hlen, total_len;
-
-   png_debug(1, "in png_write_sCAL_s");
-
-   wlen = strlen(width);
-   hlen = strlen(height);
-   total_len = wlen + hlen + 2;
-
-   if (total_len > 64)
-   {
-      png_warning(png_ptr, "Can't write sCAL (buffer too small)");
-      return;
-   }
-
-   buf[0] = (png_byte)unit;
-   memcpy(buf + 1, width, wlen + 1);      /* Append the '\0' here */
-   memcpy(buf + wlen + 2, height, hlen);  /* Do NOT append the '\0' here */
-
-   png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
-   png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);
-}
-#endif
-
-#ifdef PNG_WRITE_pHYs_SUPPORTED
-/* Write the pHYs chunk */
-void /* PRIVATE */
-png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,
-    png_uint_32 y_pixels_per_unit,
-    int unit_type)
-{
-   png_byte buf[9];
-
-   png_debug(1, "in png_write_pHYs");
-
-   if (unit_type >= PNG_RESOLUTION_LAST)
-      png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
-
-   png_save_uint_32(buf, x_pixels_per_unit);
-   png_save_uint_32(buf + 4, y_pixels_per_unit);
-   buf[8] = (png_byte)unit_type;
-
-   png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
-}
-#endif
-
-#ifdef PNG_WRITE_tIME_SUPPORTED
-/* Write the tIME chunk.  Use either png_convert_from_struct_tm()
- * or png_convert_from_time_t(), or fill in the structure yourself.
- */
-void /* PRIVATE */
-png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
-{
-   png_byte buf[7];
-
-   png_debug(1, "in png_write_tIME");
-
-   if (mod_time->month  > 12 || mod_time->month  < 1 ||
-       mod_time->day    > 31 || mod_time->day    < 1 ||
-       mod_time->hour   > 23 || mod_time->second > 60)
-   {
-      png_warning(png_ptr, "Invalid time specified for tIME chunk");
-      return;
-   }
-
-   png_save_uint_16(buf, mod_time->year);
-   buf[2] = mod_time->month;
-   buf[3] = mod_time->day;
-   buf[4] = mod_time->hour;
-   buf[5] = mod_time->minute;
-   buf[6] = mod_time->second;
-
-   png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
-}
-#endif
-
-/* Initializes the row writing capability of libpng */
-void /* PRIVATE */
-png_write_start_row(png_structrp png_ptr)
-{
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
-   /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
-   /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
-   /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
-   /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
-
-   png_alloc_size_t buf_size;
-   int usr_pixel_depth;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   png_byte filters;
-#endif
-
-   png_debug(1, "in png_write_start_row");
-
-   usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
-   buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
-
-   /* 1.5.6: added to allow checking in the row write code. */
-   png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;
-   png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
-
-   /* Set up row buffer */
-   png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
-
-   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   filters = png_ptr->do_filter;
-
-   if (png_ptr->height == 1)
-      filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
-   if (png_ptr->width == 1)
-      filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
-
-   if (filters == 0)
-      filters = PNG_FILTER_NONE;
-
-   png_ptr->do_filter = filters;
-
-   if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG |
-       PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL)
-   {
-      int num_filters = 0;
-
-      png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
-
-      if (filters & PNG_FILTER_SUB)
-         num_filters++;
-
-      if (filters & PNG_FILTER_UP)
-         num_filters++;
-
-      if (filters & PNG_FILTER_AVG)
-         num_filters++;
-
-      if (filters & PNG_FILTER_PAETH)
-         num_filters++;
-
-      if (num_filters > 1)
-         png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr,
-             buf_size));
-   }
-
-   /* We only need to keep the previous row if we are using one of the following
-    * filters.
-    */
-   if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
-      png_ptr->prev_row = png_voidcast(png_bytep,
-         png_calloc(png_ptr, buf_size));
-#endif /* WRITE_FILTER */
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* If interlaced, we need to set up width and height of pass */
-   if (png_ptr->interlaced != 0)
-   {
-      if ((png_ptr->transformations & PNG_INTERLACE) == 0)
-      {
-         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
-             png_pass_ystart[0]) / png_pass_yinc[0];
-
-         png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -
-             png_pass_start[0]) / png_pass_inc[0];
-      }
-
-      else
-      {
-         png_ptr->num_rows = png_ptr->height;
-         png_ptr->usr_width = png_ptr->width;
-      }
-   }
-
-   else
-#endif
-   {
-      png_ptr->num_rows = png_ptr->height;
-      png_ptr->usr_width = png_ptr->width;
-   }
-}
-
-/* Internal use only.  Called when finished processing a row of data. */
-void /* PRIVATE */
-png_write_finish_row(png_structrp png_ptr)
-{
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
-   /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
-   /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
-   /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
-   /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
-
-   png_debug(1, "in png_write_finish_row");
-
-   /* Next row */
-   png_ptr->row_number++;
-
-   /* See if we are done */
-   if (png_ptr->row_number < png_ptr->num_rows)
-      return;
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-   /* If interlaced, go to next pass */
-   if (png_ptr->interlaced != 0)
-   {
-      png_ptr->row_number = 0;
-      if ((png_ptr->transformations & PNG_INTERLACE) != 0)
-      {
-         png_ptr->pass++;
-      }
-
-      else
-      {
-         /* Loop until we find a non-zero width or height pass */
-         do
-         {
-            png_ptr->pass++;
-
-            if (png_ptr->pass >= 7)
-               break;
-
-            png_ptr->usr_width = (png_ptr->width +
-                png_pass_inc[png_ptr->pass] - 1 -
-                png_pass_start[png_ptr->pass]) /
-                png_pass_inc[png_ptr->pass];
-
-            png_ptr->num_rows = (png_ptr->height +
-                png_pass_yinc[png_ptr->pass] - 1 -
-                png_pass_ystart[png_ptr->pass]) /
-                png_pass_yinc[png_ptr->pass];
-
-            if ((png_ptr->transformations & PNG_INTERLACE) != 0)
-               break;
-
-         } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);
-
-      }
-
-      /* Reset the row above the image for the next pass */
-      if (png_ptr->pass < 7)
-      {
-         if (png_ptr->prev_row != NULL)
-            memset(png_ptr->prev_row, 0,
-                (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
-                png_ptr->usr_bit_depth, png_ptr->width)) + 1);
-
-         return;
-      }
-   }
-#endif
-
-   /* If we get here, we've just written the last row, so we need
-      to flush the compressor */
-   png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH);
-}
-
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
-/* Pick out the correct pixels for the interlace pass.
- * The basic idea here is to go through the row with a source
- * pointer and a destination pointer (sp and dp), and copy the
- * correct pixels for the pass.  As the row gets compacted,
- * sp will always be >= dp, so we should never overwrite anything.
- * See the default: case for the easiest code to understand.
- */
-void /* PRIVATE */
-png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
-{
-   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
-   /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
-   /* Offset to next interlace block */
-   static PNG_CONST png_byte  png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
-   png_debug(1, "in png_do_write_interlace");
-
-   /* We don't have to do anything on the last pass (6) */
-   if (pass < 6)
-   {
-      /* Each pixel depth is handled separately */
-      switch (row_info->pixel_depth)
-      {
-         case 1:
-         {
-            png_bytep sp;
-            png_bytep dp;
-            unsigned int shift;
-            int d;
-            int value;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            dp = row;
-            d = 0;
-            shift = 7;
-
-            for (i = png_pass_start[pass]; i < row_width;
-               i += png_pass_inc[pass])
-            {
-               sp = row + (png_size_t)(i >> 3);
-               value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;
-               d |= (value << shift);
-
-               if (shift == 0)
-               {
-                  shift = 7;
-                  *dp++ = (png_byte)d;
-                  d = 0;
-               }
-
-               else
-                  shift--;
-
-            }
-            if (shift != 7)
-               *dp = (png_byte)d;
-
-            break;
-         }
-
-         case 2:
-         {
-            png_bytep sp;
-            png_bytep dp;
-            unsigned int shift;
-            int d;
-            int value;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            dp = row;
-            shift = 6;
-            d = 0;
-
-            for (i = png_pass_start[pass]; i < row_width;
-               i += png_pass_inc[pass])
-            {
-               sp = row + (png_size_t)(i >> 2);
-               value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;
-               d |= (value << shift);
-
-               if (shift == 0)
-               {
-                  shift = 6;
-                  *dp++ = (png_byte)d;
-                  d = 0;
-               }
-
-               else
-                  shift -= 2;
-            }
-            if (shift != 6)
-               *dp = (png_byte)d;
-
-            break;
-         }
-
-         case 4:
-         {
-            png_bytep sp;
-            png_bytep dp;
-            unsigned int shift;
-            int d;
-            int value;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-
-            dp = row;
-            shift = 4;
-            d = 0;
-            for (i = png_pass_start[pass]; i < row_width;
-                i += png_pass_inc[pass])
-            {
-               sp = row + (png_size_t)(i >> 1);
-               value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;
-               d |= (value << shift);
-
-               if (shift == 0)
-               {
-                  shift = 4;
-                  *dp++ = (png_byte)d;
-                  d = 0;
-               }
-
-               else
-                  shift -= 4;
-            }
-            if (shift != 4)
-               *dp = (png_byte)d;
-
-            break;
-         }
-
-         default:
-         {
-            png_bytep sp;
-            png_bytep dp;
-            png_uint_32 i;
-            png_uint_32 row_width = row_info->width;
-            png_size_t pixel_bytes;
-
-            /* Start at the beginning */
-            dp = row;
-
-            /* Find out how many bytes each pixel takes up */
-            pixel_bytes = (row_info->pixel_depth >> 3);
-
-            /* Loop through the row, only looking at the pixels that matter */
-            for (i = png_pass_start[pass]; i < row_width;
-               i += png_pass_inc[pass])
-            {
-               /* Find out where the original pixel is */
-               sp = row + (png_size_t)i * pixel_bytes;
-
-               /* Move the pixel */
-               if (dp != sp)
-                  memcpy(dp, sp, pixel_bytes);
-
-               /* Next pixel */
-               dp += pixel_bytes;
-            }
-            break;
-         }
-      }
-      /* Set new row width */
-      row_info->width = (row_info->width +
-          png_pass_inc[pass] - 1 -
-          png_pass_start[pass]) /
-          png_pass_inc[pass];
-
-      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
-          row_info->width);
-   }
-}
-#endif
-
-
-/* This filters the row, chooses which filter to use, if it has not already
- * been specified by the application, and then writes the row out with the
- * chosen filter.
- */
-static void /* PRIVATE */
-png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
-   png_size_t row_bytes);
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-static png_size_t /* PRIVATE */
-png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
-    const png_size_t row_bytes, const png_size_t lmins)
-{
-   png_bytep rp, dp, lp;
-   png_size_t i;
-   png_size_t sum = 0;
-   int v;
-
-   png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
-
-   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
-        i++, rp++, dp++)
-   {
-      v = *dp = *rp;
-      sum += (v < 128) ? v : 256 - v;
-   }
-
-   for (lp = png_ptr->row_buf + 1; i < row_bytes;
-      i++, rp++, lp++, dp++)
-   {
-      v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
-      sum += (v < 128) ? v : 256 - v;
-
-      if (sum > lmins)  /* We are already worse, don't continue. */
-        break;
-   }
-
-   return (sum);
-}
-
-static png_size_t /* PRIVATE */
-png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
-    const png_size_t lmins)
-{
-   png_bytep rp, dp, pp;
-   png_size_t i;
-   png_size_t sum = 0;
-   int v;
-
-   png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
-
-   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
-       pp = png_ptr->prev_row + 1; i < row_bytes;
-       i++, rp++, pp++, dp++)
-   {
-      v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
-      sum += (v < 128) ? v : 256 - v;
-
-      if (sum > lmins)  /* We are already worse, don't continue. */
-        break;
-   }
-
-   return (sum);
-}
-
-static png_size_t /* PRIVATE */
-png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
-      const png_size_t row_bytes, const png_size_t lmins)
-{
-   png_bytep rp, dp, pp, lp;
-   png_uint_32 i;
-   png_size_t sum = 0;
-   int v;
-
-   png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
-
-   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
-        pp = png_ptr->prev_row + 1; i < bpp; i++)
-   {
-      v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
-
-      sum += (v < 128) ? v : 256 - v;
-   }
-
-   for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
-   {
-      v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
-          & 0xff);
-
-      sum += (v < 128) ? v : 256 - v;
-
-      if (sum > lmins)  /* We are already worse, don't continue. */
-        break;
-   }
-
-   return (sum);
-}
-
-static png_size_t /* PRIVATE */
-png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
-    const png_size_t row_bytes, const png_size_t lmins)
-{
-   png_bytep rp, dp, pp, cp, lp;
-   png_size_t i;
-   png_size_t sum = 0;
-   int v;
-
-   png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
-
-   for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
-       pp = png_ptr->prev_row + 1; i < bpp; i++)
-   {
-      v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
-
-      sum += (v < 128) ? v : 256 - v;
-   }
-
-   for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
-        i++)
-   {
-      int a, b, c, pa, pb, pc, p;
-
-      b = *pp++;
-      c = *cp++;
-      a = *lp++;
-
-      p = b - c;
-      pc = a - c;
-
-#ifdef PNG_USE_ABS
-      pa = abs(p);
-      pb = abs(pc);
-      pc = abs(p + pc);
-#else
-      pa = p < 0 ? -p : p;
-      pb = pc < 0 ? -pc : pc;
-      pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
-      p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-
-      v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
-
-      sum += (v < 128) ? v : 256 - v;
-
-      if (sum > lmins)  /* We are already worse, don't continue. */
-        break;
-   }
-
-   return (sum);
-}
-#endif /* WRITE_FILTER */
-
-void /* PRIVATE */
-png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
-{
-#ifndef PNG_WRITE_FILTER_SUPPORTED
-   png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
-#else
-   png_byte filter_to_do = png_ptr->do_filter;
-   png_bytep row_buf;
-   png_bytep best_row;
-   png_uint_32 bpp;
-   png_size_t mins;
-   png_size_t row_bytes = row_info->rowbytes;
-
-   png_debug(1, "in png_write_find_filter");
-
-   /* Find out how many bytes offset each pixel is */
-   bpp = (row_info->pixel_depth + 7) >> 3;
-
-   row_buf = png_ptr->row_buf;
-   mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the
-                               running sum */;
-
-   /* The prediction method we use is to find which method provides the
-    * smallest value when summing the absolute values of the distances
-    * from zero, using anything >= 128 as negative numbers.  This is known
-    * as the "minimum sum of absolute differences" heuristic.  Other
-    * heuristics are the "weighted minimum sum of absolute differences"
-    * (experimental and can in theory improve compression), and the "zlib
-    * predictive" method (not implemented yet), which does test compressions
-    * of lines using different filter methods, and then chooses the
-    * (series of) filter(s) that give minimum compressed data size (VERY
-    * computationally expensive).
-    *
-    * GRR 980525:  consider also
-    *
-    *   (1) minimum sum of absolute differences from running average (i.e.,
-    *       keep running sum of non-absolute differences & count of bytes)
-    *       [track dispersion, too?  restart average if dispersion too large?]
-    *
-    *  (1b) minimum sum of absolute differences from sliding average, probably
-    *       with window size <= deflate window (usually 32K)
-    *
-    *   (2) minimum sum of squared differences from zero or running average
-    *       (i.e., ~ root-mean-square approach)
-    */
-
-
-   /* We don't need to test the 'no filter' case if this is the only filter
-    * that has been chosen, as it doesn't actually do anything to the data.
-    */
-   best_row = png_ptr->row_buf;
-
-
-   if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
-   {
-      png_bytep rp;
-      png_size_t sum = 0;
-      png_size_t i;
-      int v;
-
-      if (PNG_SIZE_MAX/128 <= row_bytes)
-      {
-         for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
-         {
-            /* Check for overflow */
-            if (sum > PNG_SIZE_MAX/128 - 256)
-               break;
-
-            v = *rp;
-            sum += (v < 128) ? v : 256 - v;
-         }
-      }
-      else /* Overflow is not possible */
-      {
-         for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
-         {
-            v = *rp;
-            sum += (v < 128) ? v : 256 - v;
-         }
-      }
-
-      mins = sum;
-   }
-
-   /* Sub filter */
-   if (filter_to_do == PNG_FILTER_SUB)
-   /* It's the only filter so no testing is needed */
-   {
-      (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins);
-      best_row = png_ptr->try_row;
-   }
-
-   else if ((filter_to_do & PNG_FILTER_SUB) != 0)
-   {
-      png_size_t sum;
-      png_size_t lmins = mins;
-
-      sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins);
-
-      if (sum < mins)
-      {
-         mins = sum;
-         best_row = png_ptr->try_row;
-         if (png_ptr->tst_row != NULL)
-         {
-            png_ptr->try_row = png_ptr->tst_row;
-            png_ptr->tst_row = best_row;
-         }
-      }
-   }
-
-   /* Up filter */
-   if (filter_to_do == PNG_FILTER_UP)
-   {
-      (void) png_setup_up_row(png_ptr, row_bytes, mins);
-      best_row = png_ptr->try_row;
-   }
-
-   else if ((filter_to_do & PNG_FILTER_UP) != 0)
-   {
-      png_size_t sum;
-      png_size_t lmins = mins;
-
-      sum = png_setup_up_row(png_ptr, row_bytes, lmins);
-
-      if (sum < mins)
-      {
-         mins = sum;
-         best_row = png_ptr->try_row;
-         if (png_ptr->tst_row != NULL)
-         {
-            png_ptr->try_row = png_ptr->tst_row;
-            png_ptr->tst_row = best_row;
-         }
-      }
-   }
-
-   /* Avg filter */
-   if (filter_to_do == PNG_FILTER_AVG)
-   {
-      (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins);
-      best_row = png_ptr->try_row;
-   }
-
-   else if ((filter_to_do & PNG_FILTER_AVG) != 0)
-   {
-      png_size_t sum;
-      png_size_t lmins = mins;
-
-      sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins);
-
-      if (sum < mins)
-      {
-         mins = sum;
-         best_row = png_ptr->try_row;
-         if (png_ptr->tst_row != NULL)
-         {
-            png_ptr->try_row = png_ptr->tst_row;
-            png_ptr->tst_row = best_row;
-         }
-      }
-   }
-
-   /* Paeth filter */
-   if ((filter_to_do == PNG_FILTER_PAETH) != 0)
-   {
-      (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins);
-      best_row = png_ptr->try_row;
-   }
-
-   else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
-   {
-      png_size_t sum;
-      png_size_t lmins = mins;
-
-      sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins);
-
-      if (sum < mins)
-      {
-         best_row = png_ptr->try_row;
-         if (png_ptr->tst_row != NULL)
-         {
-            png_ptr->try_row = png_ptr->tst_row;
-            png_ptr->tst_row = best_row;
-         }
-      }
-   }
-
-   /* Do the actual writing of the filtered row data from the chosen filter. */
-   png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
-
-#endif /* WRITE_FILTER */
-}
-
-
-/* Do the actual writing of a previously filtered row. */
-static void
-png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
-   png_size_t full_row_length/*includes filter byte*/)
-{
-   png_debug(1, "in png_write_filtered_row");
-
-   png_debug1(2, "filter = %d", filtered_row[0]);
-
-   png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
-
-#ifdef PNG_WRITE_FILTER_SUPPORTED
-   /* Swap the current and previous rows */
-   if (png_ptr->prev_row != NULL)
-   {
-      png_bytep tptr;
-
-      tptr = png_ptr->prev_row;
-      png_ptr->prev_row = png_ptr->row_buf;
-      png_ptr->row_buf = tptr;
-   }
-#endif /* WRITE_FILTER */
-
-   /* Finish row - updates counters and flushes zlib if last row */
-   png_write_finish_row(png_ptr);
-
-#ifdef PNG_WRITE_FLUSH_SUPPORTED
-   png_ptr->flush_rows++;
-
-   if (png_ptr->flush_dist > 0 &&
-       png_ptr->flush_rows >= png_ptr->flush_dist)
-   {
-      png_write_flush(png_ptr);
-   }
-#endif /* WRITE_FLUSH */
-}
-#endif /* WRITE */
--- a/jdk/src/java.desktop/unix/native/common/awt/fontpath.c	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/unix/native/common/awt/fontpath.c	Wed Jul 05 22:46:04 2017 +0200
@@ -289,6 +289,12 @@
         onePath = SAFE_SIZE_ARRAY_ALLOC(malloc, strlen (fDirP->name[index]) + 2, sizeof( char ) );
         if (onePath == NULL) {
             free ( ( void *) appendDirList );
+
+            for ( index = origIndex; index < nPaths; index++ ) {
+                free( newFontPath[index] );
+            }
+
+            free( ( void *) newFontPath);
             XFreeFontPath ( origFontPath );
             return;
         }
@@ -1137,6 +1143,7 @@
                 JNU_CHECK_EXCEPTION(env);
 
                 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
+                (*env)->DeleteLocalRef(env, jstr);
             }
             (*FcStrListDone)(cacheDirs);
         }
@@ -1163,10 +1170,13 @@
             (jstring)((*env)->GetObjectField(env, fcCompFontObj, fcNameID));
         fcName = (*env)->GetStringUTFChars(env, fcNameStr, 0);
         if (fcName == NULL) {
+            (*env)->DeleteLocalRef(env, fcCompFontObj);
+            (*env)->DeleteLocalRef(env, fcNameStr);
             continue;
         }
         pattern = (*FcNameParse)((FcChar8 *)fcName);
         (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
+        (*env)->DeleteLocalRef(env, fcNameStr);
         if (pattern == NULL) {
             closeFontConfig(libfontconfig, JNI_FALSE);
             return;
@@ -1326,20 +1336,24 @@
                 jstr = (*env)->NewStringUTF(env, (const char*)family[j]);
                 if (IS_NULL(jstr)) break;
                 (*env)->SetObjectField(env, fcFont, familyNameID, jstr);
+                (*env)->DeleteLocalRef(env, jstr);
                 if (file[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)file[j]);
                     if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, fontFileID, jstr);
+                    (*env)->DeleteLocalRef(env, jstr);
                 }
                 if (styleStr[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)styleStr[j]);
                     if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, styleNameID, jstr);
+                    (*env)->DeleteLocalRef(env, jstr);
                 }
                 if (fullname[j] != NULL) {
                     jstr = (*env)->NewStringUTF(env, (const char*)fullname[j]);
                     if (IS_NULL(jstr)) break;
                     (*env)->SetObjectField(env, fcFont, fullNameID, jstr);
+                    (*env)->DeleteLocalRef(env, jstr);
                 }
                 if (fn==0) {
                     (*env)->SetObjectField(env, fcCompFontObj,
@@ -1348,10 +1362,16 @@
                 if (includeFallbacks) {
                     (*env)->SetObjectArrayElement(env, fcFontArr, fn++,fcFont);
                 } else {
+                    (*env)->DeleteLocalRef(env, fcFont);
                     break;
                 }
+                (*env)->DeleteLocalRef(env, fcFont);
             }
         }
+        if (includeFallbacks) {
+            (*env)->DeleteLocalRef(env, fcFontArr);
+        }
+        (*env)->DeleteLocalRef(env, fcCompFontObj);
         (*FcFontSetDestroy)(fontset);
         (*FcPatternDestroy)(pattern);
         free(family);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Wed Jul 05 22:46:04 2017 +0200
@@ -854,6 +854,10 @@
                 "AwtWin32GraphicsDevice::GetScreenFromHMONITOR mhnd=%x", mon);
 
     DASSERT(mon != NULL);
+    JNIEnv *env = (JNIEnv*) JNU_GetEnv(jvm, JNI_VERSION_1_2);
+    if (!Devices::GetInstance()) {
+       Devices::UpdateInstance(env);
+    }
     Devices::InstanceAccess devices;
 
     for (int i = 0; i < devices->GetNumDevices(); i++) {
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClient.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClient.java	Wed Jul 05 22:46:04 2017 +0200
@@ -40,6 +40,7 @@
 /**
  * A container for configuration information common to multiple {@link
  * HttpRequest}s. All requests are sent through a {@code HttpClient}.
+ * {@Incubating}
  *
  * <p> {@code HttpClient}s are immutable and created from a builder returned
  * from {@link HttpClient#newBuilder()}. Request builders are created by calling
@@ -76,7 +77,8 @@
 
     /**
      * A builder of immutable {@link HttpClient}s. {@code HttpClient.Builder}s
-     * are created by calling {@link HttpClient#newBuilder() }
+     * are created by calling {@link HttpClient#newBuilder()}.
+     * {@Incubating}
      *
      * <p> Each of the setter methods in this class modifies the state of the
      * builder and returns <i>this</i> (ie. the same instance). The methods are
@@ -283,6 +285,7 @@
 
     /**
      * The HTTP protocol version.
+     * {@Incubating}
      *
      * @since 9
      */
@@ -300,10 +303,12 @@
     }
 
     /**
-     * Defines automatic redirection policy. This is checked whenever a {@code 3XX}
-     * response code is received. If redirection does not happen automatically
-     * then the response is returned to the user, where it can be handled
-     * manually.
+     * Defines automatic redirection policy.
+     * {@Incubating}
+     *
+     * <p> This is checked whenever a {@code 3XX} response code is received. If
+     * redirection does not happen automatically then the response is returned
+     * to the user, where it can be handled manually.
      *
      * <p> {@code Redirect} policy is set via the {@link
      * HttpClient.Builder#followRedirects(HttpClient.Redirect)} method.
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpHeaders.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpHeaders.java	Wed Jul 05 22:46:04 2017 +0200
@@ -32,6 +32,7 @@
 
 /**
  * A read-only view of a set of HTTP headers.
+ * {@Incubating}
  *
  * @since 9
  */
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -39,10 +39,13 @@
 import java.util.function.Supplier;
 
 /**
- * Represents one HTTP request which can be sent to a server. {@code
- * HttpRequest}s are built from {@code HttpRequest} {@link HttpRequest.Builder
- * builder}s. {@code HttpRequest} builders are obtained
- * by calling {@link HttpRequest#newBuilder(java.net.URI) HttpRequest.newBuilder}.
+ * Represents one HTTP request which can be sent to a server.
+ * {@Incubating }
+ *
+ * <p> {@code HttpRequest}s are built from {@code HttpRequest}
+ * {@link HttpRequest.Builder builder}s. {@code HttpRequest} builders are
+ * obtained by calling {@link HttpRequest#newBuilder(java.net.URI)
+ * HttpRequest.newBuilder}.
  * A request's {@link java.net.URI}, headers and body can be set. Request bodies
  * are provided through a {@link BodyProcessor} object supplied to the
  * {@link Builder#DELETE(jdk.incubator.http.HttpRequest.BodyProcessor) DELETE},
@@ -250,9 +253,11 @@
     protected HttpRequest() {}
 
     /**
-     * A builder of {@link HttpRequest}s. {@code HttpRequest.Builder}s are
-     * created by calling {@link HttpRequest#newBuilder(URI)} or {@link
-     * HttpRequest#newBuilder()}.
+     * A builder of {@link HttpRequest}s.
+     * {@Incubating}
+     *
+     * <p> {@code HttpRequest.Builder}s are created by calling {@link
+     * HttpRequest#newBuilder(URI)} or {@link HttpRequest#newBuilder()}.
      *
      * <p> Each of the setter methods in this class modifies the state of the
      * builder and returns <i>this</i> (ie. the same instance). The methods are
@@ -521,8 +526,10 @@
     /**
      * A processor which converts high level Java objects into flows of
      * {@link java.nio.ByteBuffer}s suitable for sending as request bodies.
-     * {@code BodyProcessor}s implement {@link Flow.Publisher} which means they act as a
-     * publisher of byte buffers.
+     * {@Incubating}
+     * <p>
+     * {@code BodyProcessor}s implement {@link Flow.Publisher} which means they
+     * act as a publisher of byte buffers.
      * <p>
      * The HTTP client implementation subscribes to the processor in
      * order to receive the flow of outgoing data buffers. The normal semantics
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java	Wed Jul 05 22:46:04 2017 +0200
@@ -47,12 +47,15 @@
 import javax.net.ssl.SSLParameters;
 
 /**
- * Represents a response to a {@link HttpRequest}. A {@code HttpResponse} is
- * available when the response status code and headers have been received, and
- * typically after the response body has also been received. This depends on
- * the response body handler provided when sending the request. In all cases,
- * the response body handler is invoked before the body is read. This gives
- * applications an opportunity to decide how to handle the body.
+ * Represents a response to a {@link HttpRequest}.
+ * {@Incubating}
+ *
+ * <p>A {@code HttpResponse} is available when the response status code and
+ * headers have been received, and typically after the response body has also
+ * been received. This depends on the response body handler provided when
+ * sending the request. In all cases, the response body handler is invoked
+ * before the body is read. This gives applications an opportunity to decide
+ * how to handle the body.
  *
  * <p> Methods are provided in this class for accessing the response headers,
  * and response body.
@@ -157,12 +160,15 @@
     public abstract HttpClient.Version version();
 
     /**
-     * A handler for response bodies. This is a function that takes two
-     * parameters: the response status code, and the response headers,
-     * and which returns a {@link BodyProcessor}. The function is always called
-     * just before the response body is read. Its implementation may examine the
-     * status code or headers and must decide, whether to accept the response
-     * body or discard it, and if accepting it, exactly how to handle it.
+     * A handler for response bodies.
+     * {@Incubating}
+     * <p>
+     * This is a function that takes two parameters: the response status code,
+     * and the response headers, and which returns a {@link BodyProcessor}.
+     * The function is always called just before the response body is read. Its
+     * implementation may examine the status code or headers and must decide,
+     * whether to accept the response body or discard it, and if accepting it,
+     * exactly how to handle it.
      * <p>
      * Some pre-defined implementations which do not utilize the status code
      * or headers (meaning the body is always accepted) are defined:
@@ -409,10 +415,13 @@
     }
 
     /**
-     * A processor for response bodies. The object acts as a
-     * {@link Flow.Subscriber}&lt;{@link ByteBuffer}&gt; to the HTTP client implementation
-     * which publishes ByteBuffers containing the response body. The processor
-     * converts the incoming buffers of data to some user-defined object type {@code T}.
+     * A processor for response bodies.
+     * {@Incubating}
+     * <p>
+     * The object acts as a {@link Flow.Subscriber}&lt;{@link ByteBuffer}&gt; to
+     * the HTTP client implementation which publishes ByteBuffers containing the
+     * response body. The processor converts the incoming buffers of data to
+     * some user-defined object type {@code T}.
      * <p>
      * The {@link #getBody()} method returns a {@link CompletionStage}{@code <T>}
      * that provides the response body object. The {@code CompletionStage} must
@@ -539,12 +548,14 @@
     }
 
     /**
-     * A response processor for a HTTP/2 multi response. A multi response
-     * comprises a main response, and zero or more additional responses. Each
-     * additional response is sent by the server in response to requests that
-     * the server also generates. Additional responses are typically resources
-     * that the server expects the client will need which are related to the
-     * initial request.
+     * A response processor for a HTTP/2 multi response.
+     * {@Incubating}
+     * <p>
+     * A multi response comprises a main response, and zero or more additional
+     * responses. Each additional response is sent by the server in response to
+     * requests that the server also generates. Additional responses are
+     * typically resources that the server expects the client will need which
+     * are related to the initial request.
      * <p>
      * Note. Instead of implementing this interface, applications should consider
      * first using the mechanism (built on this interface) provided by
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpTimeoutException.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpTimeoutException.java	Wed Jul 05 22:46:04 2017 +0200
@@ -29,6 +29,7 @@
 
 /**
  * Thrown when a response is not received within a specified time period.
+ * {@Incubating}
  */
 public class HttpTimeoutException extends IOException {
 
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/MultiMapResult.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/MultiMapResult.java	Wed Jul 05 22:46:04 2017 +0200
@@ -32,6 +32,8 @@
 
 /**
  * A {@link java.util.Map} containing the result of a HTTP/2 request and multi-response.
+ * {@Incubating}
+ * <p>
  * This is one possible implementation of the aggregate result type {@code <U>} returned
  * from {@link HttpClient#sendAsync(HttpRequest,MultiProcessor) }.
  * The map is indexed by {@link HttpRequest} and each value is a
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocket.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocket.java	Wed Jul 05 22:46:04 2017 +0200
@@ -35,6 +35,7 @@
 
 /**
  * A WebSocket client conforming to RFC&nbsp;6455.
+ * {@Incubating}
  *
  * <p> A {@code WebSocket} provides full-duplex communication over a TCP
  * connection.
@@ -105,6 +106,7 @@
 
     /**
      * A builder for creating {@code WebSocket} instances.
+     * {@Incubating}
      *
      * <p> To build a {@code WebSocket}, {@linkplain HttpClient#newWebSocketBuilder(
      * URI, Listener) create} a builder, configure it as required by
@@ -219,6 +221,7 @@
 
     /**
      * A listener for events and messages on a {@code WebSocket}.
+     * {@Incubating}
      *
      * <p> Each method of {@code Listener} corresponds to a type of event or a
      * type of message. The {@code WebSocket} argument of the method is the
@@ -570,6 +573,7 @@
     /**
      * A marker used by {@link WebSocket.Listener} in cases where a partial
      * message may be received.
+     * {@Incubating}
      *
      * @see Listener#onText(WebSocket, CharSequence, MessagePart)
      * @see Listener#onBinary(WebSocket, ByteBuffer, MessagePart)
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocketHandshakeException.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocketHandshakeException.java	Wed Jul 05 22:46:04 2017 +0200
@@ -29,6 +29,7 @@
 
 /**
  * An exception used to signal the opening handshake failed.
+ * {@Incubating}
  *
  * @since 9
  */
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/package-info.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/package-info.java	Wed Jul 05 22:46:04 2017 +0200
@@ -25,8 +25,9 @@
 
 /**
  * <h2>High level HTTP and WebSocket API</h2>
+ * {@Incubating}
  *
- * This provides a high-level client interfaces to HTTP (versions 1.1 and 2) and
+ * <p> Provides high-level client interfaces to HTTP (versions 1.1 and 2) and
  * WebSocket. The main types defined are:
  *
  * <ul>
--- a/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/module-info.java	Wed Jul 05 22:46:04 2017 +0200
@@ -25,6 +25,7 @@
 
 /**
  * Defines the high-level HTTP and WebSocket API.
+ * {@Incubating}
  */
 module jdk.incubator.httpclient {
     requires java.base;
--- a/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -77,7 +77,7 @@
     INPUT_RECORD record;
     DWORD n;
     while (TRUE) {
-        if (ReadConsoleInput(hStdIn, &record, 1, &n) == 0) {
+        if (ReadConsoleInputW(hStdIn, &record, 1, &n) == 0) {
             return NULL;
         }
         if (record.EventType == KEY_EVENT) {
@@ -97,7 +97,7 @@
 
 JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getConsoleOutputCodepage
   (JNIEnv *, jobject) {
-    return GetConsoleCP();
+    return GetConsoleOutputCP();
 }
 
 JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalWidth
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Wed Jul 05 22:46:04 2017 +0200
@@ -356,7 +356,7 @@
                 this.md = md;
             } else {
                 if (!root.name().equals(md.name())) {
-                    error(getMsg("error.versioned.info.name.notequal"));
+                    error(getMsg("error.validator.info.name.notequal"));
                     isValid = false;
                 }
                 if (!root.requires().equals(md.requires())) {
@@ -365,10 +365,10 @@
                         if (rootRequires.contains(r))
                             continue;
                         if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) {
-                            error(getMsg("error.versioned.info.requires.transitive"));
+                            error(getMsg("error.validator.info.requires.transitive"));
                             isValid = false;
                         } else if (!isPlatformModule(r.name())) {
-                            error(getMsg("error.versioned.info.requires.added"));
+                            error(getMsg("error.validator.info.requires.added"));
                             isValid = false;
                         }
                     }
@@ -377,21 +377,21 @@
                         if (mdRequires.contains(r))
                             continue;
                         if (!isPlatformModule(r.name())) {
-                            error(getMsg("error.versioned.info.requires.dropped"));
+                            error(getMsg("error.validator.info.requires.dropped"));
                             isValid = false;
                         }
                     }
                 }
                 if (!root.exports().equals(md.exports())) {
-                    error(getMsg("error.versioned.info.exports.notequal"));
+                    error(getMsg("error.validator.info.exports.notequal"));
                     isValid = false;
                 }
                 if (!root.opens().equals(md.opens())) {
-                    error(getMsg("error.versioned.info.opens.notequal"));
+                    error(getMsg("error.validator.info.opens.notequal"));
                     isValid = false;
                 }
                 if (!root.provides().equals(md.provides())) {
-                    error(getMsg("error.versioned.info.provides.notequal"));
+                    error(getMsg("error.validator.info.provides.notequal"));
                     isValid = false;
                 }
                 if (!root.mainClass().equals(md.mainClass())) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleSorter.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleSorter.java	Wed Jul 05 22:46:04 2017 +0200
@@ -25,10 +25,12 @@
 package jdk.tools.jlink.internal;
 
 import jdk.tools.jlink.plugin.PluginException;
+import jdk.tools.jlink.plugin.ResourcePoolEntry;
 import jdk.tools.jlink.plugin.ResourcePoolModule;
 import jdk.tools.jlink.plugin.ResourcePoolModuleView;
 
 import java.lang.module.ModuleDescriptor;
+import java.nio.ByteBuffer;
 import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -53,10 +55,19 @@
         moduleView.modules().forEach(this::addModule);
     }
 
+    private ModuleDescriptor readModuleDescriptor(ResourcePoolModule module) {
+        String p = "/" + module.name() + "/module-info.class";
+        ResourcePoolEntry content = module.findEntry(p).orElseThrow(() ->
+            new PluginException("module-info.class not found for " +
+                module.name() + " module")
+        );
+        ByteBuffer bb = ByteBuffer.wrap(content.contentBytes());
+        return ModuleDescriptor.read(bb);
+    }
+
     private ModuleSorter addModule(ResourcePoolModule module) {
-        ModuleDescriptor descriptor = module.descriptor();
         addNode(module);
-        descriptor.requires().stream()
+        readModuleDescriptor(module).requires().stream()
             .forEach(req -> {
                 String dm = req.name();
                 ResourcePoolModule dep = moduleView.findModule(dm)
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Wed Jul 05 22:46:04 2017 +0200
@@ -194,8 +194,6 @@
 
     private final class PluginsHelper {
 
-        private static final String PLUGINS_PATH = "--plugin-module-path";
-
         private Layer pluginsLayer = Layer.boot();
         private final List<Plugin> plugins;
         private String lastSorter;
@@ -503,22 +501,7 @@
         }
 
         private String getPluginsPath(String[] args) throws BadArgs {
-            String pp = null;
-            for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
-                    if (i == args.length - 1) {
-                        throw new BadArgs("err.no.plugins.path").showUsage(true);
-                    } else {
-                        i += 1;
-                        pp = args[i];
-                        if (!pp.isEmpty() && pp.charAt(0) == '-') {
-                            throw new BadArgs("err.no.plugins.path").showUsage(true);
-                        }
-                        break;
-                    }
-                }
-            }
-            return pp;
+            return null;
         }
 
         // used by jimage. Return unhandled arguments like "create", "describe".
@@ -542,31 +525,7 @@
             // Must extract it prior to do any option analysis.
             // Required to interpret custom plugin options.
             // Unit tests can call Task multiple time in same JVM.
-            pluginOptions = new PluginsHelper(getPluginsPath(args));
-
-            // First extract plugins path if any
-            String pp = null;
-            List<String> filteredArgs = new ArrayList<>();
-            for (int i = 0; i < args.length; i++) {
-                if (args[i].equals(PluginsHelper.PLUGINS_PATH)) {
-                    if (i == args.length - 1) {
-                        throw new BadArgs("err.no.plugins.path").showUsage(true);
-                    } else {
-                        warning("warn.thirdparty.plugins.enabled");
-                        log.println(bundleHelper.getMessage("warn.thirdparty.plugins"));
-                        i += 1;
-                        String arg = args[i];
-                        if (!arg.isEmpty() && arg.charAt(0) == '-') {
-                            throw new BadArgs("err.no.plugins.path").showUsage(true);
-                        }
-                        pp = args[i];
-                    }
-                } else {
-                    filteredArgs.add(args[i]);
-                }
-            }
-            String[] arr = new String[filteredArgs.size()];
-            args = filteredArgs.toArray(arr);
+            pluginOptions = new PluginsHelper(null);
 
             List<String> rest = collectUnhandled? new ArrayList<>() : null;
             // process options
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Wed Jul 05 22:46:04 2017 +0200
@@ -29,7 +29,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.*;
+import java.lang.module.ModuleDescriptor.Exports;
+import java.lang.module.ModuleDescriptor.Opens;
+import java.lang.module.ModuleDescriptor.Provides;
+import java.lang.module.ModuleDescriptor.Requires;
+import java.lang.module.ModuleDescriptor.Version;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
@@ -41,8 +45,6 @@
 import java.util.TreeSet;
 import java.util.function.IntSupplier;
 
-import jdk.internal.misc.JavaLangModuleAccess;
-import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.Checks;
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModuleInfo.Attributes;
@@ -55,6 +57,7 @@
 
 import static jdk.internal.org.objectweb.asm.Opcodes.*;
 
+import jdk.tools.jlink.internal.ModuleSorter;
 import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.Plugin;
@@ -63,7 +66,7 @@
 
 /**
  * Jlink plugin to reconstitute module descriptors for system modules.
- * It will extend module-info.class with Packages attribute,
+ * It will extend module-info.class with ModulePackages attribute,
  * if not present. It also determines the number of packages of
  * the boot layer at link time.
  *
@@ -73,16 +76,15 @@
  * @see SystemModules
  */
 public final class SystemModulesPlugin implements Plugin {
-    private static final JavaLangModuleAccess JLMA =
-        SharedSecrets.getJavaLangModuleAccess();
-
     private static final String NAME = "system-modules";
     private static final String DESCRIPTION =
         PluginsResourceBundle.getDescription(NAME);
 
     private boolean enabled;
+    private boolean retainModuleTarget;
     public SystemModulesPlugin() {
         this.enabled = true;
+        this.retainModuleTarget = false;
     }
 
     @Override
@@ -102,9 +104,19 @@
     }
 
     @Override
+    public boolean hasArguments() {
+        return true;
+    }
+
+    @Override
     public void configure(Map<String, String> config) {
-        if (config.containsKey(NAME)) {
-            enabled = false;
+        String arg = config.get(NAME);
+        if (arg != null) {
+            if (arg.equals("retainModuleTarget")) {
+                retainModuleTarget = true;
+            } else {
+                throw new IllegalArgumentException(NAME + ": " + arg);
+            }
         }
     }
 
@@ -114,12 +126,15 @@
             throw new PluginException(NAME + " was set");
         }
 
-        SystemModulesClassGenerator generator = new SystemModulesClassGenerator();
+        SystemModulesClassGenerator generator =
+            new SystemModulesClassGenerator(retainModuleTarget);
 
         // generate the byte code to create ModuleDescriptors
-        // skip parsing module-info.class and skip name check
-        in.moduleView().modules().forEach(module -> {
+        // such that the modules linked in the image would skip parsing
+        // of module-info.class and also skip name check
 
+        // Sort modules in the topological order so that java.base is always first.
+        new ModuleSorter(in.moduleView()).sorted().forEach(module -> {
             ResourcePoolEntry data = module.findEntry("module-info.class").orElseThrow(
                 // automatic module not supported yet
                 () ->  new PluginException("module-info.class not found for " +
@@ -128,19 +143,10 @@
 
             assert module.name().equals(data.moduleName());
             try {
-                ModuleInfo moduleInfo = new ModuleInfo(data.contentBytes(), module.packages());
-                generator.addModule(moduleInfo);
+                // validate the module and add to system modules
+                data = generator.buildModuleInfo(data, module.packages());
 
-                // link-time validation
-                moduleInfo.validateNames();
-                // check if any exported or open package is not present
-                moduleInfo.validatePackages();
-
-                // Packages attribute needs update
-                if (moduleInfo.shouldAddPackagesAttribute()) {
-                    // replace with the overridden version
-                    data = data.copyWithContent(moduleInfo.getBytes());
-                }
+                // add resource pool entry
                 out.add(data);
             } catch (IOException e) {
                 throw new PluginException(e);
@@ -164,29 +170,55 @@
         return out.build();
     }
 
-    class ModuleInfo {
-        final ModuleDescriptor descriptor;
-        final ModuleHashes recordedHashes;
-        final ModuleResolution moduleResolution;
-        final Set<String> packages;
-        final ByteArrayInputStream bain;
+    static class ModuleInfo {
+        private final Attributes attrs;
+        private final Set<String> packages;
+        private final ByteArrayInputStream bain;
+        private final boolean dropModuleTarget;
+        private ModuleDescriptor descriptor;  // may be different that the original one
 
-        ModuleInfo(byte[] bytes, Set<String> packages) throws IOException {
+        ModuleInfo(byte[] bytes, Set<String> packages, boolean dropModuleTarget)
+            throws IOException
+        {
             this.bain = new ByteArrayInputStream(bytes);
             this.packages = packages;
 
-            Attributes attrs = jdk.internal.module.ModuleInfo.read(bain, null);
+            this.attrs = jdk.internal.module.ModuleInfo.read(bain, null);
             this.descriptor = attrs.descriptor();
-            this.recordedHashes = attrs.recordedHashes();
-            this.moduleResolution = attrs.moduleResolution();
-
             if (descriptor.isAutomatic()) {
                 throw new InternalError("linking automatic module is not supported");
             }
+
+            if (dropModuleTarget) {
+                // drop target attribute only if any OS property is present
+                this.dropModuleTarget =
+                    descriptor.osName().isPresent() ||
+                    descriptor.osArch().isPresent() ||
+                    descriptor.osVersion().isPresent();
+            } else {
+                this.dropModuleTarget = false;
+            }
         }
 
         String moduleName() {
-            return descriptor.name();
+            return attrs.descriptor().name();
+        }
+
+        ModuleDescriptor descriptor() {
+            return descriptor;
+        }
+
+
+        Set<String> packages() {
+            return packages;
+        }
+
+        ModuleHashes recordedHashes() {
+            return attrs.recordedHashes();
+        }
+
+        ModuleResolution moduleResolution() {
+            return attrs.moduleResolution();
         }
 
         /**
@@ -217,6 +249,9 @@
             for (String pn : descriptor.packages()) {
                 Checks.requirePackageName(pn);
             }
+            for (String pn : packages) {
+                Checks.requirePackageName(pn);
+            }
         }
 
 
@@ -242,22 +277,47 @@
         }
 
         /**
-         * Returns true if the PackagesAttribute should be written
+         * Returns true if module-info.class should be written
+         * 1. add ModulePackages attribute if not present; or
+         * 2. drop ModuleTarget attribute except java.base
          */
-        boolean shouldAddPackagesAttribute() {
-            return descriptor.packages().isEmpty() && packages.size() > 0;
+        boolean shouldRewrite() {
+            return shouldAddModulePackages() || shouldDropModuleTarget();
+        }
+
+        boolean shouldAddModulePackages() {
+            return (descriptor.packages().isEmpty() && packages.size() > 0);
+        }
+
+        boolean shouldDropModuleTarget() {
+            return dropModuleTarget &&
+                        (descriptor.osName().isPresent() ||
+                         descriptor.osArch().isPresent() ||
+                         descriptor.osVersion().isPresent());
         }
 
         /**
-         * Returns the bytes for the module-info.class with PackagesAttribute
+         * Returns the bytes for the module-info.class with ModulePackages
          * if it contains at least one package
          */
         byte[] getBytes() throws IOException {
             bain.reset();
 
-            // add Packages attribute if not exist
-            if (shouldAddPackagesAttribute()) {
-                return new ModuleInfoRewriter(bain, packages).getBytes();
+            // add ModulePackages attribute if not exist
+            if (shouldRewrite()) {
+                ModuleInfoRewriter rewriter = new ModuleInfoRewriter(bain);
+                if (shouldAddModulePackages()) {
+                    rewriter.addModulePackages(packages);
+                }
+                if (shouldDropModuleTarget()) {
+                    rewriter.dropModuleTarget();
+                }
+                // rewritten module descriptor
+                byte[] bytes = rewriter.getBytes();
+                try (ByteArrayInputStream bain = new ByteArrayInputStream(bytes)) {
+                     this.descriptor = ModuleDescriptor.read(bain);
+                }
+                return bytes;
             } else {
                 return bain.readAllBytes();
             }
@@ -265,16 +325,23 @@
 
         class ModuleInfoRewriter extends ByteArrayOutputStream {
             final ModuleInfoExtender extender;
-            ModuleInfoRewriter(InputStream in, Set<String> packages) throws IOException {
+            ModuleInfoRewriter(InputStream in) {
                 this.extender = ModuleInfoExtender.newExtender(in);
-                // Add Packages attribute
-                if (packages.size() > 0) {
-                    this.extender.packages(packages);
-                }
-                this.extender.write(this);
             }
 
-            byte[] getBytes() {
+            void addModulePackages(Set<String> packages) {
+                // Add ModulePackages attribute
+                if (packages.size() > 0) {
+                    extender.packages(packages);
+                }
+            }
+
+            void dropModuleTarget() {
+                extender.targetPlatform("", "", "");
+            }
+
+            byte[] getBytes() throws IOException {
+                extender.write(this);
                 return buf;
             }
         }
@@ -316,6 +383,7 @@
         private int nextLocalVar         = 2;  // index to next local variable
 
         private final ClassWriter cw;
+        private boolean dropModuleTarget;
 
         // Method visitor for generating the SystemModules::modules() method
         private MethodVisitor mv;
@@ -329,9 +397,10 @@
         private final DedupSetBuilder dedupSetBuilder
             = new DedupSetBuilder(this::getNextLocalVar);
 
-        public SystemModulesClassGenerator() {
+        public SystemModulesClassGenerator(boolean retainModuleTarget) {
             this.cw = new ClassWriter(ClassWriter.COMPUTE_MAXS +
                                       ClassWriter.COMPUTE_FRAMES);
+            this.dropModuleTarget = !retainModuleTarget;
         }
 
         private int getNextLocalVar() {
@@ -395,14 +464,52 @@
         }
 
         /*
-         * Adds the given ModuleDescriptor to the system module list, and
-         * prepares mapping from various Sets to SetBuilders to emit an
-         * optimized number of sets during build.
+         * Adds the given ModuleDescriptor to the system module list.
+         * It performs link-time validation and prepares mapping from various
+         * Sets to SetBuilders to emit an optimized number of sets during build.
          */
-        public void addModule(ModuleInfo moduleInfo) {
-            ModuleDescriptor md = moduleInfo.descriptor;
+        public ResourcePoolEntry buildModuleInfo(ResourcePoolEntry entry,
+                                                 Set<String> packages)
+            throws IOException
+        {
+            if (moduleInfos.isEmpty() && !entry.moduleName().equals("java.base")) {
+                throw new InternalError("java.base must be the first module to process");
+            }
+
+            ModuleInfo moduleInfo;
+            if (entry.moduleName().equals("java.base")) {
+                moduleInfo = new ModuleInfo(entry.contentBytes(), packages, false);
+                ModuleDescriptor md = moduleInfo.descriptor;
+                // drop Moduletarget attribute only if java.base has all OS properties
+                // otherwise, retain it
+                if (dropModuleTarget &&
+                        md.osName().isPresent() && md.osArch().isPresent() &&
+                        md.osVersion().isPresent()) {
+                    dropModuleTarget = true;
+                } else {
+                    dropModuleTarget = false;
+                }
+            } else {
+                moduleInfo = new ModuleInfo(entry.contentBytes(), packages, dropModuleTarget);
+            }
+
+            // link-time validation
+            moduleInfo.validateNames();
+            // check if any exported or open package is not present
+            moduleInfo.validatePackages();
+
+            // module-info.class may be overridden for optimization
+            // 1. update ModuleTarget attribute to drop osName, osArch, osVersion
+            // 2. add/update ModulePackages attribute
+            if (moduleInfo.shouldRewrite()) {
+                entry = entry.copyWithContent(moduleInfo.getBytes());
+            }
             moduleInfos.add(moduleInfo);
+            dedups(moduleInfo.descriptor());
+            return entry;
+        }
 
+        private void dedups(ModuleDescriptor md) {
             // exports
             for (Exports e : md.exports()) {
                 dedupSetBuilder.stringSet(e.targets());
@@ -466,8 +573,8 @@
 
             for (int index = 0; index < moduleInfos.size(); index++) {
                 ModuleInfo minfo = moduleInfos.get(index);
-                new ModuleDescriptorBuilder(minfo.descriptor,
-                                            minfo.packages,
+                new ModuleDescriptorBuilder(minfo.descriptor(),
+                                            minfo.packages(),
                                             index).build();
             }
             mv.visitVarInsn(ALOAD, MD_VAR);
@@ -494,8 +601,8 @@
 
             for (int index = 0; index < moduleInfos.size(); index++) {
                 ModuleInfo minfo = moduleInfos.get(index);
-                if (minfo.recordedHashes != null) {
-                    new ModuleHashesBuilder(minfo.recordedHashes,
+                if (minfo.recordedHashes() != null) {
+                    new ModuleHashesBuilder(minfo.recordedHashes(),
                                             index,
                                             hmv).build();
                 }
@@ -525,12 +632,12 @@
 
             for (int index=0; index < moduleInfos.size(); index++) {
                 ModuleInfo minfo = moduleInfos.get(index);
-                if (minfo.moduleResolution != null) {
+                if (minfo.moduleResolution() != null) {
                     mresmv.visitVarInsn(ALOAD, 0);
                     pushInt(mresmv, index);
                     mresmv.visitTypeInsn(NEW, MODULE_RESOLUTION_CLASSNAME);
                     mresmv.visitInsn(DUP);
-                    mresmv.visitLdcInsn(minfo.moduleResolution.value());
+                    mresmv.visitLdcInsn(minfo.moduleResolution().value());
                     mresmv.visitMethodInsn(INVOKESPECIAL,
                                            MODULE_RESOLUTION_CLASSNAME,
                                            "<init>",
@@ -644,6 +751,11 @@
                 // main class
                 md.mainClass().ifPresent(this::mainClass);
 
+                // os name, arch, version
+                targetPlatform(md.osName().orElse(null),
+                               md.osArch().orElse(null),
+                               md.osVersion().orElse(null));
+
                 putModuleDescriptor();
             }
 
@@ -937,6 +1049,33 @@
                     "version", STRING_SIG, false);
                 mv.visitInsn(POP);
             }
+
+            /*
+             * Invoke Builder.osName(String name)
+             *        Builder.osArch(String arch)
+             *        Builder.osVersion(String version)
+             */
+            void targetPlatform(String osName, String osArch, String osVersion) {
+                if (osName != null) {
+                    invokeBuilderMethod("osName", osName);
+                }
+
+                if (osArch != null) {
+                    invokeBuilderMethod("osArch", osArch);
+                }
+
+                if (osVersion != null) {
+                    invokeBuilderMethod("osVersion", osVersion);
+                }
+            }
+
+            void invokeBuilderMethod(String methodName, String value) {
+                mv.visitVarInsn(ALOAD, BUILDER_VAR);
+                mv.visitLdcInsn(value);
+                mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER,
+                    methodName, STRING_SIG, false);
+                mv.visitInsn(POP);
+            }
         }
 
         class ModuleHashesBuilder {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -81,6 +81,8 @@
 Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If\n\
 this flag is not specified a default set of classes will be generated.
 
+system-modules.argument=retainModuleTarget
+
 system-modules.description=Fast loading of module descriptors (always enabled)
 
 onoff.argument=<on|off>
@@ -142,9 +144,6 @@
 \      --resources-last-sorter <name>    The last plugin allowed to sort\n\
 \                                        resources
 
-plugin.opt.plugin-module-path=\
-\      --plugin-module-path <modulepath> Custom plugin module path
-
 plugin.opt.disable-plugin=\
 \      --disable-plugin <pluginname>     Disable the plugin mentioned
 
--- a/jdk/test/ProblemList.txt	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 22:46:04 2017 +0200
@@ -203,6 +203,8 @@
 
 sun/rmi/rmic/newrmic/equivalence/run.sh                         8145980 generic-all
 
+java/rmi/registry/readTest/CodebaseTest.java                    8173324 windows-all
+
 ############################################################################
 
 # jdk_security
@@ -251,6 +253,7 @@
 
 tools/pack200/CommandLineTests.java                             8059906 generic-all
 
+tools/launcher/ArgsEnvVar.java					8173712 generic-all
 tools/launcher/FXLauncherTest.java                              8068049 linux-all,macosx-all
 
 tools/jimage/JImageExtractTest.java                             8169713 generic-all
@@ -260,8 +263,6 @@
 
 tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java       8169971 windows-x64
 
-tools/jlink/CustomPluginTest.java                               8172864 generic-all
-
 ############################################################################
 
 # jdk_jdi
--- a/jdk/test/java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -21,43 +21,54 @@
  * questions.
  */
 
-/*
+ /*
   @test
-  @bug 8154043
+  @bug 8154043 8172509
   @summary Fields not reachable anymore by tab-key, because of new tabbing
   behaviour of radio button groups.
   @run main ButtonGroupLayoutTraversalTest
-*/
-
-import javax.swing.*;
-import java.awt.*;
+ */
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.Robot;
 import java.awt.event.FocusAdapter;
 import java.awt.event.FocusEvent;
 import java.awt.event.KeyEvent;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.JPanel;
+import javax.swing.ButtonGroup;
+import javax.swing.JComponent;
+import javax.swing.JRadioButton;
+import javax.swing.JToggleButton;
+import javax.swing.LayoutFocusTraversalPolicy;
+import javax.swing.UnsupportedLookAndFeelException;
 
 public class ButtonGroupLayoutTraversalTest {
+
     static int nx = 3;
     static int ny = 3;
 
     static int focusCnt[] = new int[nx * ny];
     private static JFrame window;
 
-
     public static void main(String[] args) throws Exception {
 
-        SwingUtilities.invokeAndWait(()->initLayout(nx, ny));
+        SwingUtilities.invokeAndWait(() -> changeLAF());
+        SwingUtilities.invokeAndWait(() -> initLayout(nx, ny));
         Robot robot = new Robot();
         robot.setAutoDelay(100);
         robot.waitForIdle();
         robot.delay(200);
 
-
-        for(int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
+        for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
             robot.keyPress(KeyEvent.VK_RIGHT);
             robot.keyRelease(KeyEvent.VK_RIGHT);
         }
 
-        for(int i = 0; i < nx * ny / 2; i++) {
+        for (int i = 0; i < nx * ny / 2; i++) {
             robot.keyPress(KeyEvent.VK_TAB);
             robot.keyRelease(KeyEvent.VK_TAB);
         }
@@ -65,26 +76,26 @@
         robot.waitForIdle();
         robot.delay(200);
 
-        for(int i = 0; i < nx * ny; i++) {
-            if(focusCnt[i] < 1) {
+        for (int i = 0; i < nx * ny; i++) {
+            if (focusCnt[i] < 1) {
                 SwingUtilities.invokeLater(window::dispose);
-                throw new RuntimeException("Component " + i +
-                        " is not reachable in the forward focus cycle");
+                throw new RuntimeException("Component " + i
+                        + " is not reachable in the forward focus cycle");
             } else if (focusCnt[i] > 1) {
                 SwingUtilities.invokeLater(window::dispose);
-                throw new RuntimeException("Component " + i +
-                        " got focus more than once in the forward focus cycle");
+                throw new RuntimeException("Component " + i
+                        + " got focus more than once in the forward focus cycle");
             }
         }
 
-        for(int i = 0; i < nx * ny / 2; i++) {
+        for (int i = 0; i < nx * ny / 2; i++) {
             robot.keyPress(KeyEvent.VK_SHIFT);
             robot.keyPress(KeyEvent.VK_TAB);
             robot.keyRelease(KeyEvent.VK_TAB);
             robot.keyRelease(KeyEvent.VK_SHIFT);
         }
 
-        for(int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
+        for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
             robot.keyPress(KeyEvent.VK_LEFT);
             robot.keyRelease(KeyEvent.VK_LEFT);
         }
@@ -97,23 +108,37 @@
         robot.waitForIdle();
         robot.delay(200);
 
-        for(int i = 0; i < nx * ny; i++) {
-            if(focusCnt[i] < 2) {
+        for (int i = 0; i < nx * ny; i++) {
+            if (focusCnt[i] < 2) {
                 SwingUtilities.invokeLater(window::dispose);
-                throw new RuntimeException("Component " + i +
-                        " is not reachable in the backward focus cycle");
+                throw new RuntimeException("Component " + i
+                        + " is not reachable in the backward focus cycle");
             } else if (focusCnt[i] > 2) {
                 SwingUtilities.invokeLater(window::dispose);
-                throw new RuntimeException("Component " + i +
-                        " got focus more than once in the backward focus cycle");
+                throw new RuntimeException("Component " + i
+                        + " got focus more than once in the backward focus cycle");
             }
         }
 
         SwingUtilities.invokeLater(window::dispose);
     }
 
-    public static void initLayout(int nx, int ny)
-    {
+    private static void changeLAF() {
+        String currentLAF = UIManager.getLookAndFeel().toString();
+        currentLAF = currentLAF.toLowerCase();
+        if (currentLAF.contains("aqua") || currentLAF.contains("nimbus")) {
+            try {
+                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+            } catch (ClassNotFoundException
+                    | IllegalAccessException
+                    | InstantiationException
+                    | UnsupportedLookAndFeelException ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+    public static void initLayout(int nx, int ny) {
         window = new JFrame("Test");
         window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         JPanel rootPanel = new JPanel();
@@ -122,9 +147,9 @@
         formPanel.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
         formPanel.setFocusCycleRoot(true);
         ButtonGroup radioButtonGroup = new ButtonGroup();
-        for(int i = 0; i < nx * ny; i++) {
+        for (int i = 0; i < nx * ny; i++) {
             JToggleButton comp;
-            if(i % 2 == 0) {
+            if (i % 2 == 0) {
                 comp = new JRadioButton("Grouped component");
                 radioButtonGroup.add(comp);
             } else {
@@ -137,10 +162,10 @@
                 @Override
                 public void focusGained(FocusEvent e) {
                     focusCnt[fi]++;
-                    if( focusCnt[fi] == 1) {
+                    if (focusCnt[fi] == 1) {
                         ((JComponent) e.getSource())
                                 .setBackground(Color.yellow);
-                    } else if(focusCnt[fi] == 2) {
+                    } else if (focusCnt[fi] == 2) {
                         ((JComponent) e.getSource())
                                 .setBackground(Color.green);
                     } else {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FontClass/AppleFontNameTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6232267
+ * @requires (os.family == "mac")
+ * @summary Test reading a font with only Apple names.
+ * @run main AppleFontNameTest
+ */
+
+import java.awt.Font;
+import java.io.File;
+
+/*
+ * This test picks on a font that is known to have only Apple names.
+ * So it runs only on MacOS and works only if the font is where it
+ * has historically been. Anything else is a silent pass.`
+ */
+
+public class AppleFontNameTest {
+
+    static String file = "/System/Library/Fonts/Menlo.ttc";
+
+    public static void main(String[] args) throws Exception {
+        String os = System.getProperty("os.name");
+        if (!(os.startsWith("Mac"))) {
+            return;
+        }
+        File fontFile = new File(file);
+        if (!fontFile.exists()) {
+            return;
+        }
+        Font[] fonts = Font.createFonts(new File(file));
+        System.out.println("createFont from file returned " + fonts);
+
+        if (fonts == null || fonts.length == 0) {
+            throw new RuntimeException("No fonts");
+        }
+        for (Font f : fonts) {
+            System.out.println(f);
+            if (!f.getFamily().equals("Menlo"))
+               throw new RuntimeException("Expected Menlo, got " + f.getFamily());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FontMetrics/FontCrash.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8172999
+ * @summary Verify no crash loading font metrics instance.
+ * @run main/othervm FontCrash
+ */
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Toolkit;
+
+public class FontCrash {
+
+    public static void main(String[] args) {
+        System.setProperty("java2d.font.usePlatformFont", "true");
+        Font f = new Font(Font.DIALOG,Font.PLAIN,12);
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        tk.getFontMetrics(f);
+    }
+}
--- a/jdk/test/java/awt/font/JNICheck/JNICheck.sh	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/awt/font/JNICheck/JNICheck.sh	Wed Jul 05 22:46:04 2017 +0200
@@ -23,7 +23,7 @@
 #
 #
 #   @test
-#   @bug        6430247 8130507 8020448
+#   @bug        6430247 8130507 8020448 8172813
 #   @summary    Tests that there are no JNI warnings.
 #   @compile JNICheck.java
 #   @run shell/timeout=300 JNICheck.sh
@@ -49,7 +49,7 @@
 fi
 
 $JAVA_HOME/bin/java ${TESTVMOPTS} \
-    -cp "${CP}" -Xcheck:jni JNICheck > "${CP}"/log.txt
+    -cp "${CP}" -Xcheck:jni JNICheck | grep -v SIG | grep -v Signal | grep -v CallStatic > "${CP}"/log.txt
 
 # any messages logged may indicate a failure.
 if [ -s "${CP}"/log.txt ]; then
--- a/jdk/test/java/lang/annotation/AnnotationVerifier.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/lang/annotation/AnnotationVerifier.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -27,9 +27,15 @@
  * Create class file using ASM, slightly modified the ASMifier output
  */
 
-import sun.reflect.annotation.AnnotationType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.lang.annotation.Annotation;
 import java.lang.annotation.AnnotationFormatError;
-import org.testng.annotations.*;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /*
  * @test
@@ -37,27 +43,380 @@
  * @summary Verify valid annotation
  * @modules java.base/jdk.internal.org.objectweb.asm
  * @modules java.base/sun.reflect.annotation
- * @clean AnnotationWithVoidReturn.class AnnotationWithParameter.class
- * @compile -XDignore.symbol.file ClassFileGenerator.java
+ * @clean AnnotationWithVoidReturn AnnotationWithParameter
+ *        AnnotationWithExtraInterface AnnotationWithException
+ *        AnnotationWithHashCode AnnotationWithDefaultMember
+ *        AnnotationWithoutAnnotationAccessModifier HolderX
+ * @compile -XDignore.symbol.file ClassFileGenerator.java GoodAnnotation.java
  * @run main ClassFileGenerator
  * @run testng AnnotationVerifier
  */
 
 public class AnnotationVerifier {
 
+    //=======================================================
+    // GoodAnnotation...
+
+    @GoodAnnotation
+    static class HolderA {
+    }
+
+    @Test
+    public void holderA_goodAnnotation() {
+        testGetAnnotation(HolderA.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderA_annotations() {
+        testGetAnnotations(HolderA.class, GoodAnnotation.class);
+    }
+
+    //=======================================================
+    // AnnotationWithParameter...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithParameter {
+        int m(int x) default -1;
+    }
+    */
+
+    @GoodAnnotation
     @AnnotationWithParameter
+    static class HolderB {
+    }
+
+    @Test
+    public void holderB_annotationWithParameter() {
+        testGetAnnotation(HolderB.class, AnnotationWithParameter.class, false);
+    }
+
+    @Test
+    public void holderB_goodAnnotation() {
+        testGetAnnotation(HolderB.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderB_annotations() {
+        testGetAnnotations(HolderB.class, GoodAnnotation.class);
+    }
+
+    //=======================================================
+    // AnnotationWithVoidReturn...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithVoidReturn {
+        void m() default 1;
+    }
+    */
+
+    @GoodAnnotation
     @AnnotationWithVoidReturn
-    static class BadAnnotation {
+    static class HolderC {
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderC_annotationWithVoidReturn() {
+        testGetAnnotation(HolderC.class, AnnotationWithVoidReturn.class, false);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderC_goodAnnotation() {
+        testGetAnnotation(HolderC.class, GoodAnnotation.class, false);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderC_annotations() {
+        testGetAnnotations(HolderC.class);
+    }
+
+    //=======================================================
+    // AnnotationWithExtraInterface...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithExtraInterface extends java.io.Serializable {
+        int m() default 1;
+    }
+    */
+
+    @GoodAnnotation
+    @AnnotationWithExtraInterface
+    static class HolderD {
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderD_annotationWithExtraInterface() {
+        testGetAnnotation(HolderD.class, AnnotationWithExtraInterface.class, false);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderD_goodAnnotation() {
+        testGetAnnotation(HolderD.class, GoodAnnotation.class, false);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderD_annotations() {
+        testGetAnnotations(HolderD.class);
+    }
+
+    //=======================================================
+    // AnnotationWithException...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithException {
+        int m() throws Exception default 1;
+    }
+    */
+
+    @GoodAnnotation
+    @AnnotationWithException
+    static class HolderE {
+    }
+
+    @AnnotationWithException
+    static class HolderE2 {
+    }
+
+    @Test
+    public void holderE_annotationWithException() {
+        testGetAnnotation(HolderE.class, AnnotationWithException.class, true);
+    }
+
+    @Test
+    public void holderE_goodAnnotation() {
+        testGetAnnotation(HolderE.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderE_annotations() {
+        testGetAnnotations(HolderE.class, GoodAnnotation.class, AnnotationWithException.class);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderE_annotationWithException_equals() {
+        AnnotationWithException ann1, ann2;
+        try {
+            ann1 = HolderE.class.getAnnotation(AnnotationWithException.class);
+            ann2 = HolderE2.class.getAnnotation(AnnotationWithException.class);
+        } catch (Throwable t) {
+            throw new AssertionError("Unexpected exception", t);
+        }
+        Assert.assertNotNull(ann1);
+        Assert.assertNotNull(ann2);
+
+        testEquals(ann1, ann2, true); // this throws AnnotationFormatError
+    }
+
+    //=======================================================
+    // AnnotationWithHashCode...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithHashCode {
+        int hashCode() default 1;
+    }
+    */
+
+    @GoodAnnotation
+    @AnnotationWithHashCode
+    static class HolderF {
+    }
+
+    @AnnotationWithHashCode
+    static class HolderF2 {
+    }
+
+    @Test
+    public void holderF_annotationWithHashCode() {
+        testGetAnnotation(HolderF.class, AnnotationWithHashCode.class, true);
     }
 
     @Test
-    @ExpectedExceptions(IllegalArgumentException.class)
-    public void annotationValidationIAE() {
-        AnnotationType.getInstance(AnnotationWithParameter.class);
+    public void holderF_goodAnnotation() {
+        testGetAnnotation(HolderF.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderF_annotations() {
+        testGetAnnotations(HolderF.class, GoodAnnotation.class, AnnotationWithHashCode.class);
+    }
+
+    @Test(expectedExceptions = AnnotationFormatError.class)
+    public void holderF_annotationWithHashCode_equals() {
+        AnnotationWithHashCode ann1, ann2;
+        try {
+            ann1 = HolderF.class.getAnnotation(AnnotationWithHashCode.class);
+            ann2 = HolderF2.class.getAnnotation(AnnotationWithHashCode.class);
+        } catch (Throwable t) {
+            throw new AssertionError("Unexpected exception", t);
+        }
+        Assert.assertNotNull(ann1);
+        Assert.assertNotNull(ann2);
+
+        testEquals(ann1, ann2, true); // this throws AnnotationFormatError
+    }
+
+    //=======================================================
+    // AnnotationWithDefaultMember...
+
+    /*
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithDefaultMember {
+        int m() default 1;
+        default int d() default 2 { return 2; }
+    }
+    */
+
+    @GoodAnnotation
+    @AnnotationWithDefaultMember
+    static class HolderG {
+    }
+
+    @AnnotationWithDefaultMember
+    static class HolderG2 {
+    }
+
+    @Test
+    public void holderG_annotationWithDefaultMember() {
+        testGetAnnotation(HolderG.class, AnnotationWithDefaultMember.class, true);
+    }
+
+    @Test
+    public void holderG_goodAnnotation() {
+        testGetAnnotation(HolderG.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderG_annotations() {
+        testGetAnnotations(HolderG.class, GoodAnnotation.class, AnnotationWithDefaultMember.class);
     }
 
     @Test(expectedExceptions = AnnotationFormatError.class)
-    public void annotationValidationAFE() {
-        BadAnnotation.class.getAnnotation(AnnotationWithVoidReturn.class);
+    public void holderG_annotationWithDefaultMember_equals() {
+        AnnotationWithDefaultMember ann1, ann2;
+        try {
+            ann1 = HolderG.class.getAnnotation(AnnotationWithDefaultMember.class);
+            ann2 = HolderG2.class.getAnnotation(AnnotationWithDefaultMember.class);
+        } catch (Throwable t) {
+            throw new AssertionError("Unexpected exception", t);
+        }
+        Assert.assertNotNull(ann1);
+        Assert.assertNotNull(ann2);
+
+        testEquals(ann1, ann2, true); // this throws AnnotationFormatError
+    }
+
+    //=======================================================
+    // AnnotationWithoutAnnotationAccessModifier...
+
+    /*
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public interface AnnotationWithoutAnnotationAccessModifier extends Annotation {
+        int m() default 1;
+    }
+
+    @GoodAnnotation
+    @AnnotationWithoutAnnotationAccessModifier
+    static class HolderX {
+    }
+
+    */
+
+    @Test
+    public void holderX_annotationWithoutAnnotationAccessModifier() {
+        testGetAnnotation(HolderX.class, AnnotationWithoutAnnotationAccessModifier.class, false);
+    }
+
+    @Test
+    public void holderX_goodAnnotation() {
+        testGetAnnotation(HolderX.class, GoodAnnotation.class, true);
+    }
+
+    @Test
+    public void holderX_annotations() {
+        testGetAnnotations(HolderX.class, GoodAnnotation.class);
+    }
+
+    //=======================================================
+    // utils
+    //
+
+    private static void testGetAnnotation(Class<?> holderClass,
+                                          Class<? extends Annotation> annType,
+                                          boolean expectedPresent) {
+        Object result = null;
+        try {
+            try {
+                result = holderClass.getAnnotation(annType);
+                if (expectedPresent != (result != null)) {
+                    throw new AssertionError("Expected " +
+                                             (expectedPresent ? "non-null" : "null") +
+                                             " result, but got: " + result);
+                }
+            } catch (Throwable t) {
+                result = t;
+                throw t;
+            }
+        } finally {
+            System.out.println("\n" +
+                               holderClass.getSimpleName() +
+                               ".class.getAnnotation(" +
+                               annType.getSimpleName() +
+                               ".class) = " +
+                               result);
+        }
+    }
+
+    private static void testGetAnnotations(Class<?> holderClass,
+                                           Class<? extends Annotation> ... expectedTypes) {
+        Object result = null;
+        try {
+            try {
+                Annotation[] anns = holderClass.getAnnotations();
+
+                Set<Class<? extends Annotation>> gotTypes =
+                    Stream.of(anns)
+                          .map(Annotation::annotationType)
+                          .collect(Collectors.toSet());
+
+                Set<Class<? extends Annotation>> expTypes =
+                    Stream.of(expectedTypes)
+                          .collect(Collectors.toSet());
+
+                if (!expTypes.equals(gotTypes)) {
+                    throw new AssertionError("Expected annotation types: " + expTypes +
+                                             " but got: " + Arrays.toString(anns));
+                }
+                result = Arrays.toString(anns);
+            } catch (Throwable t) {
+                result = t;
+                throw t;
+            }
+        } finally {
+            System.out.println("\n" +
+                               holderClass.getSimpleName() +
+                               ".class.getAnnotations() = " +
+                               result);
+        }
+    }
+
+    private static void testEquals(Annotation ann1, Annotation ann2, boolean expectedEquals) {
+        Object result = null;
+        try {
+            try {
+                boolean gotEquals = ann1.equals(ann2);
+                Assert.assertEquals(gotEquals, expectedEquals);
+                result = gotEquals;
+            } catch (Throwable t) {
+                result = t;
+                throw t;
+            }
+        } finally {
+            System.out.println("\n" + ann1 + ".equals(" + ann2 + ") = " + result);
+        }
     }
 }
--- a/jdk/test/java/lang/annotation/ClassFileGenerator.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/lang/annotation/ClassFileGenerator.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -40,6 +40,13 @@
     public static void main(String... args) throws Exception {
         classFileWriter("AnnotationWithVoidReturn.class", AnnoationWithVoidReturnDump.dump());
         classFileWriter("AnnotationWithParameter.class", AnnoationWithParameterDump.dump());
+        classFileWriter("AnnotationWithExtraInterface.class", AnnotationWithExtraInterfaceDump.dump());
+        classFileWriter("AnnotationWithException.class", AnnotationWithExceptionDump.dump());
+        classFileWriter("AnnotationWithHashCode.class", AnnotationWithHashCodeDump.dump());
+        classFileWriter("AnnotationWithDefaultMember.class", AnnotationWithDefaultMemberDump.dump());
+        classFileWriter("AnnotationWithoutAnnotationAccessModifier.class",
+                        AnnotationWithoutAnnotationAccessModifierDump.dump());
+        classFileWriter("HolderX.class", HolderXDump.dump());
     }
 
     private static void classFileWriter(String name, byte[] contents) throws IOException {
@@ -49,14 +56,13 @@
         }
     }
 
-    /*
-    Following code create equivalent classfile,
-    which is not allowed by javac.
+    /* Following code creates equivalent classfile, which is not allowed by javac:
 
     @Retention(RetentionPolicy.RUNTIME)
     public @interface AnnotationWithVoidReturn {
-    void m() default 1;
+        void m() default 1;
     }
+
     */
 
     private static class AnnoationWithVoidReturnDump implements Opcodes {
@@ -65,7 +71,7 @@
             MethodVisitor mv;
             AnnotationVisitor av0;
 
-            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + +ACC_INTERFACE,
+            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
                     "AnnotationWithVoidReturn", null,
                     "java/lang/Object", new String[]{"java/lang/annotation/Annotation"});
 
@@ -91,14 +97,13 @@
         }
     }
 
-    /*
-    Following code create equivalent classfile,
-    which is not allowed by javac.
+    /* Following code creates equivalent classfile, which is not allowed by javac:
 
     @Retention(RetentionPolicy.RUNTIME)
     public @interface AnnotationWithParameter {
-       int m(int x);
+        int m(int x) default -1;
     }
+
     */
 
     private static class AnnoationWithParameterDump implements Opcodes {
@@ -136,4 +141,250 @@
         }
     }
 
+    /* Following code creates equivalent classfile, which is not allowed by javac:
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithExtraInterface extends java.io.Serializable {
+        int m() default 1;
+    }
+
+    */
+
+    private static class AnnotationWithExtraInterfaceDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+            MethodVisitor mv;
+            AnnotationVisitor av0;
+
+            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
+                    "AnnotationWithExtraInterface", null,
+                    "java/lang/Object", new String[]{"java/lang/annotation/Annotation",
+                                                     "java/io/Serializable"});
+
+            {
+                av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
+                av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;",
+                        "RUNTIME");
+                av0.visitEnd();
+            }
+            {
+                mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "m", "()I", null, null);
+                mv.visitEnd();
+            }
+            {
+                av0 = mv.visitAnnotationDefault();
+                av0.visit(null, new Integer(1));
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
+
+    /* Following code creates equivalent classfile, which is not allowed by javac:
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithException {
+        int m() throws Exception default 1;
+    }
+
+    */
+
+    private static class AnnotationWithExceptionDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+            MethodVisitor mv;
+            AnnotationVisitor av0;
+
+            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
+                    "AnnotationWithException", null,
+                    "java/lang/Object", new String[]{"java/lang/annotation/Annotation"});
+
+            {
+                av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
+                av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;",
+                        "RUNTIME");
+                av0.visitEnd();
+            }
+            {
+                mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "m", "()I", null,
+                                    new String[] {"java/lang/Exception"});
+                mv.visitEnd();
+            }
+            {
+                av0 = mv.visitAnnotationDefault();
+                av0.visit(null, new Integer(1));
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
+
+    /* Following code creates equivalent classfile, which is not allowed by javac:
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithHashCode {
+        int hashCode() default 1;
+    }
+
+    */
+
+    private static class AnnotationWithHashCodeDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+            MethodVisitor mv;
+            AnnotationVisitor av0;
+
+            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
+                    "AnnotationWithHashCode", null,
+                    "java/lang/Object", new String[]{"java/lang/annotation/Annotation"});
+
+            {
+                av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
+                av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;",
+                        "RUNTIME");
+                av0.visitEnd();
+            }
+            {
+                mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "hashCode", "()I", null, null);
+                mv.visitEnd();
+            }
+            {
+                av0 = mv.visitAnnotationDefault();
+                av0.visit(null, new Integer(1));
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
+
+    /* Following code creates equivalent classfile, which is not allowed by javac:
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface AnnotationWithDefaultMember {
+        int m() default 1;
+        default int d() default 2 { return 2; }
+    }
+
+    */
+
+    private static class AnnotationWithDefaultMemberDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+            MethodVisitor mv, dv;
+            AnnotationVisitor av0;
+
+            cw.visit(52, ACC_PUBLIC + ACC_ANNOTATION + ACC_ABSTRACT + ACC_INTERFACE,
+                    "AnnotationWithDefaultMember", null,
+                    "java/lang/Object", new String[]{"java/lang/annotation/Annotation"});
+
+            {
+                av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
+                av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;",
+                        "RUNTIME");
+                av0.visitEnd();
+            }
+            {
+                mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "m", "()I", null, null);
+                mv.visitEnd();
+            }
+            {
+                av0 = mv.visitAnnotationDefault();
+                av0.visit(null, new Integer(1));
+                av0.visitEnd();
+            }
+            {
+                dv = cw.visitMethod(ACC_PUBLIC, "d", "()I", null, null);
+                dv.visitMaxs(1, 1);
+                dv.visitCode();
+                dv.visitInsn(Opcodes.ICONST_2);
+                dv.visitInsn(Opcodes.IRETURN);
+                dv.visitEnd();
+            }
+            {
+                av0 = dv.visitAnnotationDefault();
+                av0.visit(null, new Integer(2));
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
+
+    /* Following code creates equivalent classfile, which is not allowed by javac:
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public interface AnnotationWithoutAnnotationAccessModifier extends java.lang.annotation.Annotation {
+        int m() default 1;
+    }
+
+    */
+
+    private static class AnnotationWithoutAnnotationAccessModifierDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+            MethodVisitor mv;
+            AnnotationVisitor av0;
+
+            cw.visit(52, ACC_PUBLIC + /* ACC_ANNOTATION +*/ ACC_ABSTRACT + ACC_INTERFACE,
+                    "AnnotationWithoutAnnotationAccessModifier", null,
+                    "java/lang/Object", new String[]{"java/lang/annotation/Annotation"});
+
+            {
+                av0 = cw.visitAnnotation("Ljava/lang/annotation/Retention;", true);
+                av0.visitEnum("value", "Ljava/lang/annotation/RetentionPolicy;",
+                        "RUNTIME");
+                av0.visitEnd();
+            }
+            {
+                mv = cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "m", "()I", null, null);
+                mv.visitEnd();
+            }
+            {
+                av0 = mv.visitAnnotationDefault();
+                av0.visit(null, new Integer(1));
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
+
+    /* Following code creates equivalent classfile, which is not allowed by javac
+       since AnnotationWithoutAnnotationAccessModifier is not marked with ACC_ANNOTATION:
+
+    @GoodAnnotation
+    @AnnotationWithoutAnnotationAccessModifier
+    public interface HolderX {
+    }
+
+    */
+
+    private static class HolderXDump implements Opcodes {
+        public static byte[] dump() throws Exception {
+            ClassWriter cw = new ClassWriter(0);
+
+            cw.visit(52, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE,
+                    "HolderX", null,
+                    "java/lang/Object", new String[0]);
+
+            {
+                AnnotationVisitor av0;
+                av0 = cw.visitAnnotation("LGoodAnnotation;", true);
+                av0.visitEnd();
+                av0 = cw.visitAnnotation("LAnnotationWithoutAnnotationAccessModifier;", true);
+                av0.visitEnd();
+            }
+            cw.visitEnd();
+
+            return cw.toByteArray();
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/annotation/GoodAnnotation.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Simple conforming runtime annotation.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface GoodAnnotation {}
--- a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -167,7 +167,7 @@
             exception = e;
         } finally {
             if (rmid != null)
-                rmid.destroy();
+                rmid.cleanup();
         }
         if (exception != null)
             TestLibrary.bomb("\nexception thrown in test: ", exception);
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -277,10 +277,14 @@
                     try {
                         Process client = new ProcessBuilder(clientProcessStr).
                                 inheritIO().start();
-                        client.waitFor();
-                        int exitValue = client.exitValue();
-                        if (0 != exitValue) {
-                            die("Error: error happened in client process, exitValue = " + exitValue);
+                        try {
+                            client.waitFor();
+                            int exitValue = client.exitValue();
+                            if (0 != exitValue) {
+                                die("Error: error happened in client process, exitValue = " + exitValue);
+                            }
+                        } finally {
+                            client.destroyForcibly();
                         }
                     } catch (IOException ex) {
                         die("Error: Unable start client process, ex=" + ex.getMessage());
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -75,6 +75,7 @@
         System.err.println("\nRegression test for bug 4308492\n");
 
         KeepAliveDuringCall obj = new KeepAliveDuringCall();
+        JavaVM jvm = null;
 
         try {
             UnicastRemoteObject.exportObject(obj);
@@ -88,9 +89,10 @@
             System.err.println("bound shutdown monitor in local registry");
 
             System.err.println("starting remote ShutdownImpl VM...");
-            (new JavaVM("ShutdownImpl",
+            jvm = new JavaVM("ShutdownImpl",
                         "-Drmi.registry.port=" +
-                        registryPort, "")).start();
+                        registryPort, "");
+            jvm.start();
 
             Shutdown s;
             synchronized (obj.lock) {
@@ -132,6 +134,9 @@
                     "TEST FAILED: unexpected exception", e);
             }
         } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
             try {
                 UnicastRemoteObject.unexportObject(obj, true);
             } catch (RemoteException e) {
--- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -82,6 +82,7 @@
                            String.valueOf(LEASE_VALUE));
 
         LeaseCheckInterval obj = new LeaseCheckInterval();
+        JavaVM jvm = null;
 
         try {
             UnicastRemoteObject.exportObject(obj);
@@ -96,8 +97,9 @@
 
             synchronized (obj.lock) {
                 System.err.println("starting remote client VM...");
-                (new JavaVM("SelfTerminator", "-Drmi.registry.port=" +
-                            registryPort, "")).start();
+                jvm = new JavaVM("SelfTerminator", "-Drmi.registry.port=" +
+                            registryPort, "");
+                jvm.start();
 
                 System.err.println("waiting for unreferenced() callback...");
                 obj.lock.wait(TIMEOUT);
@@ -120,6 +122,9 @@
                     "TEST FAILED: unexpected exception: " + e.toString());
             }
         } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
             /*
              * When all is said and done, try to unexport the remote object
              * so that the VM has a chance to exit.
--- a/jdk/test/java/rmi/testlibrary/JavaVM.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/testlibrary/JavaVM.java	Wed Jul 05 22:46:04 2017 +0200
@@ -224,7 +224,7 @@
 
     public void destroy() {
         if (vm != null) {
-            vm.destroy();
+            vm.destroyForcibly();
         }
         vm = null;
     }
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -110,6 +110,7 @@
                                     String propertyValue,
                                     String extraProp)
     {
+        JavaVM jvm = null;
         try {
             String propOption = "";
             String equal = "";
@@ -119,7 +120,7 @@
             }
 
             // create a client to tell checkFQDN what its rmi name is.
-            JavaVM jvm = new JavaVM("CheckFQDNClient",
+            jvm = new JavaVM("CheckFQDNClient",
                                     propOption + property +
                                     equal +
                                     propertyValue + extraProp +
@@ -140,6 +141,10 @@
 
         } catch (Exception e) {
             TestLibrary.bomb(e);
+        } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
         }
     }
 
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -108,8 +108,12 @@
                                         registryPort,
                                         "");
 
-                if (jvm.execute() != 0) {
-                    TestLibrary.bomb("Client process failed");
+                try {
+                    if (jvm.execute() != 0) {
+                        TestLibrary.bomb("Client process failed");
+                    }
+                } finally {
+                    jvm.destroy();
                 }
             }
             numLeft = getDGCLeaseTableSize();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Calendar/Bug8167273.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8167273
+ * @summary Test
+ * Era names retrieved from Calendar and DateFormatSymbols class
+ * should match for default providers preference
+ * as well as when  preference list is [COMPAT, CLDR],
+ * Empty era names are not retrieved from DateformatSymbols class.
+ * Equivalent locales specified for [zh-HK, no-NO, no] for
+ * CLDR Provider works correctly.
+ * Implict COMPAT Locale nb is reflected in available locales
+ * for all Providers for COMPAT.
+ * @modules java.base/sun.util.locale.provider
+ *          java.base/sun.util.spi
+ *          jdk.localedata
+ * @run main/othervm -Djava.locale.providers=COMPAT,CLDR Bug8167273 testEraName
+ * @run main/othervm  Bug8167273 testEraName
+ * @run main/othervm -Djava.locale.providers=CLDR Bug8167273 testCldr
+ * @run main/othervm  Bug8167273 testEmptyEraNames
+ * @run main/othervm  -Djava.locale.providers=COMPAT Bug8167273 testCompat
+ */
+import java.text.DateFormatSymbols;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import sun.util.locale.provider.LocaleProviderAdapter;
+import sun.util.locale.provider.LocaleProviderAdapter.Type;
+
+public class Bug8167273 {
+
+    public static void main(String[] args) throws Exception {
+        switch (args[0]) {
+            case "testEraName":
+                testEraName();
+                break;
+            case "testEmptyEraNames":
+                testEmptyEraNames();
+                break;
+            case "testCldr":
+                testCldrSupportedLocales();
+                break;
+            case "testCompat":
+                testCompatSupportedLocale();
+                break;
+            default:
+                throw new RuntimeException("no test was specified.");
+        }
+    }
+
+    /**
+     * tests that era names retrieved from Calendar.getDisplayNames map should
+     * match with that of Era names retrieved from DateFormatSymbols.getEras()
+     * method for all Gregorian Calendar locales .
+     */
+    public static void testEraName() {
+        Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
+        Set<Locale> JpThlocales = Set.of(
+                new Locale("th", "TH"),
+                new Locale("ja", "JP", "JP"), new Locale("th", "TH", "TH")
+        );
+        Set<Locale> allLocs = new HashSet<>(allLocales);
+        // Removing Japense and Thai Locales to check  Gregorian Calendar Locales
+        allLocs.removeAll(JpThlocales);
+        allLocs.forEach((locale) -> {
+            Calendar cal = Calendar.getInstance(locale);
+            Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, locale);
+            DateFormatSymbols symbols = new DateFormatSymbols(locale);
+            String[] eras = symbols.getEras();
+            for (String era : eras) {
+                if (!names.containsKey(era)) {
+                    reportMismatch(names.keySet(), eras, locale);
+                }
+            }
+        });
+    }
+
+    private static void reportMismatch(Set<String> CalendarEras, String[] dfsEras, Locale locale) {
+        System.out.println("For Locale  " + locale + "era names in calendar map are  " + CalendarEras);
+        for (String era : dfsEras) {
+            System.out.println("For Locale  " + locale + " era names in DateFormatSymbols era array are  " + era);
+        }
+        throw new RuntimeException(" Era name retrived from Calendar class do not match with"
+                + " retrieved from DateFormatSymbols  for Locale   " + locale);
+
+    }
+
+    /**
+     * tests that Eras names returned from DateFormatSymbols.getEras()
+     * and Calendar.getDisplayNames() should not be empty for any Locale.
+     */
+    private static void testEmptyEraNames() {
+        Set<Locale> allLocales = Set.of(Locale.getAvailableLocales());
+        allLocales.forEach((loc) -> {
+            DateFormatSymbols dfs = new DateFormatSymbols(loc);
+            Calendar cal = Calendar.getInstance(loc);
+            Map<String, Integer> names = cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, loc);
+            Set<String> CalendarEraNames = names.keySet();
+            String[] eras = dfs.getEras();
+            for (String era : eras) {
+                if (era.isEmpty()) {
+                    throw new RuntimeException("Empty era names retrieved for DateFomatSymbols.getEras"
+                            + " for locale " + loc);
+                }
+            }
+            CalendarEraNames.stream().filter((erakey) -> (erakey.isEmpty())).forEachOrdered((l) -> {
+                throw new RuntimeException("Empty era names retrieved for Calendar.getDisplayName"
+                        + " for locale " + loc);
+            });
+        });
+
+    }
+
+    /**
+     * tests that CLDR provider should return true for locale zh_HK, no-NO and
+     * no.
+     */
+    private static void testCldrSupportedLocales() {
+        Set<Locale> locales = Set.of(Locale.forLanguageTag("zh-HK"),
+                Locale.forLanguageTag("no-NO"),
+                Locale.forLanguageTag("no"));
+        LocaleProviderAdapter cldr = LocaleProviderAdapter.forType(Type.CLDR);
+        Set<Locale> availableLocs = Set.of(cldr.getAvailableLocales());
+        Set<String> langtags = new HashSet<>();
+        availableLocs.forEach((loc) -> {
+            langtags.add(loc.toLanguageTag());
+        });
+
+        locales.stream().filter((loc) -> (!cldr.isSupportedProviderLocale(loc, langtags))).forEachOrdered((loc) -> {
+            throw new RuntimeException("Locale " + loc + "  is not supported by CLDR Locale Provider");
+        });
+    }
+
+    /**
+     * Tests that locale nb should be supported by JRELocaleProvider .
+     */
+    private static void testCompatSupportedLocale() {
+        LocaleProviderAdapter jre = LocaleProviderAdapter.forJRE();
+        checkPresenceCompat("BreakIteratorProvider",
+                jre.getBreakIteratorProvider().getAvailableLocales());
+        checkPresenceCompat("CollatorProvider",
+                jre.getCollatorProvider().getAvailableLocales());
+        checkPresenceCompat("DateFormatProvider",
+                jre.getDateFormatProvider().getAvailableLocales());
+        checkPresenceCompat("DateFormatSymbolsProvider",
+                jre.getDateFormatSymbolsProvider().getAvailableLocales());
+        checkPresenceCompat("DecimalFormatSymbolsProvider",
+                jre.getDecimalFormatSymbolsProvider().getAvailableLocales());
+        checkPresenceCompat("NumberFormatProvider",
+                jre.getNumberFormatProvider().getAvailableLocales());
+        checkPresenceCompat("CurrencyNameProvider",
+                jre.getCurrencyNameProvider().getAvailableLocales());
+        checkPresenceCompat("LocaleNameProvider",
+                jre.getLocaleNameProvider().getAvailableLocales());
+        checkPresenceCompat("TimeZoneNameProvider",
+                jre.getTimeZoneNameProvider().getAvailableLocales());
+        checkPresenceCompat("CalendarDataProvider",
+                jre.getCalendarDataProvider().getAvailableLocales());
+        checkPresenceCompat("CalendarNameProvider",
+                jre.getCalendarNameProvider().getAvailableLocales());
+        checkPresenceCompat("CalendarProvider",
+                jre.getCalendarProvider().getAvailableLocales());
+    }
+
+    private static void checkPresenceCompat(String testName, Locale[] got) {
+        List<Locale> gotLocalesList = Arrays.asList(got);
+        Locale nb = Locale.forLanguageTag("nb");
+        if (!gotLocalesList.contains(nb)) {
+            throw new RuntimeException("Locale nb not supported by JREProvider for "
+                    + testName + " test ");
+        }
+    }
+}
--- a/jdk/test/java/util/Calendar/SupplementalJapaneseEraTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/util/Calendar/SupplementalJapaneseEraTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -22,8 +22,10 @@
  */
 
 import java.text.SimpleDateFormat;
+import java.time.chrono.JapaneseChronology;
 import java.time.chrono.JapaneseDate;
 import java.time.chrono.JapaneseEra;
+import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.TextStyle;
 import java.util.Calendar;
 import java.util.Date;
@@ -122,7 +124,7 @@
         got = sdf.format(firstDayOfEra);
         expected = NEW_ERA_ABBR+" 1-02-11";
         if (!expected.equals(got)) {
-            System.err.printf("GGGG y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected);
+            System.err.printf("G y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected);
             errors++;
         }
 
@@ -163,6 +165,20 @@
             System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR);
             errors++;
         }
+
+        // test long/abbreviated names with java.time.format
+        got = new DateTimeFormatterBuilder()
+            .appendPattern("GGGG")
+            .appendLiteral(" ")
+            .appendPattern("G")
+            .toFormatter(Locale.US)
+            .withChronology(JapaneseChronology.INSTANCE)
+            .format(jdate);
+        expected = NEW_ERA_NAME + " " + NEW_ERA_ABBR;
+        if (!expected.equals(got)) {
+            System.err.printf("java.time formatter long/abbr names: got=\"%s\", expected=\"%s\"%n", got, expected);
+            errors++;
+        }
     }
 
     private static void testValidation(String eraName) {
--- a/jdk/test/java/util/Calendar/SupplementalJapaneseEraTest.sh	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/java/util/Calendar/SupplementalJapaneseEraTest.sh	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 8048123 8054214
+# @bug 8048123 8054214 8173423
 # @summary Test for jdk.calendar.japanese.supplemental.era support
 # @build SupplementalJapaneseEraTest
 # @run shell SupplementalJapaneseEraTest.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 6959653 8172365
+ * @summary Test ResourceBundle.Control provided using SPI.
+ * @library test
+ * @build test/*
+ * @build com.foo.UserControlProvider
+ * @run main/othervm UserDefaultControlTest false
+ * @run main/othervm UserDefaultControlTest true
+ */
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.net.*;
+import java.nio.file.*;
+import java.util.*;
+
+import jdk.test.*;
+
+public class UserDefaultControlTest {
+    public static void main(String... args) throws Exception {
+        boolean smExists = Boolean.valueOf(args[0]);
+        initServices();
+        if (smExists) {
+            System.out.println("test with security manager present:");
+            System.setSecurityManager(new SecurityManager());
+        } else {
+            System.out.println("test without security manager present:");
+        }
+
+        test(smExists);
+    }
+
+    private static void initServices() throws IOException {
+        Path testClasses = Paths.get(System.getProperty("test.classes"));
+        Path services = testClasses.resolve(Paths.get("META-INF", "services"));
+        Files.createDirectories(services);
+        Files.write(services.resolve("java.util.spi.ResourceBundleControlProvider"),
+                List.of("com.foo.UserControlProvider"));
+        Path comfoo = testClasses.resolve(Paths.get("com", "foo"));
+        Path testSrcComFoo =
+            Paths.get(System.getProperty("test.src")).resolve(Paths.get("com", "foo"));
+        Files.copy(testSrcComFoo.resolve("XmlRB.xml"), comfoo.resolve("XmlRB.xml"),
+            StandardCopyOption.REPLACE_EXISTING);
+        Files.copy(testSrcComFoo.resolve("XmlRB_ja.xml"), comfoo.resolve("XmlRB_ja.xml"),
+            StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    private static void test(boolean smExists) {
+        ResourceBundle rb;
+
+        try {
+            rb = ResourceBundle.getBundle("com.foo.XmlRB", Locale.ROOT);
+            if (smExists) {
+                throw new RuntimeException("getBundle did not throw " +
+                    "MissingResourceException with a security manager");
+            }
+        } catch (MissingResourceException e) {
+            if (smExists) {
+                // failed successfully
+                return;
+            } else {
+                throw e;
+            }
+        }
+
+        String type = rb.getString("type");
+        if (!type.equals("XML")) {
+            throw new RuntimeException("Root Locale: type: got " + type
+                                       + ", expected XML (ASCII)");
+        }
+
+        rb = ResourceBundle.getBundle("com.foo.XmlRB", Locale.JAPAN);
+        type = rb.getString("type");
+        // Expect fullwidth "XML"
+        if (!type.equals("\uff38\uff2d\uff2c")) {
+            throw new RuntimeException("Locale.JAPAN: type: got " + type
+                                       + ", expected \uff38\uff2d\uff2c (fullwidth XML)");
+        }
+
+        try {
+            rb = ResourceBundle.getBundle("com.bar.XmlRB", Locale.JAPAN);
+            throw new RuntimeException("com.bar.XmlRB test failed.");
+        } catch (MissingResourceException e) {
+            // OK
+        }
+
+        // tests with named module. Only resource bundles on the classpath
+        // should be available, unless an unnamed module is explicitly
+        // specified.
+        rb = ResourceBundleDelegate.getBundle("simple", Locale.ROOT);
+        try {
+            rb = ResourceBundleDelegate.getBundle("com.foo.XmlRB", Locale.ROOT);
+            throw new RuntimeException("getBundle in a named module incorrectly loaded " +
+                                    "a resouce bundle through RBControlProvider");
+        } catch (MissingResourceException e) {
+            // OK
+        }
+
+        Module unnamedModule = UserDefaultControlTest.class
+                                .getClassLoader()
+                                .getUnnamedModule();
+        rb = ResourceBundleDelegate.getBundle("com.foo.XmlRB", Locale.JAPAN, unnamedModule);
+        type = rb.getString("type");
+        // Expect fullwidth "XML"
+        if (!type.equals("\uff38\uff2d\uff2c")) {
+            throw new RuntimeException("getBundle called from named module for unnamed module."
+                                       + " Locale.JAPAN: type: got " + type
+                                       + ", expected \uff38\uff2d\uff2c (fullwidth XML)");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/com/foo/UserControlProvider.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.foo;
+
+import java.util.ResourceBundle;
+import java.util.spi.ResourceBundleControlProvider;
+
+public class UserControlProvider implements ResourceBundleControlProvider {
+    static final ResourceBundle.Control XMLCONTROL = new UserXMLControl();
+
+    public ResourceBundle.Control getControl(String baseName) {
+        System.out.println(getClass().getName()+".getControl called for " + baseName);
+
+        // Throws a NPE if baseName is null.
+        if (baseName.startsWith("com.foo.Xml")) {
+            System.out.println("\treturns " + XMLCONTROL);
+            return XMLCONTROL;
+        }
+        System.out.println("\treturns null");
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/com/foo/UserXMLControl.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.foo;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class UserXMLControl extends ResourceBundle.Control {
+    @Override
+    public List<String> getFormats(String baseName) {
+        if (baseName == null) {
+            throw new NullPointerException();
+        }
+        return Arrays.asList("xml");
+    }
+
+    @Override
+    public ResourceBundle newBundle(String baseName, Locale locale,
+                                    String format,
+                                    ClassLoader loader,
+                                    boolean reload)
+        throws IllegalAccessException,
+               InstantiationException, IOException {
+        if (baseName == null || locale == null
+            || format == null || loader == null) {
+            throw new NullPointerException();
+        }
+        ResourceBundle bundle = null;
+        if (format.equals("xml")) {
+            String bundleName = toBundleName(baseName, locale);
+            String resourceName = toResourceName(bundleName, format);
+            URL url = loader.getResource(resourceName);
+            if (url != null) {
+                URLConnection connection = url.openConnection();
+                if (connection != null) {
+                    if (reload) {
+                        // disable caches if reloading
+                        connection.setUseCaches(false);
+                    }
+                    try (InputStream stream = connection.getInputStream()) {
+                        if (stream != null) {
+                            BufferedInputStream bis = new BufferedInputStream(stream);
+                            bundle = new XMLResourceBundle(bis);
+                        }
+                    }
+                }
+            }
+        }
+        return bundle;
+    }
+
+    private static class XMLResourceBundle extends ResourceBundle {
+        private Properties props;
+
+        XMLResourceBundle(InputStream stream) throws IOException {
+            props = new Properties();
+            props.loadFromXML(stream);
+        }
+
+        protected Object handleGetObject(String key) {
+            if (key == null) {
+                throw new NullPointerException();
+            }
+            return props.get(key);
+        }
+
+        public Enumeration<String> getKeys() {
+            // Not implemented
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!---->
+
+<!-- DTD for properties -->
+<!DOCTYPE properties [
+<!ELEMENT properties ( comment?, entry* ) >
+<!ATTLIST properties version CDATA #FIXED "1.0">
+<!ELEMENT comment (#PCDATA) >
+<!ELEMENT entry (#PCDATA) >
+<!ATTLIST entry key CDATA #REQUIRED>
+]>
+
+<properties>
+    <comment>Test data for UserDefaultControlTest.java</comment>
+    <entry key="type">XML</entry>
+</properties>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!---->
+
+<!-- DTD for properties -->
+<!DOCTYPE properties [
+<!ELEMENT properties ( comment?, entry* ) >
+<!ATTLIST properties version CDATA #FIXED "1.0">
+<!ELEMENT comment (#PCDATA) >
+<!ELEMENT entry (#PCDATA) >
+<!ATTLIST entry key CDATA #REQUIRED>
+]>
+
+<properties>
+    <comment>Test data for UserDefaultControlTest.java</comment>
+    <entry key="type">XML</entry>
+</properties>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/simple.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+key = value
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/test/jdk/test/ResourceBundleDelegate.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test;
+
+import java.lang.reflect.Module;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class ResourceBundleDelegate {
+    public static ResourceBundle getBundle(String baseName, Locale locale) {
+        return ResourceBundle.getBundle(baseName, locale);
+    }
+
+    public static ResourceBundle getBundle(String baseName, Locale locale, Module module) {
+        return ResourceBundle.getBundle(baseName, locale, module);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/spi/ResourceBundleControlProvider/test/module-info.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module test {
+    exports jdk.test;
+}
--- a/jdk/test/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/net/ssl/FixingJavadocs/SSLSessionNulls.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -27,6 +27,7 @@
  * @summary Need to revisit the javadocs for JSSE, especially the
  *      promoted classes.
  * @library /javax/net/ssl/templates
+ * @modules jdk.crypto.ec
  * @run main/othervm SSLSessionNulls
  *
  *     SunJSSE does not support dynamic system properties, no way to re-use
--- a/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/net/ssl/SSLSession/SessionTimeOutTests.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -32,11 +32,14 @@
  */
 
 import java.io.*;
-import java.net.*;
+import java.net.InetSocketAddress;
+import java.net.SocketTimeoutException;
+
 import javax.net.ssl.*;
 import java.util.*;
 import java.security.*;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Session reuse time-out tests cover the cases below:
@@ -44,9 +47,9 @@
  * its lifetime exceeds x.
  * 2. Effect of changing the timeout limit.
  * The test suite does not cover the default timeout(24 hours) usage. This
- * case has been tested independetly.
+ * case has been tested independently.
  *
- * Invairant for passing this test is, at any given time,
+ * Invariant for passing this test is, at any given time,
  * lifetime of a session < current_session_timeout, such that
  * current_session_timeout > 0, for all sessions cached by the session
  * context.
@@ -80,7 +83,7 @@
     /*
      * Is the server ready to serve?
      */
-    AtomicInteger serverReady = new AtomicInteger(PORTS);
+    private final CountDownLatch serverCondition = new CountDownLatch(PORTS);
 
     /*
      * Turn on SSL debugging?
@@ -98,9 +101,6 @@
 
     /*
      * Define the server side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to zero
-     * to avoid infinite hangs.
      */
 
     /*
@@ -108,31 +108,44 @@
      */
     static int MAX_ACTIVE_CONNECTIONS = 3;
 
-    void doServerSide(int serverPort, int serverConns) throws Exception {
+    /*
+     * Divide the max connections among the available server ports.
+     * The use of more than one server port ensures creation of more
+     * than one session.
+     */
+    private static final int serverConns = MAX_ACTIVE_CONNECTIONS / PORTS;
+    private static final int remainingConns = MAX_ACTIVE_CONNECTIONS % PORTS;
 
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        int slot = createdPorts.getAndIncrement();
+    private static final int TIMEOUT = 30000; // in millisecond
+
+    void doServerSide(int slot, int serverConns) throws Exception {
+
+        SSLServerSocket sslServerSocket
+                = (SSLServerSocket) sslssf.createServerSocket(0);
+        sslServerSocket.setSoTimeout(TIMEOUT);
         serverPorts[slot] = sslServerSocket.getLocalPort();
 
         /*
-         * Signal Client, we're ready for his connect.
+         * Signal Client, one server is ready for its connect.
          */
-        serverReady.getAndDecrement();
-        int read = 0;
-        int nConnections = 0;
-        SSLSession sessions [] = new SSLSession [serverConns];
+        serverCondition.countDown();
 
-        while (nConnections < serverConns) {
-            SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        for (int nConnections = 0; nConnections < serverConns; nConnections++) {
+            SSLSocket sslSocket = null;
+            try {
+                sslSocket = (SSLSocket) sslServerSocket.accept();
+            }  catch (SocketTimeoutException ste) {
+                System.out.println(
+                        "No incoming client connection. Ignore in server side.");
+                continue;
+            }
             InputStream sslIS = sslSocket.getInputStream();
             OutputStream sslOS = sslSocket.getOutputStream();
-            read = sslIS.read();
-            sessions[nConnections] = sslSocket.getSession();
+            sslIS.read();
+            sslSocket.getSession();
             sslOS.write(85);
             sslOS.flush();
             sslSocket.close();
-            nConnections++;
         }
     }
 
@@ -143,35 +156,49 @@
      * to avoid infinite hangs.
      */
     void doClientSide() throws Exception {
-
         /*
          * Wait for server to get started.
          */
-        while (serverReady.get() > 0) {
-            Thread.sleep(50);
+        if (!serverCondition.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
+            System.out.println(
+                    "The server side is not ready yet. Ignore in client side.");
+            return;
         }
 
-        int nConnections = 0;
-        SSLSocket sslSockets[] = new SSLSocket [MAX_ACTIVE_CONNECTIONS];
-        Vector sessions = new Vector();
+        SSLSocket sslSockets[] = new SSLSocket[MAX_ACTIVE_CONNECTIONS];
+        Vector<SSLSession> sessions = new Vector<>();
         SSLSessionContext sessCtx = sslctx.getClientSessionContext();
 
         sessCtx.setSessionTimeout(10); // in secs
         int timeout = sessCtx.getSessionTimeout();
-        while (nConnections < MAX_ACTIVE_CONNECTIONS) {
+        for (int nConnections = 0; nConnections < MAX_ACTIVE_CONNECTIONS;
+                nConnections++) {
             // divide the connections among the available server ports
-            sslSockets[nConnections] = (SSLSocket) sslsf.
-                        createSocket("localhost",
-                        serverPorts [nConnections % (serverPorts.length)]);
+            try {
+                SSLSocket sslSocket = (SSLSocket) sslsf.createSocket();
+                sslSocket.connect(new InetSocketAddress("localhost",
+                        serverPorts[nConnections % serverPorts.length]),
+                        TIMEOUT);
+                sslSockets[nConnections] = sslSocket;
+            } catch (IOException ioe) {
+                // The server side may be impacted by naughty test cases or
+                // third party routines, and cannot accept connections.
+                //
+                // Just ignore the test if the connection cannot be
+                // established.
+                System.out.println(
+                        "Cannot make a connection in time. Ignore in client side.");
+                continue;
+            }
+
             InputStream sslIS = sslSockets[nConnections].getInputStream();
             OutputStream sslOS = sslSockets[nConnections].getOutputStream();
             sslOS.write(237);
             sslOS.flush();
-            int read = sslIS.read();
+            sslIS.read();
             SSLSession sess = sslSockets[nConnections].getSession();
             if (!sessions.contains(sess))
                 sessions.add(sess);
-            nConnections++;
         }
         System.out.println();
         System.out.println("Current timeout is set to: " + timeout);
@@ -217,7 +244,7 @@
         }
 
         // check the ids returned by the enumerator
-        Enumeration e = sessCtx.getIds();
+        Enumeration<byte[]> e = sessCtx.getIds();
         System.out.println("----------------------------------------"
                                 + "-----------------------");
         System.out.println("Testing SSLSessionContext.getId()......");
@@ -262,7 +289,7 @@
 
             System.out.println("            " + isTimedout);
         }
-        for (int i = 0; i < nConnections; i++) {
+        for (int i = 0; i < sslSockets.length; i++) {
             sslSockets[i].close();
         }
         System.out.println("----------------------------------------"
@@ -290,7 +317,6 @@
      */
 
     int serverPorts[] = new int[PORTS];
-    AtomicInteger createdPorts = new AtomicInteger(0);
     static SSLServerSocketFactory sslssf;
     static SSLSocketFactory sslsf;
     static SSLContext sslctx;
@@ -311,6 +337,9 @@
         System.setProperty("javax.net.ssl.trustStore", trustFilename);
         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
         sslctx = SSLContext.getInstance("TLS");
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         KeyStore ks = KeyStore.getInstance("JKS");
@@ -319,8 +348,6 @@
         sslctx.init(kmf.getKeyManagers(), null, null);
         sslssf = (SSLServerSocketFactory) sslctx.getServerSocketFactory();
         sslsf = (SSLSocketFactory) sslctx.getSocketFactory();
-        if (debug)
-            System.setProperty("javax.net.debug", "all");
 
         /*
          * Start the tests.
@@ -342,33 +369,25 @@
          * create the SSLServerSocket and SSLSocket factories
          */
 
-        /*
-         * Divide the max connections among the available server ports.
-         * The use of more than one server port ensures creation of more
-         * than one session.
-         */
-        int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length);
-        int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length);
-
         Exception startException = null;
         try {
             if (separateServerThread) {
                 for (int i = 0; i < serverPorts.length; i++) {
                     // distribute remaining connections among the
-                    // vailable ports
+                    // available ports
                     if (i < remainingConns)
-                        startServer(serverPorts[i], (serverConns + 1), true);
+                        startServer(i, (serverConns + 1), true);
                     else
-                        startServer(serverPorts[i], serverConns, true);
+                        startServer(i, serverConns, true);
                 }
                 startClient(false);
             } else {
                 startClient(true);
-                for (int i = 0; i < serverPorts.length; i++) {
+                for (int i = 0; i < PORTS; i++) {
                     if (i < remainingConns)
-                        startServer(serverPorts[i], (serverConns + 1), false);
+                        startServer(i, (serverConns + 1), false);
                     else
-                        startServer(serverPorts[i], serverConns, false);
+                        startServer(i, serverConns, false);
                 }
             }
         } catch (Exception e) {
@@ -434,13 +453,13 @@
         // Fall-through: no exception to throw!
     }
 
-    void startServer(final int port, final int nConns,
-                        boolean newThread) throws Exception {
+    void startServer(final int slot, final int nConns, boolean newThread)
+            throws Exception {
         if (newThread) {
             serverThread = new Thread() {
                 public void run() {
                     try {
-                        doServerSide(port, nConns);
+                        doServerSide(slot, nConns);
                     } catch (Exception e) {
                         /*
                          * Our server thread just died.
@@ -449,7 +468,6 @@
                          */
                         System.err.println("Server died...");
                         e.printStackTrace();
-                        serverReady.set(0);
                         serverException = e;
                     }
                 }
@@ -457,11 +475,9 @@
             serverThread.start();
         } else {
             try {
-                doServerSide(port, nConns);
+                doServerSide(slot, nConns);
             } catch (Exception e) {
                 serverException = e;
-            } finally {
-                serverReady.set(0);
             }
         }
     }
--- a/jdk/test/javax/net/ssl/interop/ClientHelloChromeInterOp.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/net/ssl/interop/ClientHelloChromeInterOp.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -30,7 +30,8 @@
  * @test
  * @bug 8169362
  * @summary Interop automated testing with Chrome
- * @modules java.base/sun.security.util
+ * @modules jdk.crypto.ec
+ *          java.base/sun.security.util
  * @run main/othervm ClientHelloChromeInterOp
  */
 
--- a/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -29,11 +29,22 @@
 /*
  * @test
  * @bug 8161106 8170329
+ * @modules jdk.crypto.ec
  * @summary Improve SSLSocket test template
  * @run main/othervm SSLSocketTemplate
  */
-import java.io.*;
-import javax.net.ssl.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManagerFactory;
 import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.security.KeyStore;
@@ -41,7 +52,7 @@
 import java.security.KeyFactory;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateFactory;
-import java.security.spec.*;
+import java.security.spec.PKCS8EncodedKeySpec;
 import java.util.Base64;
 
 import java.util.concurrent.CountDownLatch;
--- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -66,8 +66,11 @@
     private static Process rmiServerProcess;
 
     public static void main(String[] args) throws Exception {
-        startTestComponents();
-        stopTestComponents();
+        try {
+            startTestComponents();
+        } finally {
+            stopTestComponents();
+        }
         System.err.println("Test completed OK ");
     }
 
@@ -142,11 +145,13 @@
     }
 
     static void stopOrbd() throws Exception {
-        System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess ");
-        orbdProcess.destroyForcibly();
-        orbdProcess.waitFor();
-        System.out.println("orbd exitCode:"
-            + orbdProcess.exitValue());
+        if (orbdProcess != null) {
+            System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess ");
+            orbdProcess.destroyForcibly();
+            orbdProcess.waitFor();
+            System.out.println("orbd exitCode:"
+                + orbdProcess.exitValue());
+        }
     }
 
     static void executeRmiIiopClient() throws Exception {
--- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -61,8 +61,11 @@
     private static Process rmiServerProcess;
 
     public static void main(String[] args) throws Exception {
-        startTestComponents();
-        stopTestComponents();
+        try {
+            startTestComponents();
+        } finally {
+            stopTestComponents();
+        }
         System.err.println("Test completed OK ");
     }
 
@@ -124,17 +127,21 @@
     }
 
     static void stopRmiIiopServer() throws Exception {
-        rmiServerProcess.destroyForcibly();
-        rmiServerProcess.waitFor();
-        System.out.println("serverProcess exitCode:"
-            + rmiServerProcess.exitValue());
+        if (rmiServerProcess != null) {
+            rmiServerProcess.destroyForcibly();
+            rmiServerProcess.waitFor();
+            System.out.println("serverProcess exitCode:"
+                + rmiServerProcess.exitValue());
+        }
     }
 
     static void stopOrbd() throws Exception {
-        orbdProcess.destroyForcibly();
-        orbdProcess.waitFor();
-        System.out.println("orbd exitCode:"
-            + orbdProcess.exitValue());
+        if (orbdProcess != null) {
+            orbdProcess.destroyForcibly();
+            orbdProcess.waitFor();
+            System.out.println("orbd exitCode:"
+                + orbdProcess.exitValue());
+        }
     }
 
     static void executeRmiIiopClient() throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/UIDefaults/8149879/InternalResourceBundle.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.EventQueue;
+
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.nimbus.NimbusLookAndFeel;
+
+/**
+ * @test
+ * @bug 8149879
+ * @summary The users should not register internal resource bundles.
+ */
+public class InternalResourceBundle {
+
+    public static void main(final String[] args) throws Exception {
+        EventQueue.invokeAndWait(() -> {
+            // Indirectly register resource bundle from Nimbus, it will be used
+            // by default
+            try {
+                UIManager.setLookAndFeel(new NimbusLookAndFeel());
+            } catch (final UnsupportedLookAndFeelException e) {
+                throw new RuntimeException(e);
+            }
+            UIDefaults defaults = UIManager.getDefaults();
+            // Try to register resource bundle from Metal, which is
+            // not enabled by default. This request should be skipped.
+            defaults.addResourceBundle("com.sun.swing.internal.plaf.metal.resources.metal");
+
+            Object value = getValue(defaults);
+            if (value != null) {
+                throw new RuntimeException("value is not null = " + value);
+            }
+
+            // Indirectly register resource bundle from Metal
+            try {
+                UIManager.setLookAndFeel(new MetalLookAndFeel());
+            } catch (final UnsupportedLookAndFeelException e) {
+                throw new RuntimeException(e);
+            }
+            value = getValue(defaults);
+            if (value == null) {
+                throw new RuntimeException("value is null");
+            }
+        });
+    }
+
+    private static Object getValue(UIDefaults defaults) {
+        return defaults.get("MetalTitlePane.restore.titleAndMnemonic");
+    }
+}
--- a/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,11 @@
         ByteArrayOutputStream err = new ByteArrayOutputStream();
         JavaVM vm = new JavaVM(StartRegistry.class.getName(),
                                "-Dsun.rmi.transport.logLevel=v", "", out, err);
-        vm.execute();
+        try {
+            vm.execute();
+        } finally {
+            vm.destroy();
+        }
 
         String errString = err.toString();
 
--- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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
@@ -72,7 +72,11 @@
                 + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
                 + " -Djava.util.logging.config.file="
                 + loggingPropertiesFile, "", out, err);
-        vm.execute();
+        try {
+            vm.execute();
+        } finally {
+            vm.destroy();
+        }
 
         /*
          * Verify that the subprocess had no System.err output.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/Resources/customSysClassLoader/BootMessages.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8168075
+ * @summary Ensure that security messages can be formatted during system class
+ *   loader initialization.
+ * @build CustomClassLoader
+ * @run main/othervm/java.security.policy=error.policy -Djava.security.manager -Djava.system.class.loader=CustomClassLoader BootMessages
+ */
+
+public class BootMessages {
+
+    public static void main(String[] args) throws Exception {
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/Resources/customSysClassLoader/CustomClassLoader.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,34 @@
+
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * A class loader that can be used in tests that require a custom class
+ * loader. Its behavior is identical to ClassLoader.
+ */
+
+public class CustomClassLoader extends ClassLoader {
+    public CustomClassLoader(ClassLoader parent) {
+        super(parent);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/Resources/customSysClassLoader/MessageFormatting.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.*;
+import sun.security.util.Resources;
+import sun.security.util.LocalizedMessage;
+import java.text.MessageFormat;
+
+/*
+ * @test
+ * @bug 8168075
+ * @summary Ensure that security message formatting code is capable of
+ *     displaying all messages.
+ * @modules java.base/sun.security.util
+ */
+
+public class MessageFormatting {
+
+    private static final Object[] MSG_ARGS = new Integer[]{0, 1, 2};
+
+    public static void main(String[] args) throws Exception {
+
+        Resources resources = new Resources();
+        Enumeration<String> keys = resources.getKeys();
+        while (keys.hasMoreElements()) {
+            String curKey = keys.nextElement();
+            String formattedString = LocalizedMessage.getMessageUnbooted(curKey, MSG_ARGS);
+            String msg = resources.getString(curKey);
+            String expectedString = formatIfNecessary(msg, MSG_ARGS);
+            if (!formattedString.equals(expectedString)) {
+                System.err.println("Expected string:");
+                System.err.println(expectedString);
+                System.err.println("Actual string:");
+                System.err.println(formattedString);
+                throw new Exception("Incorrect message string");
+            }
+        }
+    }
+
+    private static String formatIfNecessary(String str, Object[] args) {
+        // message formatting code only formats messages with arguments
+        if (str.indexOf('{') < 0) {
+            return str;
+        }
+        MessageFormat format = new MessageFormat(str);
+        return format.format(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/Resources/customSysClassLoader/error.policy	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,5 @@
+grant { 
+    permission java.lang.RuntimePermission "createClassLoader";
+    permission java.lang.RuntimePermission "";
+};
+
--- a/jdk/test/sun/util/locale/provider/Bug8038436.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/sun/util/locale/provider/Bug8038436.java	Wed Jul 05 22:46:04 2017 +0200
@@ -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 @@
 
 /*
  * @test
- * @bug 8038436 8158504 8065555 8167143
+ * @bug 8038436 8158504 8065555 8167143 8167273
  * @summary Test for changes in 8038436
  * @modules java.base/sun.util.locale.provider
  *          java.base/sun.util.spi
@@ -120,7 +120,7 @@
         "fi, fi-FI, fr, fr-BE, fr-CA, fr-CH, fr-FR, ga, ga-IE, he, he-IL, " +
         "hi-IN, hr, hr-HR, hu, hu-HU, id, id-ID, is, is-IS, it, it-CH, it-IT, " +
         "ja, ja-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, mk, mk-MK, ms, ms-MY, mt, " +
-        "mt-MT, nb-NO, nl, nl-BE, nl-NL, nn-NO, no, no-NO, no-NO, pl, pl-PL, pt, pt-BR, " +
+        "mt-MT, nb, nb-NO, nl, nl-BE, nl-NL, nn-NO, no, no-NO, no-NO, pl, pl-PL, pt, pt-BR, " +
         "pt-PT, ro, ro-RO, ru, ru-RU, sk, sk-SK, sl, sl-SI, sq, sq-AL, sr, " +
         "sr-BA, sr-CS, sr-Latn, sr-Latn-ME, sr-ME, sr-RS, sv, sv-SE, th, th-TH, " +
         "tr, tr-TR, uk, uk-UA, und, vi, vi-VN, zh, zh-CN, zh-HK, zh-Hans-CN, " +
@@ -130,7 +130,7 @@
     static final String[] decimalfspLocs = bipLocs;
     static final String[] calnpLocs = bipLocs;
     static final String[] cpLocs = ("ar, be, bg, ca, cs, da, el, es, et, fi, " +
-        "fr, he, hi, hr, hu, is, ja, ko, lt, lv, mk, nb-NO, nn-NO, no, pl, ro, ru, sk, sl, " +
+        "fr, he, hi, hr, hu, is, ja, ko, lt, lv, mk, nb, nb-NO, nn-NO, no, pl, ro, ru, sk, sl, " +
         "sq, sr, sr-Latn, sv, th, tr, uk, und, vi, zh, zh-HK, zh-Hant-HK, " +
         "zh-Hant-TW, zh-TW, ").split(",\\s*");
     static final String[] nfpLocs = ("ar, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IQ, " +
@@ -144,7 +144,7 @@
         "fr-LU, ga, ga-IE, he, he-IL, hi, hi-IN, hr, hr-HR, hu, hu-HU, id, " +
         "id-ID, is, is-IS, it, it-CH, it-IT, ja, ja-JP, " +
         "ja-JP-u-ca-japanese-x-lvariant-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, " +
-        "mk, mk-MK, ms, ms-MY, mt, mt-MT, nb-NO, nl, nl-BE, nl-NL, nn-NO, " +
+        "mk, mk-MK, ms, ms-MY, mt, mt-MT, nb, nb-NO, nl, nl-BE, nl-NL, nn-NO, " +
         "nn-NO, no, no-NO, pl, pl-PL, pt, pt-BR, pt-PT, ro, ro-RO, ru, ru-RU, " +
         "sk, sk-SK, sl, sl-SI, sq, sq-AL, sr, sr-BA, sr-CS, sr-Latn, " +
         "sr-Latn-BA, sr-Latn-ME, sr-Latn-RS, sr-ME, sr-RS, sv, sv-SE, th, " +
@@ -160,22 +160,22 @@
         "es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et-EE, fi-FI, " +
         "fr, fr-BE, fr-CA, fr-CH, fr-FR, fr-LU, ga-IE, he-IL, hi-IN, hr-HR, " +
         "hu-HU, id-ID, is-IS, it, it-CH, it-IT, ja, ja-JP, ko, ko-KR, lt-LT, " +
-        "lv-LV, mk-MK, ms-MY, mt-MT, nb-NO, nl-BE, nl-NL, nn-NO, no-NO, pl-PL, pt, pt-BR, " +
+        "lv-LV, mk-MK, ms-MY, mt-MT, nb,  nb-NO, nl-BE, nl-NL, nn-NO, no-NO, pl-PL, pt, pt-BR, " +
         "pt-PT, ro-RO, ru-RU, sk-SK, sl-SI, sq-AL, sr-BA, sr-CS, sr-Latn-BA, " +
         "sr-Latn-ME, sr-Latn-RS, sr-ME, sr-RS, sv, sv-SE, th-TH, tr-TR, uk-UA, " +
         "und, vi-VN, zh-CN, zh-HK, zh-Hans-CN, zh-Hans-SG, zh-Hant-HK, " +
         "zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
     static final String[] lnpLocs = ("ar, be, bg, ca, cs, da, de, el, el-CY, " +
         "en, en-MT, en-PH, en-SG, es, es-US, et, fi, fr, ga, he, hi, hr, hu, " +
-        "id, is, it, ja, ko, lt, lv, mk, ms, mt, nb-NO, nl, nn-NO, no, no-NO, pl, pt, pt-BR, " +
+        "id, is, it, ja, ko, lt, lv, mk, ms, mt, nb, nb-NO, nl, nn-NO, no, no-NO, pl, pt, pt-BR, " +
         "pt-PT, ro, ru, sk, sl, sq, sr, sr-Latn, sv, th, tr, uk, und, vi, zh, " +
         "zh-HK, zh-Hans-SG, zh-Hant-HK, zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
     static final String[] tznpLocs = ("de, en, en-CA, en-GB, en-IE, es, fr, hi, " +
-        "it, ja, ko, nb-NO, nn-NO, pt-BR, sv, und, zh-CN, zh-HK, zh-Hans-CN, zh-Hant-HK, " +
+        "it, ja, ko, nb,  nb-NO, nn-NO, pt-BR, sv, und, zh-CN, zh-HK, zh-Hans-CN, zh-Hant-HK, " +
         "zh-Hant-TW, zh-TW, ").split(",\\s*");
     static final String[] caldpLocs = ("ar, be, bg, ca, cs, da, de, el, el-CY, " +
         "en, en-GB, en-IE, en-MT, es, es-ES, es-US, et, fi, fr, fr-CA, he, hi, " +
-        "hr, hu, id-ID, is, it, ja, ko, lt, lv, mk, ms-MY, mt, mt-MT, nb-NO, nl, nn-NO, no, " +
+        "hr, hu, id-ID, is, it, ja, ko, lt, lv, mk, ms-MY, mt, mt-MT, nb, nb-NO, nl, nn-NO, no, " +
         "pl, pt, pt-BR, pt-PT, ro, ru, sk, sl, sq, sr, sr-Latn-BA, sr-Latn-ME, " +
         "sr-Latn-RS, sv, th, tr, uk, und, vi, zh, ").split(",\\s*");
     static final String[] calpLocs = caldpLocs;
--- a/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -31,27 +31,47 @@
  * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
  * @build jdk.testlibrary.FileUtils
  * @build MRTestBase
- * @run testng ApiValidatorTest
+ * @run testng/timeout=1200 ApiValidatorTest
  */
 
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.testlibrary.FileUtils;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class ApiValidatorTest extends MRTestBase {
 
+    static final Pattern MODULE_PATTERN = Pattern.compile("module (\\w+)");
+    static final Pattern CLASS_PATTERN = Pattern.compile("package (\\w+).*public class (\\w+)");
+
+    private Path root;
+    private Path classes;
+
+    @BeforeMethod
+    void testInit(Method method) {
+        root = Paths.get(method.getName());
+        classes = root.resolve("classes");
+    }
+
+    @AfterMethod
+    void testCleanup() throws IOException {
+        FileUtils.deleteFileTreeWithRetry(root);
+    }
+
+
     @Test(dataProvider = "signatureChange")
     public void changeMethodSignature(String sigBase, String sigV10,
-                                      boolean isAcceptable,
-                                      Method method) throws Throwable {
-        Path root = Paths.get(method.getName());
-        Path classes = root.resolve("classes");
+                                      boolean isAcceptable) throws Throwable {
 
         String METHOD_SIG = "#SIG";
         String classTemplate =
@@ -76,8 +96,6 @@
             result.shouldNotHaveExitValue(SUCCESS)
                     .shouldContain("contains a class with different api from earlier version");
         }
-
-        FileUtils.deleteFileTreeWithRetry(root);
     }
 
     @DataProvider
@@ -100,11 +118,7 @@
     }
 
     @Test(dataProvider = "publicAPI")
-    public void introducingPublicMembers(String publicAPI,
-                                         Method method) throws Throwable {
-        Path root = Paths.get(method.getName());
-        Path classes = root.resolve("classes");
-
+    public void introducingPublicMembers(String publicAPI) throws Throwable {
         String API = "#API";
         String classTemplate =
                 "public class C { \n" +
@@ -122,8 +136,6 @@
                 "--release", "10", "-C", classes.resolve("v10").toString(), ".")
                 .shouldNotHaveExitValue(SUCCESS)
                 .shouldContain("contains a class with different api from earlier version");
-
-        FileUtils.deleteFileTreeWithRetry(root);
     }
 
     @DataProvider
@@ -138,11 +150,7 @@
     }
 
     @Test(dataProvider = "privateAPI")
-    public void introducingPrivateMembers(String privateAPI,
-                                          Method method) throws Throwable {
-        Path root = Paths.get(method.getName());
-        Path classes = root.resolve("classes");
-
+    public void introducingPrivateMembers(String privateAPI) throws Throwable {
         String API = "#API";
         String classTemplate =
                 "public class C { \n" +
@@ -167,8 +175,6 @@
         jar("uf", jarfile,
                 "--release", "11", "-C", classes.resolve("v10").toString(), ".")
                 .shouldHaveExitValue(SUCCESS);
-
-        FileUtils.deleteFileTreeWithRetry(root);
     }
 
     @DataProvider
@@ -190,4 +196,229 @@
         Files.write(classSourceFile, template.getBytes());
         javac(classes, classSourceFile);
     }
+
+     /* Modular multi-release checks */
+
+    @Test
+    public void moduleNameHasChanged() throws Throwable {
+
+        compileModule(classes.resolve("base"), "module A { }");
+        compileModule(classes.resolve("v10"), "module B { }");
+
+        String jarfile = root.resolve("test.jar").toString();
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("incorrect name");
+
+        // update module-info release
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("base").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
+        jar("uf", jarfile,
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("incorrect name");
+    }
+
+    //    @Test @ignore 8173370
+    public void moduleBecomeOpen() throws Throwable {
+
+        compileModule(classes.resolve("base"), "module A { }");
+        compileModule(classes.resolve("v10"), "open module A { }");
+
+        String jarfile = root.resolve("test.jar").toString();
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("FIX ME");
+
+        // update module-info release
+        jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("base").toString(), ".")
+                .shouldHaveExitValue(SUCCESS);
+        jar("uf", jarfile,
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+                .shouldNotHaveExitValue(SUCCESS)
+                .shouldContain("FIX ME");
+    }
+
+    @Test
+    public void moduleRequires() throws Throwable {
+
+        String BASE_VERSION_DIRECTIVE = "requires jdk.compiler;";
+        // add transitive flag
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "requires transitive jdk.compiler;",
+                false,
+                "contains additional \"requires transitive\"");
+        // remove requires
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "",
+                true,
+                "");
+        // add requires
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "requires jdk.compiler; requires jdk.jartool;",
+                true,
+                "");
+        // add requires transitive
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "requires jdk.compiler; requires transitive jdk.jartool;",
+                false,
+                "contains additional \"requires transitive\"");
+    }
+
+    @Test
+    public void moduleExports() throws Throwable {
+
+        String BASE_VERSION_DIRECTIVE = "exports pkg1; exports pkg2 to jdk.compiler;";
+        // add export
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " exports pkg3;",
+                false,
+                "contains different \"exports\"");
+        // change exports to qualified exports
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "exports pkg1 to jdk.compiler; exports pkg2;",
+                false,
+                "contains different \"exports\"");
+        // remove exports
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "exports pkg1;",
+                false,
+                "contains different \"exports\"");
+        // add qualified exports
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " exports pkg3 to jdk.compiler;",
+                false,
+                "contains different \"exports\"");
+    }
+
+    @Test
+    public void moduleOpens() throws Throwable {
+
+        String BASE_VERSION_DIRECTIVE = "opens pkg1; opens pkg2 to jdk.compiler;";
+        // add opens
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " opens pkg3;",
+                false,
+                "contains different \"opens\"");
+        // change opens to qualified opens
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "opens pkg1 to jdk.compiler; opens pkg2;",
+                false,
+                "contains different \"opens\"");
+        // remove opens
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "opens pkg1;",
+                false,
+                "contains different \"opens\"");
+        // add qualified opens
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " opens pkg3 to jdk.compiler;",
+                false,
+                "contains different \"opens\"");
+    }
+
+    @Test
+    public void moduleProvides() throws Throwable {
+
+        String BASE_VERSION_DIRECTIVE = "provides pkg1.A with pkg1.A;";
+        // add provides
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " provides pkg2.B with pkg2.B;",
+                false,
+                "contains different \"provides\"");
+        // change service impl
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "provides pkg1.A with pkg2.B;",
+                false,
+                "contains different \"provides\"");
+        // remove provides
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "",
+                false,
+                "contains different \"provides\"");
+    }
+
+    @Test
+    public void moduleUses() throws Throwable {
+
+        String BASE_VERSION_DIRECTIVE = "uses pkg1.A;";
+        // add
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                BASE_VERSION_DIRECTIVE + " uses pkg2.B;",
+                true,
+                "");
+        // replace
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "uses pkg2.B;",
+                true,
+                "");
+        // remove
+        moduleDirectivesCase(BASE_VERSION_DIRECTIVE,
+                "",
+                true,
+                "");
+    }
+
+    private void moduleDirectivesCase(String baseDirectives,
+                                      String versionedDirectives,
+                                      boolean expectSuccess,
+                                      String expectedMessage) throws Throwable {
+        String[] moduleClasses = {
+                "package pkg1; public class A { }",
+                "package pkg2; public class B extends pkg1.A { }",
+                "package pkg3; public class C extends pkg2.B { }"};
+        compileModule(classes.resolve("base"),
+                "module A { " + baseDirectives + " }",
+                moduleClasses);
+        compileModule(classes.resolve("v10"),
+                "module A { " + versionedDirectives + " }",
+                moduleClasses);
+
+        String jarfile = root.resolve("test.jar").toString();
+        OutputAnalyzer output = jar("cf", jarfile,
+                "-C", classes.resolve("base").toString(), ".",
+                "--release", "10", "-C", classes.resolve("v10").toString(), ".");
+        if (expectSuccess) {
+            output.shouldHaveExitValue(SUCCESS);
+        } else {
+            output.shouldNotHaveExitValue(SUCCESS)
+                    .shouldContain(expectedMessage);
+        }
+    }
+
+    private void compileModule(Path classes, String moduleSource,
+                               String... classSources) throws Throwable {
+        Matcher moduleMatcher = MODULE_PATTERN.matcher(moduleSource);
+        moduleMatcher.find();
+        String name = moduleMatcher.group(1);
+        Path moduleinfo = Files.createDirectories(
+                classes.getParent().resolve("src").resolve(name))
+                .resolve("module-info.java");
+        Files.write(moduleinfo, moduleSource.getBytes());
+
+        Path[] sourceFiles = new Path[classSources.length + 1];
+        sourceFiles[0] = moduleinfo;
+
+        for (int i = 0; i < classSources.length; i++) {
+            String classSource = classSources[i];
+            Matcher classMatcher = CLASS_PATTERN.matcher(classSource);
+            classMatcher.find();
+            String packageName = classMatcher.group(1);
+            String className = classMatcher.group(2);
+
+            Path packagePath = moduleinfo.getParent()
+                    .resolve(packageName.replace('.', '/'));
+            Path sourceFile = Files.createDirectories(packagePath)
+                    .resolve(className + ".java");
+            Files.write(sourceFile, classSource.getBytes());
+
+            sourceFiles[i + 1] = sourceFile;
+        }
+
+        javac(classes, sourceFiles);
+    }
 }
\ No newline at end of file
--- a/jdk/test/tools/jlink/CustomPluginTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import tests.Helper;
-import tests.JImageGenerator;
-import tests.Result;
-
-/*
- * @test
- * @summary Test custom plugin
- * @author Jean-Francois Denise
- * @library ../lib
- * @modules java.base/jdk.internal.jimage
- *          jdk.jdeps/com.sun.tools.classfile
- *          jdk.jlink/jdk.tools.jlink.internal
- *          jdk.jlink/jdk.tools.jmod
- *          jdk.jlink/jdk.tools.jimage
- *          jdk.compiler
- * @build tests.*
- * @run main/othervm CustomPluginTest
- */
-
-public class CustomPluginTest {
-
-    public static void main(String[] args) throws Exception {
-        new CustomPluginTest().test();
-    }
-
-    private void test() throws Exception {
-        Helper helper = Helper.newHelper();
-        if (helper == null) {
-            System.err.println("Test not run");
-            return;
-        }
-        helper.generateDefaultModules();
-        Path jmod = registerServices(helper);
-        Path pluginModulePath = jmod.getParent();
-
-        testHelloProvider(helper, pluginModulePath);
-        testCustomPlugins(helper, pluginModulePath);
-        testModuleVerification(helper, pluginModulePath);
-    }
-
-    private void testCustomPlugins(Helper helper, Path pluginModulePath) {
-        Result result = JImageGenerator.getJLinkTask()
-                .option("--list-plugins")
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir("customplugin"))
-                .call();
-        if (result.getExitCode() != 0) {
-            System.err.println(result.getMessage());
-            throw new AssertionError("jlink crashed: " + result.getExitCode());
-        }
-        List<String> customPlugins = Stream.of(result.getMessage().split("\n"))
-                .filter(s -> s.startsWith("Plugin Name:"))
-                .filter(s -> s.contains("custom"))
-                .collect(Collectors.toList());
-        if (customPlugins.size() != 1) {
-            System.err.println(result.getMessage());
-            throw new AssertionError("Found plugins: " + customPlugins);
-        }
-    }
-
-    private Path registerServices(Helper helper) throws IOException {
-        String name = "customplugin";
-        Path src = Paths.get(System.getProperty("test.src")).resolve(name);
-        Path classes = helper.getJmodClassesDir().resolve(name);
-        JImageGenerator.compile(src, classes);
-        return JImageGenerator.getJModTask()
-                .addClassPath(classes)
-                .jmod(helper.getJmodDir().resolve(name + ".jmod"))
-                .create().assertSuccess();
-    }
-
-    private void testHelloProvider(Helper helper, Path pluginModulePath) throws IOException {
-        Path pluginFile = Paths.get("customplugin.txt");
-        if (Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin output file already exists");
-        }
-        String customplugin = "customplugin";
-        {
-            // Add the path but not the option, plugin musn't be called
-            JImageGenerator.getJLinkTask()
-                    .modulePath(helper.defaultModulePath())
-                    .pluginModulePath(pluginModulePath)
-                    .output(helper.createNewImageDir(customplugin))
-                    .addMods(customplugin)
-                    .call().assertSuccess();
-        }
-
-        if (Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin output file exists, plugin "
-                    + " called although shouldn't have been");
-        }
-
-        { // Add the path and the option, plugin should be called.
-            JImageGenerator.getJLinkTask()
-                    .modulePath(helper.defaultModulePath())
-                    .addMods(customplugin)
-                    .pluginModulePath(pluginModulePath)
-                    .output(helper.createNewImageDir(customplugin))
-                    .option("--hello")
-                    .call().assertSuccess();
-        }
-
-        if (!Files.exists(pluginFile)) {
-            throw new AssertionError("Custom plugin not called");
-        }
-    }
-
-    private void testModuleVerification(Helper helper, Path pluginModulePath) throws IOException {
-        {
-            // dependent module missing check
-            String moduleName = "bar"; // 8147491
-            Path jmodFoo = helper.generateDefaultJModule("foo").assertSuccess();
-            Path jmodBar = helper.generateDefaultJModule(moduleName, "foo").assertSuccess();
-            // rogue filter removes "foo" module resources which are
-            // required by "bar" module. Module checks after plugin
-            // application should detect and report error.
-            JImageGenerator.getJLinkTask()
-                .modulePath(helper.defaultModulePath())
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir(moduleName))
-                .addMods(moduleName)
-                .option("--disable-plugin")
-                .option("release-info")
-                .option("--rogue-filter")
-                .option("/foo/")
-                .call()
-                .assertFailure("foo not found");
-        }
-
-        {
-            // package exported by one module used as concealed package
-            // in another module. But, module-info.class is not updated!
-            String moduleName = "jdk.scripting.nashorn";
-            JImageGenerator.getJLinkTask()
-                .modulePath(helper.defaultModulePath())
-                .pluginModulePath(pluginModulePath)
-                .output(helper.createNewImageDir(moduleName))
-                .addMods(moduleName)
-                // "java.logging" includes a package 'javax.script'
-                // which is an exported package from "java.scripting" module!
-                // module-info.class of java.logging left "as is".
-                .option("--rogue-adder")
-                .option("/java.logging/javax/script/Foo.class")
-                .call()
-                .assertFailure(
-                    "Module java.logging's descriptor returns inconsistent package set");
-        }
-    }
-}
--- a/jdk/test/tools/jlink/JLink2Test.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/jlink/JLink2Test.java	Wed Jul 05 22:46:04 2017 +0200
@@ -68,58 +68,9 @@
         // This test case must be first one, the JlinkTask is clean
         // and reveals possible bug related to plugin options in defaults
         testSameNames(helper);
-        testModulePath(helper);
         testOptions();
     }
 
-    private static void testModulePath(Helper helper) throws IOException {
-        Path doesNotExist = helper.createNewImageDir("doesnotexist");
-        Path jar = helper.getJarDir().resolve("bad.jar");
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(doesNotExist)
-                .option("--help")
-                .call().assertSuccess();
-        Files.createFile(jar);
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar)
-                .option("--help")
-                .call().assertFailure("(\n|\r|.)*Error: Invalid modules in the plugins path: (\n|\r|.)*");
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .option("--help")
-                .call().assertFailure("Error: Invalid modules in the plugins path: .*zip file is empty(\n|\r|.)*");
-        try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
-            JarEntry entry = new JarEntry("class");
-            out.putNextEntry(entry);
-            out.write("AAAA".getBytes());
-            out.closeEntry();
-        }
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .output(helper.createNewImageDir("crash"))
-                .addJmods(helper.getStdJmodsDir())
-                .addJmods(jar.getParent())
-                .addMods("bad")
-                .call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
-        try (JarOutputStream out = new JarOutputStream(new FileOutputStream(jar.toFile()))) {
-            JarEntry entry = new JarEntry("classes");
-            out.putNextEntry(entry);
-            out.closeEntry();
-
-            entry = new JarEntry("classes/class");
-            out.putNextEntry(entry);
-            out.write("AAAA".getBytes());
-            out.closeEntry();
-        }
-        JImageGenerator.getJLinkTask()
-                .pluginModulePath(jar.getParent())
-                .output(helper.createNewImageDir("bad"))
-                .addJmods(jar.getParent())
-                .addJars(helper.getStdJmodsDir())
-                .addMods("bad")
-                .call().assertFailure("(\n|\r|.)*Error: module-info.class not found for bad module(\n|\r|.)*");
-    }
-
     private static void testSameNames(Helper helper) throws Exception {
         // Multiple modules with the same name in modulepath, take the first one in the path.
         // First jmods then jars. So jmods are found, jars are hidden.
--- a/jdk/test/tools/jlink/customplugin/module-info.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module customplugin {
-    requires jdk.jlink;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.HelloPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.CustomPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.RogueAdderPlugin;
-    provides jdk.tools.jlink.plugin.Plugin with plugin.RogueFilterPlugin;
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-public class CustomPlugin implements Plugin {
-
-    private final static String NAME = "custom-plugin";
-
-    public CustomPlugin() {
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy(Function.identity(), out);
-        return out.build();
-    }
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-    }
-
-    @Override
-    public Category getType() {
-        return Category.PROCESSOR;
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.util.Collections;
-import java.util.Map;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Custom plugin
- */
-public final class HelloPlugin implements Plugin {
-
-    private static final String OUTPUT_FILE = "customplugin.txt";
-    public static final String NAME = "hello";
-
-    public static boolean called;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool inResources, ResourcePoolBuilder outResources) {
-        try {
-            System.out.println("Hello!!!!!!!!!!");
-            File f = new File(OUTPUT_FILE);
-            f.createNewFile();
-            inResources.entries().forEach(res -> {
-                outResources.add(res);
-            });
-        } catch (IOException ex) {
-            throw new UncheckedIOException(ex);
-        }
-        return outResources.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/RogueAdderPlugin.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.lang.module.ModuleDescriptor;
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Function;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePoolModule;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Rogue adder plugin
- */
-public final class RogueAdderPlugin implements Plugin {
-    public static final String NAME = "rogue-adder";
-    private String resName;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy(Function.identity(), out);
-        out.add(ResourcePoolEntry.create(resName, new byte[1]));
-        return out.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public Category getType() {
-        return Category.FILTER;
-    }
-
-    @Override
-    public boolean hasArguments() {
-        return true;
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-        resName = config.get(NAME);
-    }
-}
--- a/jdk/test/tools/jlink/customplugin/plugin/RogueFilterPlugin.java	Thu Jan 26 19:22:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package plugin;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.util.Collections;
-import java.util.Map;
-import jdk.tools.jlink.plugin.ResourcePoolEntry;
-import jdk.tools.jlink.plugin.ResourcePool;
-import jdk.tools.jlink.plugin.ResourcePoolBuilder;
-import jdk.tools.jlink.plugin.Plugin;
-
-/**
- * Rogue filter plugin
- */
-public final class RogueFilterPlugin implements Plugin {
-    public static final String NAME = "rogue-filter";
-    private String prefix;
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-    @Override
-    public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        in.transformAndCopy((file) -> {
-            return file.path().startsWith(prefix)? null : file;
-        }, out);
-        return out.build();
-    }
-
-    @Override
-    public String getDescription() {
-        return NAME + "-description";
-    }
-
-    @Override
-    public Category getType() {
-        return Category.FILTER;
-    }
-
-    @Override
-    public boolean hasArguments() {
-        return true;
-    }
-
-    @Override
-    public void configure(Map<String, String> config) {
-        prefix = config.get(NAME);
-    }
-}
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -25,6 +25,9 @@
 import java.lang.module.ModuleDescriptor.*;
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -36,6 +39,7 @@
 
 /**
  * @test
+ * @bug 8142968 8173381
  * @modules java.base/jdk.internal.misc
  * @run testng SystemModulesTest
  * @summary Verify the properties of ModuleDescriptor created
@@ -43,7 +47,72 @@
  */
 
 public class SystemModulesTest {
-    private static final JavaLangModuleAccess jlma = SharedSecrets.getJavaLangModuleAccess();
+    private static final JavaLangModuleAccess JLMA =
+        SharedSecrets.getJavaLangModuleAccess();
+    private static final String OS_NAME = System.getProperty("os.name");
+    private static final String OS_ARCH = System.getProperty("os.arch");
+    //  system modules containing no package
+    private static final Set<String> EMPTY_MODULES =
+        Set.of("java.se", "java.se.ee", "jdk.jdwp.agent", "jdk.pack");
+
+    @Test
+    public void testSystemModules() {
+        Path jimage = Paths.get(System.getProperty("java.home"), "lib", "modules");
+        if (Files.notExists(jimage))
+            return;
+
+        ModuleFinder.ofSystem().findAll().stream()
+                    .map(ModuleReference::descriptor)
+                    .forEach(this::checkAttributes);
+    }
+
+    // JMOD files are created with osName and osArch that may be different
+    // than os.name and os.arch system property
+    private boolean checkOSName(String name) {
+        if (name.equals(OS_NAME))
+            return true;
+
+        if (OS_NAME.equals("Mac OS X")) {
+            return name.equals("Darwin");
+        } else if (OS_NAME.startsWith("Windows")) {
+            return name.startsWith("Windows");
+        } else {
+            System.err.println("ERROR: " + name + " but expected: " + OS_NAME);
+            return false;
+        }
+    }
+
+    private boolean checkOSArch(String name) {
+        if (name.equals(OS_ARCH))
+            return true;
+
+        switch (OS_ARCH) {
+            case "i386":
+            case "x86":
+                return name.equals("i586");
+            default:
+                System.err.println("ERROR: " + name + " but expected: " + OS_ARCH);
+                return false;
+        }
+    }
+
+    private void checkAttributes(ModuleDescriptor md) {
+        System.out.format("%s %s %s %s%n", md.name(),
+                          md.osName(), md.osArch(), md.osVersion());
+
+        if (md.name().equals("java.base")) {
+            assertTrue(checkOSName(md.osName().get()));
+            assertTrue(checkOSArch(md.osArch().get()));
+            assertTrue(md.osVersion().isPresent());
+        } else {
+            // target platform attribute is dropped by jlink plugin
+            assertFalse(md.osName().isPresent());
+            assertFalse(md.osArch().isPresent());
+            assertFalse(md.osVersion().isPresent());
+            assertTrue(md.packages().size() > 0
+                || EMPTY_MODULES.contains(md.name()), md.name());
+        }
+    }
 
     /**
      * Verify ModuleDescriptor contains unmodifiable sets
@@ -59,18 +128,19 @@
     private void testModuleDescriptor(ModuleDescriptor md) {
         assertUnmodifiable(md.packages(), "package");
         assertUnmodifiable(md.requires(),
-                           jlma.newRequires(Set.of(Requires.Modifier.TRANSITIVE), "require", null));
+                           JLMA.newRequires(Set.of(Requires.Modifier.TRANSITIVE),
+                                            "require", null));
         for (Requires req : md.requires()) {
             assertUnmodifiable(req.modifiers(), Requires.Modifier.TRANSITIVE);
         }
 
-        assertUnmodifiable(md.exports(), jlma.newExports(Set.of(), "export", Set.of()));
+        assertUnmodifiable(md.exports(), JLMA.newExports(Set.of(), "export", Set.of()));
         for (Exports exp : md.exports()) {
             assertUnmodifiable(exp.modifiers(), Exports.Modifier.SYNTHETIC);
             assertUnmodifiable(exp.targets(), "target");
         }
 
-        assertUnmodifiable(md.opens(), jlma.newOpens(Set.of(), "open", Set.of()));
+        assertUnmodifiable(md.opens(), JLMA.newOpens(Set.of(), "open", Set.of()));
         for (Opens opens : md.opens()) {
             assertUnmodifiable(opens.modifiers(), Opens.Modifier.SYNTHETIC);
             assertUnmodifiable(opens.targets(), "target");
@@ -79,7 +149,7 @@
         assertUnmodifiable(md.uses(), "use");
 
         assertUnmodifiable(md.provides(),
-                           jlma.newProvides("provide", List.of("provide")));
+                           JLMA.newProvides("provide", List.of("provide")));
         for (Provides provides : md.provides()) {
             assertUnmodifiable(provides.providers(), "provide");
         }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -22,13 +22,20 @@
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.lang.module.ModuleDescriptor;
+import java.lang.reflect.Layer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.Set;
+import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import jdk.testlibrary.FileUtils;
+
 import static jdk.testlibrary.ProcessTools.*;
 
 
@@ -38,6 +45,7 @@
 
 /**
  * @test
+ * @bug 8142968 8173381
  * @library /lib/testlibrary
  * @modules jdk.compiler jdk.jlink
  * @build UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
@@ -50,8 +58,9 @@
 
     private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
     private static final Path MODS_DIR = Paths.get("mods");
+    private static final Path JMODS_DIR = Paths.get("jmods");
+
     private static final Path IMAGE = Paths.get("image");
-    private static final Path JMODS = Paths.get(JAVA_HOME, "jmods");
     private static final String MAIN_MID = "m1/p1.Main";
 
     // the names of the modules in this test
@@ -59,7 +68,7 @@
 
 
     private static boolean hasJmods() {
-        if (!Files.exists(JMODS)) {
+        if (!Files.exists(Paths.get(JAVA_HOME, "jmods"))) {
             System.err.println("Test skipped. NO jmods directory");
             return false;
         }
@@ -75,25 +84,17 @@
 
         for (String mn : modules) {
             Path msrc = SRC_DIR.resolve(mn);
-            assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
+            assertTrue(CompilerUtils.compile(msrc, MODS_DIR,
+                "--module-source-path", SRC_DIR.toString()));
         }
 
         if (Files.exists(IMAGE)) {
             FileUtils.deleteFileTreeUnchecked(IMAGE);
         }
 
-        createImage(IMAGE, "java.base", "m1", "m3");
-    }
+        createImage(IMAGE, "m1", "m3");
 
-    private void createImage(Path outputDir, String... modules) throws Throwable {
-        Path jlink = Paths.get(JAVA_HOME, "bin", "jlink");
-        String mp = JMODS.toString() + File.pathSeparator + MODS_DIR.toString();
-        assertTrue(executeProcess(jlink.toString(), "--output", outputDir.toString(),
-                        "--add-modules", Arrays.stream(modules).collect(Collectors.joining(",")),
-                        "--module-path", mp)
-                        .outputTo(System.out)
-                        .errorTo(System.out)
-                        .getExitValue() == 0);
+        createJmods("m1", "m4");
     }
 
     /*
@@ -120,9 +121,9 @@
 
         Path java = IMAGE.resolve("bin").resolve("java");
         assertTrue(executeProcess(java.toString(), "-m", "m3/p3.Main")
-            .outputTo(System.out)
-            .errorTo(System.out)
-            .getExitValue() == 0);
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .getExitValue() == 0);
     }
 
     /*
@@ -150,12 +151,114 @@
     public void testDedupSet() throws Throwable {
         if (!hasJmods()) return;
 
-        Path dir = Paths.get("newImage");
-        createImage(dir, "java.base", "m1", "m2", "m3", "m4");
+        Path dir = Paths.get("dedupSetTest");
+        createImage(dir, "m1", "m2", "m3", "m4");
         Path java = dir.resolve("bin").resolve("java");
         assertTrue(executeProcess(java.toString(), "-m", MAIN_MID)
                         .outputTo(System.out)
                         .errorTo(System.out)
                         .getExitValue() == 0);
     }
+
+    private void createJmods(String... modules) throws IOException {
+        // use the same target platform as in java.base
+        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
+                                   .getDescriptor();
+        String osName = md.osName().get();
+        String osArch = md.osArch().get();
+
+        // create JMOD files
+        Files.createDirectories(JMODS_DIR);
+        Stream.of(modules).forEach(mn ->
+            assertTrue(jmod("create",
+                "--class-path", MODS_DIR.resolve(mn).toString(),
+                "--os-name", osName,
+                "--os-arch", osArch,
+                "--main-class", mn.replace('m', 'p') + ".Main",
+                JMODS_DIR.resolve(mn + ".jmod").toString()) == 0)
+        );
+    }
+
+
+    /**
+     * Verify the module descriptor if package p4.dummy is excluded at link time.
+     */
+    @Test
+    public void testModulePackagesAttribute() throws Throwable {
+        if (!hasJmods()) return;
+
+        // create an image using JMOD files
+        Path dir = Paths.get("packagesTest");
+        String mp = Paths.get(JAVA_HOME, "jmods").toString() +
+            File.pathSeparator + JMODS_DIR.toString();
+
+        Set<String> modules = Set.of("m1", "m4");
+        assertTrue(JLINK_TOOL.run(System.out, System.out,
+            "--output", dir.toString(),
+            "--exclude-resources", "m4/p4/dummy/*",
+            "--add-modules", modules.stream().collect(Collectors.joining(",")),
+            "--module-path", mp) == 0);
+
+        // verify ModuleDescriptor
+        Path java = dir.resolve("bin").resolve("java");
+        assertTrue(executeProcess(java.toString(),
+                        "--add-modules=m1", "-m", "m4")
+            .outputTo(System.out)
+            .errorTo(System.out)
+            .getExitValue() == 0);
+    }
+
+    /**
+     * Verify the plugin to retain ModuleTarget attribute
+     */
+    @Test
+    public void testRetainModuleTarget() throws Throwable {
+        if (!hasJmods()) return;
+
+        // create an image using JMOD files
+        Path dir = Paths.get("retainModuleTargetTest");
+        String mp = Paths.get(JAVA_HOME, "jmods").toString() +
+            File.pathSeparator + JMODS_DIR.toString();
+
+        Set<String> modules = Set.of("m1", "m4");
+        assertTrue(JLINK_TOOL.run(System.out, System.out,
+            "--output", dir.toString(),
+            "--system-modules", "retainModuleTarget",
+            "--exclude-resources", "m4/p4/dummy/*",
+            "--add-modules", modules.stream().collect(Collectors.joining(",")),
+            "--module-path", mp) == 0);
+
+        // verify ModuleDescriptor
+        Path java = dir.resolve("bin").resolve("java");
+        assertTrue(executeProcess(java.toString(),
+                        "--add-modules=m1", "-m", "m4", "retainModuleTarget")
+            .outputTo(System.out)
+            .errorTo(System.out)
+            .getExitValue() == 0);
+    }
+
+    static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
+        .orElseThrow(() ->
+            new RuntimeException("jlink tool not found")
+        );
+
+    static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
+        .orElseThrow(() ->
+            new RuntimeException("jmod tool not found")
+        );
+
+    static final String MODULE_PATH = Paths.get(JAVA_HOME, "jmods").toString()
+        + File.pathSeparator + MODS_DIR.toString();
+
+    private void createImage(Path outputDir, String... modules) throws Throwable {
+        assertTrue(JLINK_TOOL.run(System.out, System.out,
+            "--output", outputDir.toString(),
+            "--add-modules", Arrays.stream(modules).collect(Collectors.joining(",")),
+            "--module-path", MODULE_PATH) == 0);
+    }
+
+    private static int jmod(String... options) {
+        System.out.println("jmod " + Arrays.asList(options));
+        return JMOD_TOOL.run(System.out, System.out, options);
+    }
 }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Wed Jul 05 22:46:04 2017 +0200
@@ -23,7 +23,10 @@
 
 package p1;
 
+import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
+import java.lang.reflect.Layer;
+import java.lang.reflect.Module;
 import java.net.URI;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
@@ -37,25 +40,48 @@
         // load another package
         p2.T.test();
 
-        // check the module descriptor of a system module
-        validate(Main.class.getModule().getDescriptor());
+        // validate the module descriptor
+        validate(Main.class.getModule());
+
+        // validate the Moduletarget attribute for java.base
+        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
+                                   .getDescriptor();
+        if (!md.osName().isPresent() || !md.osArch().isPresent() ||
+                !md.osVersion().isPresent()) {
+            throw new RuntimeException("java.base: " + md.osName() + " " +
+                    md.osArch() + " " + md.osVersion());
+        }
+    }
+
+    static void validate(Module module) throws IOException {
+        ModuleDescriptor md = module.getDescriptor();
 
         // read m1/module-info.class
         FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
                                                   Collections.emptyMap());
-        Path path = fs.getPath("/", "modules", "m1", "module-info.class");
-        validate(ModuleDescriptor.read(Files.newInputStream(path)));
-    }
+        Path path = fs.getPath("/", "modules", module.getName(), "module-info.class");
+        ModuleDescriptor md1 = ModuleDescriptor.read(Files.newInputStream(path));
+
 
-    static void validate(ModuleDescriptor md) {
+        // check the module descriptor of a system module and read from jimage
         checkPackages(md.packages(), "p1", "p2");
+        checkPackages(md1.packages(), "p1", "p2");
+
+        // check ModuleTarget attribute
+        checkModuleTargetAttribute(md);
+        checkModuleTargetAttribute(md1);
     }
 
     static void checkPackages(Set<String> pkgs, String... expected) {
-        for (String pn : expected) {
-            if (!pkgs.contains(pn)) {
-                throw new RuntimeException(pn + " missing in " + pkgs);
-            }
+        if (!pkgs.equals(Set.of(expected))) {
+            throw new RuntimeException(pkgs + " expected: " + Set.of(expected));
+        }
+    }
+
+    static void checkModuleTargetAttribute(ModuleDescriptor md) {
+        if (md.osName().isPresent() || md.osArch().isPresent() ||
+                md.osVersion().isPresent()) {
+            throw new RuntimeException(md.osName() + " " + md.osArch() + " " + md.osVersion());
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p4;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.reflect.Layer;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.Set;
+
+public class Main {
+    // the system module plugin by default drops ModuleTarget attribute
+    private static boolean expectModuleTarget = false;
+    public static void main(String... args) throws IOException {
+        if (args.length > 0) {
+            if (!args[0].equals("retainModuleTarget")) {
+                throw new IllegalArgumentException(args[0]);
+            }
+
+            expectModuleTarget = true;
+        }
+
+        // java.base is packaged with osName/osArch/osVersion
+        ModuleDescriptor md = Layer.boot().findModule("java.base").get()
+                                   .getDescriptor();
+        if (!md.osName().isPresent() ||
+                !md.osArch().isPresent() ||
+                !md.osVersion().isPresent()) {
+            throw new RuntimeException("osName/osArch/osVersion is missing: " +
+                md.osName() + " " + md.osArch() + " " + md.osVersion());
+        }
+
+        // verify module-info.class for m1 and m4
+        checkModule("m1", "p1", "p2");
+        checkModule("m4", "p4");
+    }
+
+    private static void checkModule(String mn, String... packages) throws IOException {
+        // verify ModuleDescriptor from the runtime module
+        ModuleDescriptor md = Layer.boot().findModule(mn).get()
+                                   .getDescriptor();
+        checkModuleDescriptor(md, packages);
+
+        // verify ModuleDescriptor from module-info.class read from ModuleReader
+        try (InputStream in = ModuleFinder.ofSystem().find(mn).get()
+            .open().open("module-info.class").get()) {
+            checkModuleDescriptor(ModuleDescriptor.read(in), packages);
+        }
+
+        // verify ModuleDescriptor from module-info.class read from jimage
+        FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
+            Collections.emptyMap());
+        Path path = fs.getPath("/", "modules", mn, "module-info.class");
+        checkModuleDescriptor(ModuleDescriptor.read(Files.newInputStream(path)), packages);
+    }
+
+    static void checkModuleDescriptor(ModuleDescriptor md, String... packages) {
+        String mainClass = md.name().replace('m', 'p') + ".Main";
+        if (!md.mainClass().get().equals(mainClass)) {
+            throw new RuntimeException(md.mainClass().toString());
+        }
+
+        if (expectModuleTarget) {
+            // ModuleTarget attribute is retained
+            if (!md.osName().isPresent() || !md.osArch().isPresent()) {
+                throw new RuntimeException("osName or osArch is missing: " +
+                    md.osName() + " " + md.osArch());
+            }
+        } else {
+            // by default ModuleTarget attribute is dropped
+            if (md.osName().isPresent() || md.osArch().isPresent()) {
+                throw new RuntimeException("osName and osArch should not be set: " +
+                    md.osName() + " " + md.osArch());
+            }
+        }
+
+        if (md.osVersion().isPresent()) {
+            throw new RuntimeException("Expected no osVersion set: " + md.osVersion());
+        }
+
+        Set<String> pkgs = md.packages();
+        if (!pkgs.equals(Set.of(packages))) {
+            throw new RuntimeException(pkgs + " expected: " + Set.of(packages));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/dummy/dummy.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,1 @@
+key=dummy
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/ArgsEnvVar.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8170832
+ * @summary Arguments passed in environment variable
+ * @build TestHelper
+ * @run main ArgsEnvVar
+ */
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class ArgsEnvVar extends TestHelper {
+    private static File testJar = null;
+    private static Map<String, String> env = new HashMap<>();
+
+    private static String JAVA_OPTIONS = "JAVA_OPTIONS";
+
+    static void init() throws IOException {
+        if  (testJar != null) {
+            return;
+        }
+        testJar = new File("test.jar");
+        StringBuilder tsrc = new StringBuilder();
+        tsrc.append("public static void main(String... args) {\n");
+        tsrc.append("   for (String x : args) {\n");
+        tsrc.append("        System.out.println(x);\n");
+        tsrc.append("   }\n");
+        tsrc.append("}\n");
+        createJar(testJar, new File("Foo"), tsrc.toString());
+
+        env.put(JLDEBUG_KEY, "true");
+    }
+
+    private File createArgFile(String fname, List<String> lines) throws IOException {
+        File argFile = new File(fname);
+        argFile.delete();
+        createAFile(argFile, lines);
+        return argFile;
+    }
+
+    private void verifyOptions(List<String> args, TestResult tr) {
+        if (args.isEmpty()) {
+            return;
+        }
+
+        int i = 1;
+        for (String x : args) {
+            tr.matches(".*argv\\[" + i + "\\] = " + Pattern.quote(x) + ".*");
+            i++;
+        }
+        if (! tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("test fails");
+        }
+    }
+
+    private void verifyUserArgs(List<String> args, TestResult tr, int index) {
+        if (javaCmd != TestHelper.javaCmd) {
+            tr.contains("\tFirst application arg index: 1");
+        } else {
+            tr.contains("\tFirst application arg index: " + index);
+
+            for (String arg: args) {
+                tr.matches("^" + Pattern.quote(arg) + "$");
+            }
+        }
+
+        if (! tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("test fails");
+        }
+    }
+
+    @Test
+    // Verify prepend and @argfile expansion
+    public void basic() throws IOException {
+        File argFile1 = createArgFile("argFile1", List.of("-Xmx32m"));
+        File argFile2 = createArgFile("argFile2", List.of("-Darg.file2=TWO"));
+        File argFile3 = createArgFile("argFile3", List.of("-Darg.file3=THREE"));
+
+        env.put(JAVA_OPTIONS, "@argFile1\n-Xint\r-cp @@escaped\t@argFile2");
+
+        TestResult tr = doExec(env, javaCmd, "@argFile3", "-cp", "test.jar", "Foo", "uarg1", "@uarg2");
+
+        List<String> appArgs = new ArrayList<>();
+        appArgs.add("uarg1");
+        appArgs.add("@uarg2");
+
+        List<String> options = new ArrayList<>();
+        options.add("-Xmx32m");
+        options.add("-Xint");
+        options.add("-cp");
+        options.add("@escaped");
+        options.add("-Darg.file2=TWO");
+        options.add("-Darg.file3=THREE");
+        options.add("-cp");
+        options.add("test.jar");
+        options.add("Foo");
+        options.addAll(appArgs);
+
+        verifyOptions(options, tr);
+        verifyUserArgs(appArgs, tr, 10);
+        argFile1.delete();
+        argFile2.delete();
+        argFile3.delete();
+    }
+
+    private TestResult testInEnv(List<String> options) {
+        env.put(JAVA_OPTIONS, String.join(" ", options));
+        return doExec(env, javaCmd, "-jar", "test.jar");
+    }
+
+    private TestResult testInEnvAsArgFile(List<String> options) throws IOException {
+        File argFile = createArgFile("argFile", options);
+        env.put(JAVA_OPTIONS, "@argFile");
+        TestResult tr = doExec(env, javaCmd, "-jar", "test.jar");
+        argFile.delete();
+        return tr;
+    }
+
+    @Test
+    public void noTerminalOpt() throws IOException {
+        List<List<String>> terminal_opts = List.of(
+                List.of("-jar", "test.jar"),
+                List.of("-m", "test/Foo"),
+                List.of("--module", "test/Foo"),
+                List.of("--dry-run"),
+                List.of("-h"),
+                List.of("-?"),
+                List.of("-help"),
+                List.of("--help"),
+                List.of("-X"),
+                List.of("--help-extra"),
+                List.of("-version"),
+                List.of("--version"),
+                List.of("-fullversion"),
+                List.of("--full-version"));
+
+        for (List<String> options: terminal_opts) {
+            // terminal opt in environment variable
+            TestResult tr = testInEnv(options);
+            tr.checkNegative();
+            if (!tr.testStatus) {
+                System.out.println(tr);
+                throw new RuntimeException("test fails");
+            }
+
+            // terminal opt in environment variable through @file
+            tr = testInEnvAsArgFile(options);
+            tr.checkNegative();
+            if (!tr.testStatus) {
+                System.out.println(tr);
+                throw new RuntimeException("test fails");
+            }
+        }
+    }
+
+    @Test
+    public void quote() throws IOException {
+        File argFile1 = createArgFile("arg File 1", List.of("-Xint"));
+        File argFile2 = createArgFile("arg File 2", List.of("-Dprop='value with spaces'"));
+        File argFile3 = createArgFile("arg File 3", List.of("-Xmx32m"));
+        env.put(JAVA_OPTIONS, "'@arg File 1' @\"arg File 2\" @'arg File'\" 3\"");
+
+        TestResult tr = doExec(env, javaCmd, "-jar", "test.jar");
+        List<String> options = new ArrayList<>();
+        options.add("-Xint");
+        options.add("-Dprop=value with spaces");
+        options.add("-Xmx32m");
+        options.add("-jar");
+        options.add("test.jar");
+        verifyOptions(options, tr);
+        argFile1.delete();
+        argFile2.delete();
+        argFile3.delete();
+    }
+
+    @Test
+    public void openQuoteShouldFail() {
+        env.put(JAVA_OPTIONS, "-Dprop='value missing close quote");
+        TestResult tr = doExec(env, javaCmd, "-version");
+        tr.checkNegative();
+        if (!tr.testStatus) {
+            System.out.println(tr);
+            throw new RuntimeException("test fails");
+        }
+    }
+
+    @Test
+    public void noWildcard() {
+        env.put(JAVA_OPTIONS, "-cp *");
+        TestResult tr = doExec(env, javaCmd, "-jar", "test.jar");
+        verifyOptions(List.of("-cp", "*", "-jar", "test.jar"), tr);
+
+        env.put(JAVA_OPTIONS, "-p ?");
+        tr = doExec(env, javaCmd, "-jar", "test.jar", "one", "two");
+        verifyOptions(List.of("-p", "?", "-jar", "test.jar", "one", "two"), tr);
+    }
+
+    public static void main(String... args) throws Exception {
+        init();
+        ArgsEnvVar a = new ArgsEnvVar();
+        a.run(args);
+        if (testExitValue > 0) {
+            System.out.println("Total of " + testExitValue + " failed");
+            System.exit(1);
+        } else {
+            System.out.println("All tests pass");
+        }
+    }
+}
+
--- a/jdk/test/tools/launcher/ArgsFileTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/launcher/ArgsFileTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -183,13 +183,13 @@
         lines.add("uarg1 @uarg2 @@uarg3 -uarg4 uarg5");
         File argFile2 = createArgFile("argFile2", lines);
         File argKill = createArgFile("argKill",
-            Collections.singletonList("-Xdisable-@files"));
+            Collections.singletonList("--disable-@files"));
 
-        TestResult tr = doExec(env, javaCmd, "@argFile1", "-Xdisable-@files", "@argFile2");
+        TestResult tr = doExec(env, javaCmd, "@argFile1", "--disable-@files", "@argFile2");
         List<String> options = new ArrayList<>();
         options.add("-Xmx32m");
         options.add("-Xint");
-        options.add("-Xdisable-@files");
+        options.add("--disable-@files");
         options.add("@argFile2");
         verifyOptions(options, tr);
         // Main class is @argFile2
@@ -202,9 +202,9 @@
         verifyUserArgs(Collections.emptyList(), tr, 5);
 
         // multiple is fine, once on is on.
-        tr = doExec(env, javaCmd, "@argKill", "@argFile1", "-Xdisable-@files", "@argFile2");
-        options = Arrays.asList("-Xdisable-@files", "@argFile1",
-                "-Xdisable-@files", "@argFile2");
+        tr = doExec(env, javaCmd, "@argKill", "@argFile1", "--disable-@files", "@argFile2");
+        options = Arrays.asList("--disable-@files", "@argFile1",
+                "--disable-@files", "@argFile2");
         verifyOptions(options, tr);
         verifyUserArgs(Collections.emptyList(), tr, 3);
 
--- a/jdk/test/tools/launcher/ClassPathWildCard.sh	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/launcher/ClassPathWildCard.sh	Wed Jul 05 22:46:04 2017 +0200
@@ -125,7 +125,7 @@
   CheckFail TestA
 
   rm -f TestB${OUTEXT}
-  $JAVA${variant} -classpath JarDir/"*"$NOOP TestB || exit 1
+  $JAVA${variant} -cp JarDir/"*"$NOOP TestB || exit 1
   CheckFail TestB
 
 
@@ -134,11 +134,11 @@
   cp TestD/*.class JarDir
 
   rm -f TestC${OUTEXT}
-  $JAVA${variant} -classpath JarDir${PATHSEP}JarDir/"*"$NOOP TestC || exit 1
+  $JAVA${variant} --class-path JarDir${PATHSEP}JarDir/"*"$NOOP TestC || exit 1
   CheckFail TestC
 
   rm -f TestD${OUTEXT}
-  $JAVA${variant} -classpath JarDir${PATHSEP}JarDir/"*"$NOOP TestD || exit 1
+  $JAVA${variant} --class-path=JarDir${PATHSEP}JarDir/"*"$NOOP TestD || exit 1
   CheckFail TestD
 }
 
--- a/jdk/test/tools/launcher/I18NArgTest.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/jdk/test/tools/launcher/I18NArgTest.java	Wed Jul 05 22:46:04 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,14 @@
 
 /*
  * @test
- * @bug 8016110
+ * @bug 8016110 8170832
  * @summary verify Japanese character in an argument are treated correctly
  * @compile -XDignore.symbol.file I18NArgTest.java
  * @run main I18NArgTest
  */
 import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
 
 public class I18NArgTest extends TestHelper {
     public static void main(String... args) throws IOException {
@@ -80,6 +82,7 @@
         execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue);
         execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue);
     }
+
     static void execTest(String unicodeStr, String hexValue) {
         TestResult tr = doExec(javaCmd,
                 "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(),
@@ -91,7 +94,24 @@
             System.err.println(tr);
             throw new RuntimeException("test fails");
         }
+
+        // Test via JAVA_OPTIONS
+/*
+        Map<String, String> env = new HashMap<>();
+        String cmd = "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath() +
+                " -Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath() +
+                " -cp " + TEST_CLASSES_DIR.getAbsolutePath() +
+                " I18NArgTest " + unicodeStr + " " + hexValue;
+        env.put("JAVA_OPTIONS", cmd);
+        tr = doExec(env, javaCmd);
+        System.out.println(tr.testOutput);
+        if (!tr.isOK()) {
+            System.err.println(tr);
+            throw new RuntimeException("test fails");
+        }
+*/
     }
+
     static void testCharacters(String... args) {
         String input = args[0];
         String expected = args[1];
--- a/make/Javadoc.gmk	Thu Jan 26 19:22:38 2017 +0000
+++ b/make/Javadoc.gmk	Wed Jul 05 22:46:04 2017 +0200
@@ -26,6 +26,7 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include $(JDK_TOPDIR)/make/Tools.gmk
 
 ################################################################################
 
@@ -180,6 +181,8 @@
     -tag see \
     -tag 'jvms:a:See <cite>The Java&trade; Virtual Machine Specification</cite>:' \
     -tag 'jls:a:See <cite>The Java&trade; Language Specification</cite>:' \
+    -taglet build.tools.taglet.Incubating \
+    -tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
     #
 
 DEFAULT_JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
@@ -311,7 +314,7 @@
   $1_INDEX_FILE := $$(JAVADOC_OUTPUTDIR)/$$($1_OUTPUT_DIRNAME)/index.html
 
   # Rule for actually running javadoc
-  $$($1_INDEX_FILE): $$($1_VARDEPS_FILE) $$($1_PACKAGE_DEPS) $$($1_DEPS)
+  $$($1_INDEX_FILE): $(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) $$($1_PACKAGE_DEPS) $$($1_DEPS)
 	$$(call LogWarn, Generating Javadoc from $$(words $$($1_PACKAGES)) package(s) for $$($1_OUTPUT_DIRNAME))
 	$$(call MakeDir, $$(@D))
         ifneq ($$($1_PACKAGES_FILE), )
@@ -740,7 +743,7 @@
 
 ################################################################################
 
-docs-javadoc: $(TARGETS)
+docs-javadoc: $(BUILD_TOOLS_JDK) $(TARGETS)
 
 docs-copy: $(COPY_TARGETS)
 
--- a/make/common/Modules.gmk	Thu Jan 26 19:22:38 2017 +0000
+++ b/make/common/Modules.gmk	Wed Jul 05 22:46:04 2017 +0200
@@ -182,15 +182,12 @@
 
 # Find all module-info.java files for the current build target platform and
 # configuration.
-# TODO: The $(firstword call is part of a workaround for using different
-# imported module-info.java in Jake due to a change in format. Remove once
-# new format is standard in JDK 9 and javafx delivers just that.
 # Param 1 - Module to find for, set to * for finding all
 FindAllModuleInfos = \
     $(wildcard \
         $(foreach sub, $(SRC_SUBDIRS), \
           $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
-        $(patsubst %,%/$(strip $1)/module-info.java, $(firstword $(IMPORT_MODULES_SRC))))
+        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
 
 # Find module-info.java files in the specific source dir
 # Param 1 - Src dir to find module-info.java files in
--- a/nashorn/.hgtags	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/.hgtags	Wed Jul 05 22:46:04 2017 +0200
@@ -387,3 +387,4 @@
 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151
 ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152
 19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153
+a84b49cfee63716975535abae2865ffef4dd6474 jdk-9+154
--- a/nashorn/README	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/README	Wed Jul 05 22:46:04 2017 +0200
@@ -18,7 +18,7 @@
 
     http://mercurial.selenic.com/wiki/ForestExtension
 
-and downlaoded using
+and downloaded using
 
     hg clone https://bitbucket.org/gxti/hgforest
 
@@ -39,7 +39,7 @@
 - How to build?
 
 To build Nashorn, you need to install JDK 9. You may use the Nashorn
-forest build (recommended) or down load from java.net.  You will need to
+forest build (recommended) or download from java.net.  You will need to
 set JAVA_HOME environmental variable to point to your JDK installation
 directory.
 
--- a/nashorn/make/build.xml	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/make/build.xml	Wed Jul 05 22:46:04 2017 +0200
@@ -394,6 +394,18 @@
 
   </target>
 
+  <target name="generate-security-config" depends="generate-policy-file, generate-security-properties-file"/>
+
+  <target name="generate-security-properties-file" depends="prepare">
+    <echo file="${build.dir}/nashorn.security.properties">
+
+package.access=sun.misc.,\
+    sun.reflect.,\
+    jdk.nashorn.internal.
+
+    </echo>
+  </target>
+
   <target name="generate-policy-file" depends="prepare">
     <echo file="${build.dir}/nashorn.policy">
 
@@ -600,7 +612,7 @@
 
   <target name="test" depends="prepare, javadoc, test-pessimistic, test-optimistic"/>
 
-  <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
     <echo message="Running test suite in OPTIMISTIC mode..."/>
     <antcall target="-test-nosecurity" inheritRefs="true">
       <param name="optimistic" value="true"/>
@@ -612,7 +624,7 @@
     </antcall>
   </target>
 
-  <target name="test-pessimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test-pessimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
     <echo message="Running test suite in PESSIMISTIC mode..."/>
     <antcall target="-test-nosecurity" inheritRefs="true">
       <param name="optimistic" value="false"/>
@@ -655,7 +667,7 @@
     </testng>
   </target>
 
-  <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="testmarkdown" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
     </fileset>
@@ -673,7 +685,7 @@
     </testng>
   </target>
 
-  <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
     <fileset id="test.classes" dir="${build.test.classes.dir}">
        <include name="**/framework/*Test.class"/>
     </fileset>
@@ -696,7 +708,7 @@
 
   <target name="test262parallel" depends="test262-parallel"/>
 
-  <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
     <!-- use just build.test.classes.dir to avoid referring to TestNG -->
     <java classname="${parallel.test.runner}" dir="${basedir}" fork="true" failonerror="true">
       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
@@ -714,7 +726,7 @@
 
   <target name="testparallel" depends="test-parallel"/>
 
-  <target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
+  <target name="test-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-security-config" if="testng.available">
       <!-- use just build.test.classes.dir to avoid referring to TestNG -->
       <java classname="${parallel.test.runner}" dir="${basedir}"
         failonerror="true"
--- a/nashorn/make/project.properties	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/make/project.properties	Wed Jul 05 22:46:04 2017 +0200
@@ -408,7 +408,7 @@
 run.test.jvmargs.octane.main=${run.test.jvmargs.common} -XX:TypeProfileLevel=222
 
 # Security manager args - make sure that we run with the nashorn.policy that the build creates
-run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${build.dir}/nashorn.policy
+run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${build.dir}/nashorn.policy -Djava.security.properties=${build.dir}/nashorn.security.properties
 
 # VM options for script tests with @fork option
 test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java	Wed Jul 05 22:46:04 2017 +0200
@@ -395,39 +395,45 @@
     }
 
     /**
-     * Applies argument filters to both the invocation and the guard (if there
-     * is one) with {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)}.
+     * Applies argument filters to both the invocation and the guard
+     * (if it exists and has at least {@code pos + 1} parameters) with
+     * {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)}.
      * @param pos the position of the first argument being filtered
      * @param filters the argument filters
      * @return a filtered invocation
      */
     public GuardedInvocation filterArguments(final int pos, final MethodHandle... filters) {
-        return replaceMethods(MethodHandles.filterArguments(invocation, pos, filters), guard == null ? null :
-            MethodHandles.filterArguments(guard, pos, filters));
+        return replaceMethods(MethodHandles.filterArguments(invocation, pos, filters),
+                guard == null || pos >= guard.type().parameterCount() ?
+                        guard : MethodHandles.filterArguments(guard, pos, filters));
     }
 
     /**
      * Makes an invocation that drops arguments in both the invocation and the
-     * guard (if there is one) with {@link MethodHandles#dropArguments(MethodHandle, int, List)}.
+     * guard (if it exists and has at least {@code pos} parameters) with
+     * {@link MethodHandles#dropArguments(MethodHandle, int, List)}.
      * @param pos the position of the first argument being dropped
      * @param valueTypes the types of the values being dropped
      * @return an invocation that drops arguments
      */
     public GuardedInvocation dropArguments(final int pos, final List<Class<?>> valueTypes) {
-        return replaceMethods(MethodHandles.dropArguments(invocation, pos, valueTypes), guard == null ? null :
-            MethodHandles.dropArguments(guard, pos, valueTypes));
+        return replaceMethods(MethodHandles.dropArguments(invocation, pos, valueTypes),
+                guard == null || pos > guard.type().parameterCount() ?
+                    guard : MethodHandles.dropArguments(guard, pos, valueTypes));
     }
 
     /**
      * Makes an invocation that drops arguments in both the invocation and the
-     * guard (if there is one) with {@link MethodHandles#dropArguments(MethodHandle, int, Class...)}.
+     * guard (if it exists and has at least {@code pos} parameters) with
+     * {@link MethodHandles#dropArguments(MethodHandle, int, Class...)}.
      * @param pos the position of the first argument being dropped
      * @param valueTypes the types of the values being dropped
      * @return an invocation that drops arguments
      */
     public GuardedInvocation dropArguments(final int pos, final Class<?>... valueTypes) {
-        return replaceMethods(MethodHandles.dropArguments(invocation, pos, valueTypes), guard == null ? null :
-            MethodHandles.dropArguments(guard, pos, valueTypes));
+        return replaceMethods(MethodHandles.dropArguments(invocation, pos, valueTypes),
+                guard == null || pos > guard.type().parameterCount() ?
+                        guard : MethodHandles.dropArguments(guard, pos, valueTypes));
     }
 
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/linker/NashornLinkerExporter.java	Wed Jul 05 22:46:04 2017 +0200
@@ -38,7 +38,7 @@
 
 /**
  * This linker exporter is a service provider that exports Nashorn Dynalink
- * linkers to external users. Other languague runtimes that use Dynalink
+ * linkers to external users. Other language runtimes that use Dynalink
  * can use the linkers exported by this provider to support tight integration
  * of Nashorn objects.
  */
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Wed Jul 05 22:46:04 2017 +0200
@@ -735,7 +735,7 @@
     /**
      * Name getter - ECMA Function.name
      *
-     * @param self self refence
+     * @param self self reference
      * @return the name, or undefined if none
      */
     public static Object G$name(final Object self) {
@@ -1120,12 +1120,19 @@
         assert appliedRequest != null; // Bootstrap.isCallable() returned true for args[1], so it must produce a linkage.
 
         final Class<?> applyFnType = descType.parameterType(0);
-        MethodHandle inv = appliedInvocation.getInvocation(); //method handle from apply invocation. the applied function invocation
+        // Invocation and guard handles from apply invocation.
+        MethodHandle inv = appliedInvocation.getInvocation();
+        MethodHandle guard = appliedInvocation.getGuard();
 
         if (isApply && !isFailedApplyToCall) {
             if (passesArgs) {
                 // Make sure that the passed argArray is converted to Object[] the same way NativeFunction.apply() would do it.
                 inv = MH.filterArguments(inv, 2, NativeFunction.TO_APPLY_ARGS);
+                // Some guards (non-strict functions with non-primitive this) have a this-object parameter, so we
+                // need to apply this transformations to them as well.
+                if (guard.type().parameterCount() > 2) {
+                    guard = MH.filterArguments(guard, 2, NativeFunction.TO_APPLY_ARGS);
+                }
             } else {
                 // If the original call site doesn't pass argArray, pass in an empty array
                 inv = MH.insertArguments(inv, 2, (Object) ScriptRuntime.EMPTY_ARRAY);
@@ -1144,12 +1151,25 @@
 
         if (!passesThis) {
             // If the original call site doesn't pass in a thisArg, pass in Global/undefined as needed
-            inv = bindImplicitThis(appliedFn, inv);
+            inv = bindImplicitThis(appliedFnNeedsWrappedThis, inv);
+            // guard may have this-parameter that needs to be inserted
+            if (guard.type().parameterCount() > 1) {
+                guard = bindImplicitThis(appliedFnNeedsWrappedThis, guard);
+            }
         } else if (appliedFnNeedsWrappedThis) {
             // target function needs a wrapped this, so make sure we filter for that
             inv = MH.filterArguments(inv, 1, WRAP_THIS);
+            // guard may have this-parameter that needs to be wrapped
+            if (guard.type().parameterCount() > 1) {
+                guard = MH.filterArguments(guard, 1, WRAP_THIS);
+            }
         }
+
+        final MethodType guardType = guard.type(); // Needed for combining guards below
+
+        // We need to account for the dropped (apply|call) function argument.
         inv = MH.dropArguments(inv, 0, applyFnType);
+        guard = MH.dropArguments(guard, 0, applyFnType);
 
         /*
          * Dropargs can only be non-()V in the case of isApply && !isFailedApplyToCall, which
@@ -1160,15 +1180,6 @@
             inv = MH.dropArguments(inv, 4 + i, dropArgs.parameterType(i));
         }
 
-        MethodHandle guard = appliedInvocation.getGuard();
-        // If the guard checks the value of "this" but we aren't passing thisArg, insert the default one
-        if (!passesThis && guard.type().parameterCount() > 1) {
-            guard = bindImplicitThis(appliedFn, guard);
-        }
-        final MethodType guardType = guard.type();
-
-        // We need to account for the dropped (apply|call) function argument.
-        guard = MH.dropArguments(guard, 0, descType.parameterType(0));
         // Take the "isApplyFunction" guard, and bind it to this function.
         MethodHandle applyFnGuard = MH.insertArguments(IS_APPLY_FUNCTION, 2, this); //TODO replace this with switchpoint
         // Adapt the guard to receive all the arguments that the original guard does.
@@ -1244,9 +1255,9 @@
         return ScriptObject.adaptHandleToVarArgCallSite(arrayConvertingGuard, descParamCount);
     }
 
-    private static MethodHandle bindImplicitThis(final Object fn, final MethodHandle mh) {
+    private static MethodHandle bindImplicitThis(final boolean needsWrappedThis, final MethodHandle mh) {
         final MethodHandle bound;
-        if (fn instanceof ScriptFunction && ((ScriptFunction) fn).needsWrappedThis()) {
+        if (needsWrappedThis) {
             bound = MH.filterArguments(mh, 1, SCRIPTFUNCTION_GLOBALFILTER);
         } else {
             bound = mh;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java	Wed Jul 05 22:46:04 2017 +0200
@@ -45,6 +45,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Objects;
+import jdk.dynalink.beans.BeansLinker;
 import jdk.dynalink.beans.StaticClass;
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
@@ -56,6 +57,7 @@
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.objects.NativeObject;
 import jdk.nashorn.internal.parser.Lexer;
+import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
 import jdk.nashorn.internal.runtime.linker.InvokeByName;
 
@@ -1039,7 +1041,30 @@
                 return ((JSObject)obj).hasMember(Objects.toString(property));
             }
 
-            return false;
+            final Object key = JSType.toPropertyKey(property);
+
+            if (obj instanceof StaticClass) {
+                final Class<?> clazz = ((StaticClass) obj).getRepresentedClass();
+                return BeansLinker.getReadableStaticPropertyNames(clazz).contains(Objects.toString(key))
+                    || BeansLinker.getStaticMethodNames(clazz).contains(Objects.toString(key));
+            } else {
+                if (obj instanceof Map && ((Map) obj).containsKey(key)) {
+                    return true;
+                }
+
+                final int index = ArrayIndex.getArrayIndex(key);
+                if (index >= 0) {
+                    if (obj instanceof List && index < ((List) obj).size()) {
+                        return true;
+                    }
+                    if (obj.getClass().isArray() && index < Array.getLength(obj)) {
+                        return true;
+                    }
+                }
+
+                return BeansLinker.getReadableInstancePropertyNames(obj.getClass()).contains(Objects.toString(key))
+                    || BeansLinker.getInstanceMethodNames(obj.getClass()).contains(Objects.toString(key));
+            }
         }
 
         throw typeError("in.with.non.object", rvalType.toString().toLowerCase(Locale.ENGLISH));
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Thu Jan 26 19:22:38 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Wed Jul 05 22:46:04 2017 +0200
@@ -147,9 +147,8 @@
                         new NashornBeansLinkerServices(linkerServices));
 
                 // Bind to the method, drop the original "this" and use original "callee" as this:
-                final MethodHandle inv = linkerServices.filterInternalObjects(gi
-                        .getInvocation()  // (method, this, args...)
-                        .bindTo(method)); // (this, args...)
+                final MethodHandle inv = gi.getInvocation()  // (method, this, args...)
+                                           .bindTo(method);  // (this, args...)
                 final MethodHandle calleeToThis = MH.dropArguments(inv, 1, callType.parameterType(1)); // (callee->this, <drop>, args...)
                 return gi.replaceMethods(calleeToThis, gi.getGuard());
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8166186.js	Wed Jul 05 22:46:04 2017 +0200
@@ -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.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * 8166186: ClassCastException with arguments usage
+ *
+ * @test
+ * @run
+ */
+
+function F (arg) {
+    print("F called");
+    Function.prototype.call.apply(G, arguments);
+}
+
+function G (){
+    print("G called");
+    print(this);
+    if (C++ > 5) return;
+    F("argument " + C);
+}
+
+var C = 0;
+
+G();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8166186.js.EXPECTED	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,20 @@
+G called
+[object global]
+F called
+G called
+argument 1
+F called
+G called
+argument 2
+F called
+G called
+argument 3
+F called
+G called
+argument 4
+F called
+G called
+argument 5
+F called
+G called
+argument 6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8172006.js	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8172006: Nashorn JavaScript engine fails to call @FunctionalInterface with a java.util.List argument
+ *
+ * @test
+ * @run
+ */
+
+var f = Java.type("jdk.nashorn.test.models.FunctionalInterfaceProvider").getImpl();
+
+var s = "a";
+s += "b";
+var o = { p: 10 };
+var a = [1, 2, 3];
+
+f([ f([]), f([]), f([]), f([]), f([]), f([]), f([]), f([]) ]);
+f([ f([]), f([ f([]), f([f([]), f([]), f([]) ]), f([])]), f([]) ]);
+f([ f([s]), f([o]), f([a]), f([s + "c"]), f([o]), f([a]) ]);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8173480.js	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8173480: in operator should work on java objects and classes
+ *
+ * @test
+ * @run
+ */
+
+var hash = "hash"; // for testing ConsString keys
+
+var obj = new java.lang.Object();
+Assert.assertTrue("hashCode" in obj);
+Assert.assertTrue(hash + "Code" in obj);
+Assert.assertTrue("class" in obj);
+Assert.assertFalse("x" in obj);
+Assert.assertFalse(1 in obj);
+Assert.assertFalse("1" in obj);
+
+var map = new java.util.HashMap();
+map["k"] = true;
+Assert.assertTrue(map["k"]);
+Assert.assertTrue("k" in map);
+Assert.assertTrue("hashCode" in map);
+Assert.assertTrue(hash + "Code" in map);
+Assert.assertTrue("class" in map);
+Assert.assertFalse("x" in map);
+Assert.assertFalse(1 in map);
+Assert.assertFalse("1" in map);
+
+var list = new java.util.ArrayList();
+list.add(true);
+Assert.assertTrue(list[0]);
+Assert.assertTrue(list["0"]);
+Assert.assertTrue(0 in list);
+Assert.assertTrue("0" in list);
+Assert.assertTrue("hashCode" in list);
+Assert.assertTrue(hash + "Code" in list);
+Assert.assertTrue("class" in list);
+Assert.assertFalse("x" in list);
+Assert.assertFalse(1 in list);
+Assert.assertFalse("1" in list);
+
+var objectArray = new (Java.type("java.lang.Object[]"))(1);
+objectArray[0] = true;
+Assert.assertTrue(objectArray[0]);
+Assert.assertTrue(objectArray["0"]);
+Assert.assertTrue(0 in objectArray);
+Assert.assertTrue("0" in objectArray);
+Assert.assertTrue("hashCode" in objectArray);
+Assert.assertTrue(hash + "Code" in objectArray);
+Assert.assertTrue("class" in objectArray);
+Assert.assertFalse("x" in objectArray);
+Assert.assertFalse(1 in objectArray);
+Assert.assertFalse("1" in objectArray);
+
+var RuntimeClass = Java.type("java.lang.Runtime");
+Assert.assertTrue("getRuntime" in RuntimeClass);
+Assert.assertTrue("runtime" in RuntimeClass);
+Assert.assertTrue("class" in RuntimeClass);
+Assert.assertFalse("hashCode" in RuntimeClass);
+Assert.assertFalse(hash + "Code" in RuntimeClass);
+Assert.assertFalse("x" in RuntimeClass);
+Assert.assertFalse(1 in RuntimeClass);
+Assert.assertFalse("1" in RuntimeClass);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/FunctionalInterfaceProvider.java	Wed Jul 05 22:46:04 2017 +0200
@@ -0,0 +1,53 @@
+/*
+ * 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.nashorn.test.models;
+
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.testng.Assert;
+
+import java.util.List;
+
+public class FunctionalInterfaceProvider {
+
+    private final static Object RETURN_TOKEN = new Object();
+
+    public static Functional getImpl() {
+        return (l) -> {
+            // Make sure parameters are properly exported
+            for (final Object o : l) {
+                Assert.assertTrue(o == RETURN_TOKEN
+                        || o instanceof ScriptObjectMirror
+                        || o instanceof String);
+            }
+            return RETURN_TOKEN;
+        };
+    }
+
+    @FunctionalInterface
+    public interface Functional {
+        Object method(List<Object> args);
+    }
+
+}