changeset 8753:6b21d823f6e6

Merge from main OpenJDK repository
author Greg Lewis <glewis@eyesbeyond.com>
date Thu, 07 Sep 2017 23:37:21 -0700
parents d918a2d9dbc2 ad08fea7cd1a
children 1d98f0be7c8d
files .hgtags make/sun/rmi/rmi/Makefile make/sun/splashscreen/FILES_c.gmk src/share/native/com/sun/java/util/jar/pack/defines.h src/share/native/common/check_code.c src/share/native/sun/awt/image/BufImgSurfaceData.c src/share/native/sun/awt/image/DataBufferNative.c src/share/native/sun/awt/libpng/pngtest.c src/share/native/sun/awt/libpng/pngwio.c src/share/native/sun/awt/libpng/pngwrite.c src/share/native/sun/awt/libpng/pngwtran.c src/share/native/sun/awt/libpng/pngwutil.c src/share/native/sun/security/ec/impl/ecc_impl.h
diffstat 270 files changed, 7564 insertions(+), 10473 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sun May 28 23:44:03 2017 -0700
+++ b/.hgtags	Thu Sep 07 23:37:21 2017 -0700
@@ -601,3 +601,5 @@
 e890a6aef6223d428376aac846c1d1f3e40dbda7 jdk7u141-b00
 a319566e15f5611bae9cfda2696e8217020a9269 jdk7u141-b01
 19a085e656145471455d7fbd648717f94281a729 jdk7u141-b02
+871e3350966f67b95768a94c1854f1515cfa56ca jdk7u151-b00
+da1c09ab9b742fa77c0e667c2218b8d626432656 jdk7u151-b01
--- a/make/sun/javazic/tzdata/VERSION	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/javazic/tzdata/VERSION	Thu Sep 07 23:37:21 2017 -0700
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2017a
+tzdata2017b
--- a/make/sun/javazic/tzdata/africa	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/javazic/tzdata/africa	Thu Sep 07 23:37:21 2017 -0700
@@ -443,18 +443,25 @@
 # See Africa/Johannesburg.
 
 # Liberia
-# From Paul Eggert (2006-03-22):
-# In 1972 Liberia was the last country to switch
-# from a UTC offset that was not a multiple of 15 or 20 minutes.
-# Howse reports that it was in honor of their president's birthday.
-# Shank & Pottenger report the date as May 1, whereas Howse reports Jan;
-# go with Shanks & Pottenger.
-# For Liberia before 1972, Shanks & Pottenger report -0:44, whereas Howse and
-# Whitman each report -0:44:30; go with the more precise figure.
+#
+# From Paul Eggert (2017-03-02):
+#
+# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30.
+#
+# In 1972 Liberia was the last country to switch from a UTC offset
+# that was not a multiple of 15 or 20 minutes.  The 1972 change was on
+# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of:
+# Presidential Papers: First year of the administration of
+# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972.
+# Monrovia: Executive Mansion.
+#
+# Use the abbreviation "MMT" before 1972, as the more-accurate numeric
+# abbreviation "-004430" would be one byte over the POSIX limit.
+#
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Monrovia	-0:43:08 -	LMT	1882
 			-0:43:08 -	MMT	1919 Mar # Monrovia Mean Time
-			-0:44:30 -	-004430	1972 May
+			-0:44:30 -	MMT	1972 Jan 7 # approximately MMT
 			 0:00	-	GMT
 
 ###############################################################################
--- a/make/sun/javazic/tzdata/iso3166.tab	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/javazic/tzdata/iso3166.tab	Thu Sep 07 23:37:21 2017 -0700
@@ -32,8 +32,8 @@
 # All text uses UTF-8 encoding.  The columns of the table are as follows:
 #
 # 1.  ISO 3166-1 alpha-2 country code, current as of
-#     ISO 3166-1 Newsletter VI-16 (2013-07-11).  See: Updates on ISO 3166
-#   http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm
+#     ISO 3166-1 N905 (2016-11-15).  See: Updates on ISO 3166-1
+#     http://isotc.iso.org/livelink/livelink/Open/16944257
 # 2.  The usual English name for the coded region,
 #     chosen so that alphabetic sorting of subsets produces helpful lists.
 #     This is not the same as the English name in the ISO 3166 tables.
--- a/make/sun/javazic/tzdata/northamerica	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/javazic/tzdata/northamerica	Thu Sep 07 23:37:21 2017 -0700
@@ -3162,6 +3162,12 @@
 # http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
 # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
 
+# From Steffen Thorsen (2017-03-12):
+# We have received 4 mails from different people telling that Haiti
+# has started DST again today, and this source seems to confirm that,
+# I have not been able to find a more authoritative source:
+# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Haiti	1983	only	-	May	8	0:00	1:00	D
 Rule	Haiti	1984	1987	-	Apr	lastSun	0:00	1:00	D
@@ -3174,6 +3180,8 @@
 Rule	Haiti	2005	2006	-	Oct	lastSun	0:00	0	S
 Rule	Haiti	2012	2015	-	Mar	Sun>=8	2:00	1:00	D
 Rule	Haiti	2012	2015	-	Nov	Sun>=1	2:00	0	S
+Rule	Haiti	2017	max	-	Mar	Sun>=8	2:00	1:00	D
+Rule	Haiti	2017	max	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port-au-Prince -4:49:20 -	LMT	1890
 			-4:49	-	PPMT	1917 Jan 24 12:00 # P-a-P MT
--- a/make/sun/rmi/rmi/Makefile	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/rmi/rmi/Makefile	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2011, 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
@@ -52,16 +52,9 @@
 include $(BUILDDIR)/common/Rules.gmk
 
 #
-# Full package names of implementations requiring stubs
-#
-REMOTE_impls = \
-	sun.rmi.registry.RegistryImpl \
-	sun.rmi.transport.DGCImpl
-
-#
 # The java-rmi.cgi script in bin/ only gets delivered in certain situations
 #
-BUILD_TARGETS = stubs
+BUILD_TARGETS =
 ifeq ($(PLATFORM), linux)
   BUILD_TARGETS += bin
 endif
@@ -78,29 +71,6 @@
 
 clean clobber:: bin.clean
 
-
-#
-# Compile stubs and skeletons for remote implementations
-# (use -v1.1 for backward interoperability)
-#
-#  gnumake 3.78.1 on windows attempts to build the target even
-#  though it exists. Not sure why, but a check for file existence
-#  has been added...
-#
-$(CLASSBINDIR)/%_Skel.class $(CLASSBINDIR)/%_Stub.class: $(CLASSBINDIR)/%.class
-	if [ ! -s $@ ] ; \
-	then $(RMIC) -v1.1 -classpath \
-	"$(CLASSBINDIR)" \
-	-d $(CLASSBINDIR) '$(subst /,.,$(<:$(CLASSBINDIR)/%.class=%))' ; \
-	fi
-	@$(java-vm-cleanup)
-
-REMOTE_files = $(subst .,/,$(REMOTE_impls))
-FILES_stubs  = $(REMOTE_files:%=$(CLASSBINDIR)/%_Stub.class)
-FILES_skels  = $(REMOTE_files:%=$(CLASSBINDIR)/%_Skel.class)
-
-stubs: $(FILES_stubs) $(FILES_skels)
-
 bin: $(BINDIR)/java-rmi.cgi
 
 $(BINDIR)/java-rmi.cgi: $(PLATFORM_SRC)/bin/java-rmi.cgi.sh
@@ -110,5 +80,5 @@
 bin.clean:
 	$(RM) $(BINDIR)/java-rmi.cgi
 
-.PHONY: stubs bin bin.clean
+.PHONY: bin bin.clean
 
--- a/make/sun/splashscreen/FILES_c.gmk	Sun May 28 23:44:03 2017 -0700
+++ b/make/sun/splashscreen/FILES_c.gmk	Thu Sep 07 23:37:21 2017 -0700
@@ -42,10 +42,6 @@
 	pngrutil.c \
 	pngset.c \
 	pngtrans.c \
-	pngwio.c \
-	pngwrite.c \
-	pngwtran.c \
-	pngwutil.c \
 	dgif_lib.c \
 	gif_err.c \
 	gifalloc.c \
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Thu Sep 07 23:37:21 2017 -0700
@@ -272,16 +272,21 @@
         contentView.execute(new CFNativeAction() {
             @Override
             public void run(final long viewPtr) {
+                boolean hasOwnerPtr = false;
+
                 if (owner != null) {
-                    owner.execute(new CFNativeAction() {
+                    hasOwnerPtr = 0L != owner.executeGet(new CFNativeActionGet() {
                         @Override
-                        public void run(long ownerPtr) {
+                        public long run(long ownerPtr) {
                             ref.set(nativeCreateNSWindow(viewPtr, ownerPtr, styleBits,
-                                                         bounds.x, bounds.y,
-                                                         bounds.width, bounds.height));
+                                                    bounds.x, bounds.y,
+                                                    bounds.width, bounds.height));
+                            return 1;
                         }
                     });
-                } else {
+            }
+
+            if (!hasOwnerPtr) {
                     ref.set(nativeCreateNSWindow(viewPtr, 0,
                                                  styleBits, bounds.x, bounds.y,
                                                  bounds.width, bounds.height));
--- a/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties	Thu Sep 07 23:37:21 2017 -0700
@@ -93,7 +93,7 @@
 resizable=storleks\u00E4ndringsbar
 selectable=valbar
 selected=vald
-showing=visas
+showing=visar
 singleline=en rad
 transient=tillf\u00E4llig
 visible=synlig
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Thu Sep 07 23:37:21 2017 -0700
@@ -387,6 +387,17 @@
         }
     }
 
+    private void skipPastImage(int imageIndex) {
+        cbLock.lock();
+        try {
+            gotoImage(imageIndex);
+            skipImage();
+        } catch (IOException | IndexOutOfBoundsException e) {
+        } finally {
+            cbLock.unlock();
+        }
+    }
+
     private int getNumImagesOnThread(boolean allowSearch)
       throws IOException {
         if (numImages != 0) {
@@ -1228,7 +1239,8 @@
         // Note that getData disables acceleration on buffer, but it is
         // just a 1-line intermediate data transfer buffer that will not
         // affect the acceleration of the resulting image.
-        aborted = readImage(structPointer,
+        aborted = readImage(imageIndex,
+                            structPointer,
                             buffer.getData(),
                             numRasterBands,
                             srcBands,
@@ -1390,7 +1402,8 @@
     /**
      * Returns <code>true</code> if the read was aborted.
      */
-    private native boolean readImage(long structPointer,
+    private native boolean readImage(int imageIndex,
+                                     long structPointer,
                                      byte [] buffer,
                                      int numRasterBands,
                                      int [] srcBands,
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java	Thu Sep 07 23:37:21 2017 -0700
@@ -165,8 +165,11 @@
         }
 
         public boolean postProcessKeyEvent(KeyEvent ev) {
-            if(ev.isConsumed()) {
-                // do not manage consumed event
+            if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
+                // mnemonic combination, it's consumed, but we need
+                // set altKeyPressed to false, otherwise after selection
+                // component by mnemonic combination a menu will be open
+                altKeyPressed = false;
                 return false;
             }
             if (ev.getKeyCode() == KeyEvent.VK_ALT) {
--- a/src/share/classes/com/sun/jndi/ldap/LdapClient.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/LdapClient.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1235,6 +1235,7 @@
     static final int LDAP_REF_FOLLOW = 0x01;            // follow referrals
     static final int LDAP_REF_THROW = 0x02;             // throw referral ex.
     static final int LDAP_REF_IGNORE = 0x03;            // ignore referrals
+    static final int LDAP_REF_FOLLOW_SCHEME = 0x04;     // follow referrals of the same scheme
 
     static final String LDAP_URL = "ldap://";           // LDAPv3
     static final String LDAPS_URL = "ldaps://";         // LDAPv3
--- a/src/share/classes/com/sun/jndi/ldap/LdapCtx.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/LdapCtx.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2413,6 +2413,9 @@
         // First determine the referral mode
         if (ref != null) {
             switch (ref) {
+                case "follow-scheme":
+                    handleReferrals = LdapClient.LDAP_REF_FOLLOW_SCHEME;
+                    break;
                 case "follow":
                     handleReferrals = LdapClient.LDAP_REF_FOLLOW;
                     break;
@@ -2975,7 +2978,23 @@
             r = new LdapReferralException(resolvedName, resolvedObj, remainName,
                 msg, envprops, fullDN, handleReferrals, reqCtls);
             // only one set of URLs is present
-            r.setReferralInfo(res.referrals.elementAt(0), false);
+            Vector<String> refs;
+            if (res.referrals == null) {
+                refs = null;
+            } else if (handleReferrals == LdapClient.LDAP_REF_FOLLOW_SCHEME) {
+                refs = new Vector<>();
+                for (String s : res.referrals.elementAt(0)) {
+                    if (s.startsWith("ldap:")) {
+                        refs.add(s);
+                    }
+                }
+                if (refs.isEmpty()) {
+                    refs = null;
+                }
+            } else {
+                refs = res.referrals.elementAt(0);
+            }
+            r.setReferralInfo(refs, false);
 
             if (hopCount > 1) {
                 r.setHopCount(hopCount);
@@ -3044,7 +3063,7 @@
              *     assume name resolution has not yet completed.
              */
             if (((res.entries == null) || (res.entries.isEmpty())) &&
-                (res.referrals.size() == 1)) {
+                ((res.referrals != null) && (res.referrals.size() == 1))) {
 
                 r.setReferralInfo(res.referrals, false);
 
--- a/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,7 +117,8 @@
 
         // If following referral, request controls are passed to referral ctx
         this.reqCtls =
-            (handleReferrals == LdapClient.LDAP_REF_FOLLOW ? reqCtls : null);
+            (handleReferrals == LdapClient.LDAP_REF_FOLLOW ||
+                    handleReferrals == LdapClient.LDAP_REF_FOLLOW_SCHEME ? reqCtls : null);
     }
 
     /**
@@ -217,13 +218,15 @@
             System.out.println("LdapReferralException.setReferralInfo");
 
         this.referrals = referrals;
-        if (referrals != null) {
-            referralCount = referrals.size();
-        }
+        referralCount = (referrals == null) ? 0 : referrals.size();
 
         if (debug) {
-            for (int i = 0; i < referralCount; i++) {
-                System.out.println("  [" + i + "] " + referrals.elementAt(i));
+            if (referrals != null) {
+                for (int i = 0; i < referralCount; i++) {
+                    System.out.println("  [" + i + "] " + referrals.elementAt(i));
+                }
+            } else {
+                System.out.println("setReferralInfo : referrals == null");
             }
         }
     }
--- a/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, 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
@@ -62,9 +62,10 @@
      * @param  outputFile the system-dependent filename
      * @param  live if <tt>true</tt> dump only <i>live</i> objects
      *         i.e. objects that are reachable from others
-     * @throws IOException if the <tt>outputFile</tt>
+     * @throws IOException if the <tt>outputFile</tt> already exists,
      *                     cannot be created, opened, or written to.
      * @throws UnsupportedOperationException if this operation is not supported.
+     * @throws IllegalArgumentException if <tt>outputFile</tt> does not end with ".hprof" suffix.
      * @throws NullPointerException if <tt>outputFile</tt> is <tt>null</tt>.
      * @throws SecurityException
      *         If a security manager exists and its {@link
--- a/src/share/classes/java/lang/invoke/LambdaForm.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/lang/invoke/LambdaForm.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -918,10 +918,10 @@
         System.arraycopy(names, skip+outArgs, names2, skip+inTypes, bodyLength);
         int arity2 = names2.length - bodyLength;
         int result2 = result;
-        if (result2 >= 0) {
+        if (result2 >= skip) {
             if (result2 < skip+outArgs) {
                 // return the corresponding inArg
-                result2 = reorder[result2-skip];
+                result2 = reorder[result2 - skip] + skip;
             } else {
                 result2 = result2 - outArgs + inTypes;
             }
--- a/src/share/classes/java/lang/reflect/WeakCache.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/lang/reflect/WeakCache.java	Thu Sep 07 23:37:21 2017 -0700
@@ -253,11 +253,11 @@
             // wrap value with CacheValue (WeakReference)
             CacheValue<V> cacheValue = new CacheValue<>(value);
 
+            // put into reverseMap
+            reverseMap.put(cacheValue, Boolean.TRUE);
+
             // try replacing us with CacheValue (this should always succeed)
-            if (valuesMap.replace(subKey, this, cacheValue)) {
-                // put also in reverseMap
-                reverseMap.put(cacheValue, Boolean.TRUE);
-            } else {
+            if (!valuesMap.replace(subKey, this, cacheValue)) {
                 throw new AssertionError("Should not reach here");
             }
 
--- a/src/share/classes/java/nio/Bits.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/nio/Bits.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -609,7 +609,8 @@
         String arch = AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("os.arch"));
         unaligned = arch.equals("i386") || arch.equals("x86")
-            || arch.equals("amd64") || arch.equals("x86_64");
+            || arch.equals("amd64") || arch.equals("x86_64")
+            || arch.equals("ppc64") || arch.equals("ppc64le");
         unalignedKnown = true;
         return unaligned;
     }
--- a/src/share/classes/java/rmi/activation/ActivationID.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/rmi/activation/ActivationID.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,12 @@
 import java.rmi.server.RemoteObjectInvocationHandler;
 import java.rmi.server.RemoteRef;
 import java.rmi.server.UID;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permissions;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
 
 /**
  * Activation makes use of special identifiers to denote remote
@@ -81,6 +87,14 @@
     /** indicate compatibility with the Java 2 SDK v1.2 version of class */
     private static final long serialVersionUID = -4608673054848209235L;
 
+    /** an AccessControlContext with no permissions */
+    private static final AccessControlContext NOPERMS_ACC;
+    static {
+        Permissions perms = new Permissions();
+        ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
+        NOPERMS_ACC = new AccessControlContext(pd);
+    }
+
     /**
      * The constructor for <code>ActivationID</code> takes a single
      * argument, activator, that specifies a remote reference to the
@@ -112,15 +126,21 @@
         throws ActivationException, UnknownObjectException, RemoteException
     {
         try {
-            MarshalledObject<? extends Remote> mobj =
+            final MarshalledObject<? extends Remote> mobj =
                 activator.activate(this, force);
-            return mobj.get();
-        } catch (RemoteException e) {
-            throw e;
-        } catch (IOException e) {
-            throw new UnmarshalException("activation failed", e);
-        } catch (ClassNotFoundException e) {
-            throw new UnmarshalException("activation failed", e);
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Remote>() {
+                    public Remote run() throws IOException, ClassNotFoundException {
+                        return mobj.get();
+                    }
+                }, NOPERMS_ACC);
+        } catch (PrivilegedActionException pae) {
+            Exception ex = pae.getException();
+            if (ex instanceof RemoteException) {
+                throw (RemoteException) ex;
+            } else {
+                throw new UnmarshalException("activation failed", ex);
+            }
         }
 
     }
--- a/src/share/classes/java/security/CodeSource.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/security/CodeSource.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -529,6 +529,7 @@
     {
         CertificateFactory cf;
         Hashtable<String, CertificateFactory> cfs = null;
+        List<java.security.cert.Certificate> certList = null;
 
         ois.defaultReadObject(); // location
 
@@ -538,7 +539,7 @@
             // we know of 3 different cert types: X.509, PGP, SDSI, which
             // could all be present in the stream at the same time
             cfs = new Hashtable<String, CertificateFactory>(3);
-            this.certs = new java.security.cert.Certificate[size];
+            certList = new ArrayList<>(size > 20 ? 20 : size);
         }
 
         for (int i = 0; i < size; i++) {
@@ -569,13 +570,17 @@
             ois.readFully(encoded);
             ByteArrayInputStream bais = new ByteArrayInputStream(encoded);
             try {
-                this.certs[i] = cf.generateCertificate(bais);
+                certList.add(cf.generateCertificate(bais));
             } catch (CertificateException ce) {
                 throw new IOException(ce.getMessage());
             }
             bais.close();
         }
 
+        if (certList != null) {
+            this.certs = certList.toArray(
+                    new java.security.cert.Certificate[size]);
+        }
         // Deserialize array of code signers (if any)
         try {
             this.signers = ((CodeSigner[])ois.readObject()).clone();
--- a/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Thu Sep 07 23:37:21 2017 -0700
@@ -34,6 +34,10 @@
  */
 
 package java.util.concurrent;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.concurrent.locks.AbstractQueuedSynchronizer;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
@@ -567,6 +571,9 @@
     private static final RuntimePermission shutdownPerm =
         new RuntimePermission("modifyThread");
 
+    /* The context to be used when executing the finalizer, or null. */
+    private final AccessControlContext acc;
+
     /**
      * Class Worker mainly maintains interrupt control state for
      * threads running tasks, along with other minor bookkeeping.
@@ -1310,6 +1317,9 @@
             throw new IllegalArgumentException();
         if (workQueue == null || threadFactory == null || handler == null)
             throw new NullPointerException();
+        this.acc = System.getSecurityManager() == null ?
+                null :
+                AccessController.getContext();
         this.corePoolSize = corePoolSize;
         this.maximumPoolSize = maximumPoolSize;
         this.workQueue = workQueue;
@@ -1477,7 +1487,19 @@
      * referenced and it has no threads.
      */
     protected void finalize() {
-        shutdown();
+        SecurityManager sm = System.getSecurityManager();
+        if (sm == null || acc == null) {
+            shutdown();
+        } else {
+            PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
+                @Override
+                public Void run() {
+                    shutdown();
+                    return null;
+                }
+            };
+            AccessController.doPrivileged(pa, acc);
+        }
     }
 
     /**
@@ -2099,4 +2121,3 @@
         }
     }
 }
-
--- a/src/share/classes/java/util/jar/Attributes.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/util/jar/Attributes.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,7 +71,7 @@
      * @param size the initial number of attributes
      */
     public Attributes(int size) {
-        map = new HashMap(size);
+        map = new HashMap<>(size);
     }
 
     /**
@@ -81,7 +81,7 @@
      * @param attr the specified Attributes
      */
     public Attributes(Attributes attr) {
-        map = new HashMap(attr);
+        map = new HashMap<>(attr);
     }
 
 
@@ -296,9 +296,9 @@
      * XXX Need to handle UTF8 values and break up lines longer than 72 bytes
      */
      void write(DataOutputStream os) throws IOException {
-        Iterator it = entrySet().iterator();
+        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry e = (Map.Entry)it.next();
+            Map.Entry<Object, Object> e = it.next();
             StringBuffer buffer = new StringBuffer(
                                         ((Name)e.getKey()).toString());
             buffer.append(": ");
@@ -340,9 +340,9 @@
 
         // write out all attributes except for the version
         // we wrote out earlier
-        Iterator it = entrySet().iterator();
+        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry e = (Map.Entry)it.next();
+            Map.Entry<Object, Object> e = it.next();
             String name = ((Name)e.getKey()).toString();
             if ((version != null) && ! (name.equalsIgnoreCase(vername))) {
 
@@ -499,7 +499,7 @@
          */
         public boolean equals(Object o) {
             if (o instanceof Name) {
-                Comparator c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
+                Comparator<String> c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
                 return c.compare(name, ((Name)o).name) == 0;
             } else {
                 return false;
--- a/src/share/classes/java/util/jar/JarVerifier.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/util/jar/JarVerifier.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -49,21 +49,21 @@
 
     /* a table mapping names to code signers, for jar entries that have
        had their actual hashes verified */
-    private Hashtable verifiedSigners;
+    private Hashtable<String, CodeSigner[]> verifiedSigners;
 
     /* a table mapping names to code signers, for jar entries that have
        passed the .SF/.DSA/.EC -> MANIFEST check */
-    private Hashtable sigFileSigners;
+    private Hashtable<String, CodeSigner[]> sigFileSigners;
 
     /* a hash table to hold .SF bytes */
-    private Hashtable sigFileData;
+    private Hashtable<String, byte[]> sigFileData;
 
     /** "queue" of pending PKCS7 blocks that we couldn't parse
      *  until we parsed the .SF file */
-    private ArrayList pendingBlocks;
+    private ArrayList<SignatureFileVerifier> pendingBlocks;
 
     /* cache of CodeSigner objects */
-    private ArrayList signerCache;
+    private ArrayList<CodeSigner[]> signerCache;
 
     /* Are we parsing a block? */
     private boolean parsingBlockOrSF = false;
@@ -95,10 +95,10 @@
 
     public JarVerifier(byte rawBytes[]) {
         manifestRawBytes = rawBytes;
-        sigFileSigners = new Hashtable();
-        verifiedSigners = new Hashtable();
-        sigFileData = new Hashtable(11);
-        pendingBlocks = new ArrayList();
+        sigFileSigners = new Hashtable<>();
+        verifiedSigners = new Hashtable<>();
+        sigFileData = new Hashtable<>(11);
+        pendingBlocks = new ArrayList<>();
         baos = new ByteArrayOutputStream();
         manifestDigests = new ArrayList();
     }
@@ -180,10 +180,12 @@
 
         // only set the jev object for entries that have a signature
         // (either verified or not)
-        if (sigFileSigners.get(name) != null ||
-                verifiedSigners.get(name) != null) {
-            mev.setEntry(name, je);
-            return;
+        if (!name.equals(JarFile.MANIFEST_NAME)) {
+            if (sigFileSigners.get(name) != null ||
+                    verifiedSigners.get(name) != null) {
+                mev.setEntry(name, je);
+                return;
+            }
         }
 
         // don't compute the digest for this entry
@@ -260,10 +262,9 @@
                     sigFileData.put(key, bytes);
                     // check pending blocks, we can now process
                     // anyone waiting for this .SF file
-                    Iterator it = pendingBlocks.iterator();
+                    Iterator<SignatureFileVerifier> it = pendingBlocks.iterator();
                     while (it.hasNext()) {
-                        SignatureFileVerifier sfv =
-                            (SignatureFileVerifier) it.next();
+                        SignatureFileVerifier sfv = it.next();
                         if (sfv.needSignatureFile(key)) {
                             if (debug != null) {
                                 debug.println(
@@ -282,7 +283,7 @@
                 String key = uname.substring(0, uname.lastIndexOf("."));
 
                 if (signerCache == null)
-                    signerCache = new ArrayList();
+                    signerCache = new ArrayList<>();
 
                 if (manDig == null) {
                     synchronized(manifestRawBytes) {
@@ -299,7 +300,7 @@
 
                 if (sfv.needSignatureFileBytes()) {
                     // see if we have already parsed an external .SF file
-                    byte[] bytes = (byte[]) sigFileData.get(key);
+                    byte[] bytes = sigFileData.get(key);
 
                     if (bytes == null) {
                         // put this block on queue for later processing
@@ -355,7 +356,7 @@
      */
     public CodeSigner[] getCodeSigners(String name)
     {
-        return (CodeSigner[])verifiedSigners.get(name);
+        return verifiedSigners.get(name);
     }
 
     public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry)
@@ -388,15 +389,14 @@
         CodeSigner[] signers) {
 
         if (signers != null) {
-            ArrayList certChains = new ArrayList();
+            ArrayList<java.security.cert.Certificate> certChains = new ArrayList<>();
             for (int i = 0; i < signers.length; i++) {
                 certChains.addAll(
                     signers[i].getSignerCertPath().getCertificates());
             }
 
             // Convert into a Certificate[]
-            return (java.security.cert.Certificate[])
-                certChains.toArray(
+            return certChains.toArray(
                     new java.security.cert.Certificate[certChains.size()]);
         }
         return null;
@@ -430,8 +430,8 @@
         // MANIFEST.MF is always treated as signed and verified,
         // move its signers from sigFileSigners to verifiedSigners.
         if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) {
-            verifiedSigners.put(JarFile.MANIFEST_NAME,
-                    sigFileSigners.remove(JarFile.MANIFEST_NAME));
+            CodeSigner[] codeSigners = sigFileSigners.remove(JarFile.MANIFEST_NAME);
+            verifiedSigners.put(JarFile.MANIFEST_NAME, codeSigners);
         }
     }
 
@@ -505,10 +505,10 @@
 
     // Extended JavaUtilJarAccess CodeSource API Support
 
-    private Map urlToCodeSourceMap = new HashMap();
-    private Map signerToCodeSource = new HashMap();
+    private Map<URL, Map<CodeSigner[], CodeSource>> urlToCodeSourceMap = new HashMap<>();
+    private Map<CodeSigner[], CodeSource> signerToCodeSource = new HashMap<>();
     private URL lastURL;
-    private Map lastURLMap;
+    private Map<CodeSigner[], CodeSource> lastURLMap;
 
     /*
      * Create a unique mapping from codeSigner cache entries to CodeSource.
@@ -516,19 +516,19 @@
      * and shared JAR file although in practice there will be a single URL in use.
      */
     private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
-        Map map;
+        Map<CodeSigner[], CodeSource> map;
         if (url == lastURL) {
             map = lastURLMap;
         } else {
-            map = (Map) urlToCodeSourceMap.get(url);
+            map = urlToCodeSourceMap.get(url);
             if (map == null) {
-                map = new HashMap();
+                map = new HashMap<>();
                 urlToCodeSourceMap.put(url, map);
             }
             lastURLMap = map;
             lastURL = url;
         }
-        CodeSource cs = (CodeSource) map.get(signers);
+        CodeSource cs = map.get(signers);
         if (cs == null) {
             cs = new VerifierCodeSource(csdomain, url, signers);
             signerToCodeSource.put(signers, cs);
@@ -536,16 +536,16 @@
         return cs;
     }
 
-    private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) {
-        List sources = new ArrayList();
+    private CodeSource[] mapSignersToCodeSources(URL url, List<CodeSigner[]> signers, boolean unsigned) {
+        List<CodeSource> sources = new ArrayList<>();
 
         for (int i = 0; i < signers.size(); i++) {
-            sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i)));
+            sources.add(mapSignersToCodeSource(url, signers.get(i)));
         }
         if (unsigned) {
             sources.add(mapSignersToCodeSource(url, null));
         }
-        return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]);
+        return sources.toArray(new CodeSource[sources.size()]);
     }
     private CodeSigner[] emptySigner = new CodeSigner[0];
 
@@ -565,7 +565,7 @@
          * but this handles a CodeSource of any type, just in case.
          */
         CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
-        List sourceList = new ArrayList();
+        List<CodeSource> sourceList = new ArrayList<>();
         for (int i = 0; i < sources.length; i++) {
             sourceList.add(sources[i]);
         }
@@ -586,6 +586,7 @@
      * signing data that can be compared by object reference identity.
      */
     private static class VerifierCodeSource extends CodeSource {
+        private static final long serialVersionUID = -9047366145967768825L;
 
         URL vlocation;
         CodeSigner[] vsigners;
@@ -653,16 +654,16 @@
             return vcerts;
         }
     }
-    private Map signerMap;
+    private Map<String, CodeSigner[]> signerMap;
 
-    private synchronized Map signerMap() {
+    private synchronized Map<String, CodeSigner[]> signerMap() {
         if (signerMap == null) {
             /*
              * Snapshot signer state so it doesn't change on us. We care
              * only about the asserted signatures. Verification of
              * signature validity happens via the JarEntry apis.
              */
-            signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size());
+            signerMap = new HashMap<>(verifiedSigners.size() + sigFileSigners.size());
             signerMap.putAll(verifiedSigners);
             signerMap.putAll(sigFileSigners);
         }
@@ -670,15 +671,15 @@
     }
 
     public synchronized Enumeration<String> entryNames(JarFile jar, final CodeSource[] cs) {
-        final Map map = signerMap();
-        final Iterator itor = map.entrySet().iterator();
+        final Map<String, CodeSigner[]> map = signerMap();
+        final Iterator<Map.Entry<String, CodeSigner[]>> itor = map.entrySet().iterator();
         boolean matchUnsigned = false;
 
         /*
          * Grab a single copy of the CodeSigner arrays. Check
          * to see if we can optimize CodeSigner equality test.
          */
-        List req = new ArrayList(cs.length);
+        List<CodeSigner[]> req = new ArrayList<>(cs.length);
         for (int i = 0; i < cs.length; i++) {
             CodeSigner[] match = findMatchingSigners(cs[i]);
             if (match != null) {
@@ -692,8 +693,8 @@
             }
         }
 
-        final List signersReq = req;
-        final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
+        final List<CodeSigner[]> signersReq = req;
+        final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
 
         return new Enumeration<String>() {
 
@@ -705,14 +706,14 @@
                 }
 
                 while (itor.hasNext()) {
-                    Map.Entry e = (Map.Entry) itor.next();
-                    if (signersReq.contains((CodeSigner[]) e.getValue())) {
-                        name = (String) e.getKey();
+                    Map.Entry<String, CodeSigner[]> e = itor.next();
+                    if (signersReq.contains(e.getValue())) {
+                        name = e.getKey();
                         return true;
                     }
                 }
                 while (enum2.hasMoreElements()) {
-                    name = (String) enum2.nextElement();
+                    name = enum2.nextElement();
                     return true;
                 }
                 return false;
@@ -733,13 +734,13 @@
      * Like entries() but screens out internal JAR mechanism entries
      * and includes signed entries with no ZIP data.
      */
-    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration e) {
-        final Map map = new HashMap();
+    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
+        final Map<String, CodeSigner[]> map = new HashMap<>();
         map.putAll(signerMap());
-        final Enumeration enum_ = e;
+        final Enumeration<? extends ZipEntry> enum_ = e;
         return new Enumeration<JarEntry>() {
 
-            Enumeration signers = null;
+            Enumeration<String> signers = null;
             JarEntry entry;
 
             public boolean hasMoreElements() {
@@ -747,7 +748,7 @@
                     return true;
                 }
                 while (enum_.hasMoreElements()) {
-                    ZipEntry ze = (ZipEntry) enum_.nextElement();
+                    ZipEntry ze = enum_.nextElement();
                     if (JarVerifier.isSigningRelated(ze.getName())) {
                         continue;
                     }
@@ -758,7 +759,7 @@
                     signers = Collections.enumeration(map.keySet());
                 }
                 while (signers.hasMoreElements()) {
-                    String name = (String) signers.nextElement();
+                    String name = signers.nextElement();
                     entry = jar.newEntry(new ZipEntry(name));
                     return true;
                 }
@@ -778,7 +779,7 @@
             }
         };
     }
-    private Enumeration emptyEnumeration = new Enumeration<String>() {
+    private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
 
         public boolean hasMoreElements() {
             return false;
@@ -795,8 +796,8 @@
     }
 
     private Enumeration<String> unsignedEntryNames(JarFile jar) {
-        final Map map = signerMap();
-        final Enumeration entries = jar.entries();
+        final Map<String, CodeSigner[]> map = signerMap();
+        final Enumeration<JarEntry> entries = jar.entries();
         return new Enumeration<String>() {
 
             String name;
@@ -811,7 +812,7 @@
                 }
                 while (entries.hasMoreElements()) {
                     String value;
-                    ZipEntry e = (ZipEntry) entries.nextElement();
+                    ZipEntry e = entries.nextElement();
                     value = e.getName();
                     if (e.isDirectory() || isSigningRelated(value)) {
                         continue;
@@ -834,14 +835,14 @@
             }
         };
     }
-    private List jarCodeSigners;
+    private List<CodeSigner[]> jarCodeSigners;
 
-    private synchronized List getJarCodeSigners() {
+    private synchronized List<CodeSigner[]> getJarCodeSigners() {
         CodeSigner[] signers;
         if (jarCodeSigners == null) {
-            HashSet set = new HashSet();
+            HashSet<CodeSigner[]> set = new HashSet<>();
             set.addAll(signerMap().values());
-            jarCodeSigners = new ArrayList();
+            jarCodeSigners = new ArrayList<>();
             jarCodeSigners.addAll(set);
         }
         return jarCodeSigners;
@@ -856,7 +857,7 @@
     public CodeSource getCodeSource(URL url, String name) {
         CodeSigner[] signers;
 
-        signers = (CodeSigner[]) signerMap().get(name);
+        signers = signerMap().get(name);
         return mapSignersToCodeSource(url, signers);
     }
 
--- a/src/share/classes/java/util/zip/ZipFile.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/java/util/zip/ZipFile.java	Thu Sep 07 23:37:21 2017 -0700
@@ -86,12 +86,18 @@
 
     private static final boolean usemmap;
 
+    private static final boolean ensuretrailingslash;
+
     static {
         // A system prpperty to disable mmap use to avoid vm crash when
         // in-use zip file is accidently overwritten by others.
         String prop = sun.misc.VM.getSavedProperty("sun.zip.disableMemoryMapping");
         usemmap = (prop == null ||
                    !(prop.length() == 0 || prop.equalsIgnoreCase("true")));
+
+        // see getEntry() for details
+        prop = sun.misc.VM.getSavedProperty("jdk.util.zip.ensureTrailingSlash");
+        ensuretrailingslash = prop == null || !prop.equalsIgnoreCase("false");
     }
 
     /**
@@ -305,7 +311,16 @@
             ensureOpen();
             jzentry = getEntry(jzfile, zc.getBytes(name), true);
             if (jzentry != 0) {
-                ZipEntry ze = getZipEntry(name, jzentry);
+                // If no entry is found for the specified 'name' and
+                // the 'name' does not end with a forward slash '/',
+                // the implementation tries to find the entry with a
+                // slash '/' appended to the end of the 'name', before
+                // returning null. When such entry is found, the name
+                // that actually is found (with a slash '/' attached)
+                // is used
+                // (disabled if jdk.util.zip.ensureTrailingSlash=false)
+                ZipEntry ze = ensuretrailingslash ? getZipEntry(null, jzentry)
+                                                  : getZipEntry(name, jzentry);
                 freeEntry(jzfile, jzentry);
                 return ze;
             }
@@ -525,7 +540,9 @@
             e.name = name;
         } else {
             byte[] bname = getEntryBytes(jzentry, JZENTRY_NAME);
-            if (!zc.isUTF8() && (e.flag & EFS) != 0) {
+            if (bname == null) {
+                e.name = "";             // length 0 empty name
+            } else if (!zc.isUTF8() && (e.flag & EFS) != 0) {
                 e.name = zc.toStringUTF8(bname, bname.length);
             } else {
                 e.name = zc.toString(bname, bname.length);
--- a/src/share/classes/javax/imageio/spi/ServiceRegistry.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/javax/imageio/spi/ServiceRegistry.java	Thu Sep 07 23:37:21 2017 -0700
@@ -26,6 +26,9 @@
 package javax.imageio.spi;
 
 import java.io.File;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -690,11 +693,12 @@
 
     Class category;
 
-    // Provider Objects organized by partial oridering
-    PartiallyOrderedSet poset = new PartiallyOrderedSet();
+    // Provider Objects organized by partial ordering
+    final PartiallyOrderedSet poset = new PartiallyOrderedSet();
 
     // Class -> Provider Object of that class
-    Map<Class<?>,Object> map = new HashMap();
+    final Map<Class<?>,Object> map = new HashMap();
+    final Map<Class<?>,AccessControlContext> accMap = new HashMap<>();
 
     public SubRegistry(ServiceRegistry registry, Class category) {
         this.registry = registry;
@@ -709,6 +713,7 @@
             deregisterServiceProvider(oprovider);
         }
         map.put(provider.getClass(), provider);
+        accMap.put(provider.getClass(), AccessController.getContext());
         poset.add(provider);
         if (provider instanceof RegisterableService) {
             RegisterableService rs = (RegisterableService)provider;
@@ -728,6 +733,7 @@
 
         if (provider == oprovider) {
             map.remove(provider.getClass());
+            accMap.remove(provider.getClass());
             poset.remove(provider);
             if (provider instanceof RegisterableService) {
                 RegisterableService rs = (RegisterableService)provider;
@@ -773,11 +779,21 @@
             iter.remove();
 
             if (provider instanceof RegisterableService) {
-                RegisterableService rs = (RegisterableService)provider;
-                rs.onDeregistration(registry, category);
+                final RegisterableService rs = (RegisterableService)provider;
+                AccessControlContext acc = accMap.get(provider.getClass());
+                if (acc != null || System.getSecurityManager() == null) {
+                    AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                        @Override
+                        public Void run() {
+                            rs.onDeregistration(registry, category);
+                            return null;
+                        }
+                    }, acc);
+                }
             }
         }
         poset.clear();
+        accMap.clear();
     }
 
     public void finalize() {
--- a/src/share/classes/javax/naming/directory/BasicAttribute.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/javax/naming/directory/BasicAttribute.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -515,7 +515,7 @@
             throws java.io.IOException, ClassNotFoundException {
         s.defaultReadObject();  // read in the attrID
         int n = s.readInt();    // number of values
-        values = new Vector<>(n);
+        values = new Vector<>(Math.min(1024, n));
         while (--n >= 0) {
             values.addElement(s.readObject());
         }
--- a/src/share/classes/sun/awt/image/ImageWatched.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/awt/image/ImageWatched.java	Thu Sep 07 23:37:21 2017 -0700
@@ -29,6 +29,10 @@
 import java.awt.Image;
 import java.awt.image.ImageObserver;
 
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public abstract class ImageWatched {
     public static Link endlink = new Link();
 
@@ -85,16 +89,26 @@
         }
     }
 
+    static class AccWeakReference<T> extends WeakReference<T> {
+
+         private final AccessControlContext acc;
+
+         AccWeakReference(T ref) {
+             super(ref);
+             acc = AccessController.getContext();
+         }
+    }
+
     /*
      * Standard Link implementation to manage a Weak Reference
      * to an ImageObserver.
      */
     public static class WeakLink extends Link {
-        private WeakReference<ImageObserver> myref;
+        private final AccWeakReference<ImageObserver> myref;
         private Link next;
 
         public WeakLink(ImageObserver obs, Link next) {
-            myref = new WeakReference<ImageObserver>(obs);
+            myref = new AccWeakReference<ImageObserver>(obs);
             this.next = next;
         }
 
@@ -120,6 +134,21 @@
             return this;
         }
 
+        private static boolean update(final ImageObserver iw, AccessControlContext acc,
+                                      final Image img, final int info,
+                                      final int x, final int y, final int w, final int h) {
+
+            if (acc != null || System.getSecurityManager() != null) {
+                return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                    @Override
+                    public Boolean run() {
+                        return iw.imageUpdate(img, info, x, y, w, h);
+                    }
+                }, acc);
+            }
+            return false;
+        }
+
         public boolean newInfo(Image img, int info,
                                int x, int y, int w, int h)
         {
@@ -129,7 +158,7 @@
             if (myiw == null) {
                 // My referent is null so we must prune in a second pass.
                 ret = true;
-            } else if (myiw.imageUpdate(img, info, x, y, w, h) == false) {
+            } else if (update(myiw, myref.acc, img, info, x, y, w, h) == false) {
                 // My referent has lost interest so clear it and ask
                 // for a pruning pass to remove it later.
                 myref.clear();
--- a/src/share/classes/sun/awt/resources/awt_sv.properties	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/awt/resources/awt_sv.properties	Thu Sep 07 23:37:21 2017 -0700
@@ -71,7 +71,7 @@
 AWT.f22=F22
 AWT.f23=F23
 AWT.f24=F24
-AWT.printScreen=Print Screen
+AWT.printScreen=Sk\u00E4rmutskrift
 AWT.insert=Insert
 AWT.help=Hj\u00E4lp
 AWT.windows=Windows
--- a/src/share/classes/sun/instrument/InstrumentationImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/instrument/InstrumentationImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -136,7 +136,7 @@
     }
 
     public void
-    retransformClasses(Class<?>[] classes) {
+    retransformClasses(Class<?>... classes) {
         if (!isRetransformClassesSupported()) {
             throw new UnsupportedOperationException(
               "retransformClasses is not supported in this environment");
@@ -150,7 +150,7 @@
     }
 
     public void
-    redefineClasses(ClassDefinition[]   definitions)
+    redefineClasses(ClassDefinition...  definitions)
             throws  ClassNotFoundException {
         if (!isRedefineClassesSupported()) {
             throw new UnsupportedOperationException("redefineClasses is not supported in this environment");
@@ -321,7 +321,7 @@
 
         try {
             m = javaAgentClass.getDeclaredMethod( methodname,
-                                 new Class[] {
+                                 new Class<?>[] {
                                      String.class,
                                      java.lang.instrument.Instrumentation.class
                                  }
@@ -336,7 +336,7 @@
             // now try the declared 1-arg method
             try {
                 m = javaAgentClass.getDeclaredMethod(methodname,
-                                                 new Class[] { String.class });
+                                                 new Class<?>[] { String.class });
             } catch (NoSuchMethodException x) {
                 // ignore this exception because we'll try
                 // two arg inheritance next
@@ -347,7 +347,7 @@
             // now try the inherited 2-arg method
             try {
                 m = javaAgentClass.getMethod( methodname,
-                                 new Class[] {
+                                 new Class<?>[] {
                                      String.class,
                                      java.lang.instrument.Instrumentation.class
                                  }
@@ -363,7 +363,7 @@
             // finally try the inherited 1-arg method
             try {
                 m = javaAgentClass.getMethod(methodname,
-                                             new Class[] { String.class });
+                                             new Class<?>[] { String.class });
             } catch (NoSuchMethodException x) {
                 // none of the methods exists so we throw the
                 // first NoSuchMethodException as per 5.0
@@ -411,7 +411,7 @@
     private byte[]
     transform(  ClassLoader         loader,
                 String              classname,
-                Class               classBeingRedefined,
+                Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
                 byte[]              classfileBuffer,
                 boolean             isRetransformer) {
--- a/src/share/classes/sun/instrument/TransformerManager.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/instrument/TransformerManager.java	Thu Sep 07 23:37:21 2017 -0700
@@ -169,7 +169,7 @@
     public byte[]
     transform(  ClassLoader         loader,
                 String              classname,
-                Class               classBeingRedefined,
+                Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
                 byte[]              classfileBuffer) {
         boolean someoneTouchedTheBytecode = false;
--- a/src/share/classes/sun/launcher/resources/launcher_es.properties	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/launcher/resources/launcher_es.properties	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 java.launcher.ergo.message2  =\                  porque la ejecuci\u00F3n se est\u00E1 llevando a cabo en una m\u00E1quina de clase de servidor.\n
 
 # Translators please note do not translate the options themselves
-java.launcher.opt.footer     =\    -cp <ruta de acceso de b\u00FAsqueda de clases de los directorios y los archivos zip/jar>\n    -classpath <ruta de acceso de b\u00FAsqueda de clases de los directorios y los archivos zip/jar>\n                  Lista separada por {0} de directorios, archivos JAR\n                  y archivos ZIP para buscar archivos de clase.\n    -D<nombre>=<valor>\n                  definir una propiedad del sistema\n    -verbose:[class|gc|jni]\n                  activar la salida verbose\n    -version      imprimir la versi\u00F3n del producto y salir\n    -version:<valor>\n                  Advertencia: Esta funci\u00F3n est\u00E1 anticuada y se eliminar\u00E1\n                  en una versi\u00F3n futura.\n                  es necesario que se ejecute la versi\u00F3n especificada\n    -showversion  imprimir la versi\u00F3n del producto y continuar\n    -jre-restrict-search | -no-jre-restrict-search\n                  Advertencia: Esta funci\u00F3n est\u00E1 anticuada y se eliminar\u00E1\n                  en una versi\u00F3n futura.\n                  incluir/excluir JRE privados de usuario en la b\u00FAsqueda de versi\u00F3n\n    -? -help      imprimir este mensaje de ayuda\n    -X            imprimir la ayuda sobre las opciones que no sean est\u00E1ndar\n    -ea[:<nombre_paquete>...|:<nombre_clase>]\n    -enableassertions[:<nombre_paquete>...|:<nombre_clase>]\n                  activar afirmaciones con la granularidad especificada\n    -da[:<nombre_paquete>...|:<nombre_clase>]\n    -disableassertions[:<nombre_paquete>...|:<nombre_clase>]\n                  desactivar afirmaciones con la granularidad especificada\n    -esa | -enablesystemassertions\n                  activar afirmaciones del sistema\n    -dsa | -disablesystemassertions\n                  desactivar afirmaciones del sistema\n    -agentlib:<nombre_bib>[=<opciones>]\n                  cargar la biblioteca de agente nativa <nombre_bib>, como -agentlib:hprof\n                  v\u00E9ase tambi\u00E9n -agentlib:jdwp=help y -agentlib:hprof=help\n    -agentpath:<nombre_ruta_acceso>[=<opciones>]\n                  cargar biblioteca de agente nativa con el nombre de la ruta de acceso completa\n    -javaagent:<ruta_acceso_jar>[=<opciones>]\n                  cargar agente de lenguaje de programaci\u00F3n Java, v\u00E9ase java.lang.instrument\n    -splash:<ruta_acceso_imagen>\n                  mostrar una pantalla de presentaci\u00F3n con la imagen especificada\nConsulte http://www.oracle.com/technetwork/java/javase/documentation/index.html para obtener m\u00E1s informaci\u00F3n.
+java.launcher.opt.footer     =\    -cp <ruta de acceso de b\u00FAsqueda de clases de los directorios y los archivos zip/jar>\n    -classpath <ruta de acceso de b\u00FAsqueda de clases de los directorios y los archivos zip/jar>\n                  Lista separada por {0} de directorios, archivos JAR\n                  y archivos ZIP para buscar archivos de clase.\n    -D<nombre>=<valor>\n                  definir una propiedad del sistema\n    -verbose:[class|gc|jni]\n                  activar la salida verbose\n    -version      imprimir la versi\u00F3n del producto y salir\n    -version:<valor>\n                  Advertencia: Esta funci\u00F3n est\u00E1 anticuada y se eliminar\u00E1\n                  en una versi\u00F3n futura.\n                  es necesario que se ejecute la versi\u00F3n especificada\n    -showversion  imprimir la versi\u00F3n del producto y continuar\n    -jre-restrict-search | -no-jre-restrict-search\n                  Advertencia: Esta funci\u00F3n est\u00E1 anticuada y se eliminar\u00E1\n                  en una versi\u00F3n futura.\n                  incluir/excluir JRE privados de usuario en la b\u00FAsqueda de versi\u00F3n\n    -? -help      imprimir este mensaje de ayuda\n    -X            imprimir la ayuda sobre las opciones que no sean est\u00E1ndar\n    -ea[:<nombre paquete>...|:<nombre clase>]\n    -enableassertions[:<nombre paquete>...|:<nombre clase>]\n                  activar afirmaciones con la granularidad especificada\n    -da[:<nombre paquete>...|:<nombre clase>]\n    -disableassertions[:<nombre paquete>...|:<nombre clase>]\n                  desactivar afirmaciones con la granularidad especificada\n    -esa | -enablesystemassertions\n                  activar afirmaciones del sistema\n    -dsa | -disablesystemassertions\n                  desactivar afirmaciones del sistema\n    -agentlib:<nombre bib>[=<opciones>]\n                  cargar la biblioteca de agente nativa <nombre bib>, como -agentlib:hprof\n                  v\u00E9ase tambi\u00E9n -agentlib:jdwp=help y -agentlib:hprof=help\n    -agentpath:<nombre ruta acceso>[=<opciones>]\n                  cargar biblioteca de agente nativa con el nombre de la ruta de acceso completa\n    -javaagent:<ruta acceso jar>[=<opciones>]\n                  cargar agente de lenguaje de programaci\u00F3n Java, v\u00E9ase java.lang.instrument\n    -splash:<ruta acceso imagen>\n                  mostrar una pantalla de presentaci\u00F3n con la imagen especificada\nConsulte 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=\    -Xmixed           ejecuci\u00F3n de modo mixto (por defecto)\n    -Xint             s\u00F3lo ejecuci\u00F3n de modo interpretado\n    -Xbootclasspath:<directorios y archivos zip/jar separados por {0}>\n                      definir la ruta de acceso de b\u00FAsqueda para los recursos y clases de inicializaci\u00F3n de datos\n    -Xbootclasspath/a:<directorios y archivos zip/jar separados por {0}>\n                      agregar al final de la ruta de acceso de la clase de inicializaci\u00F3n de datos\n    -Xbootclasspath/p:<directorios y archivos zip/jar separados por {0}>\n                      anteponer a la ruta de acceso de la clase de inicializaci\u00F3n de datos\n    -Xdiag            mostrar mensajes de diagn\u00F3stico adicionales\n    -Xnoclassgc       desactivar la recolecci\u00F3n de basura de clases\n    -Xincgc           activar la recolecci\u00F3n de basura de clases\n    -Xloggc:<archivo> registrar el estado de GC en un archivo con registros de hora\n    -Xbatch           desactivar compilaci\u00F3n en segundo plano\n    -Xms<tama\u00F1o>      definir tama\u00F1o de pila Java inicial\n    -Xmx<tama\u00F1o>      definir tama\u00F1o de pila Java m\u00E1ximo\n    -Xss<tama\u00F1o>      definir tama\u00F1o de la pila del thread de Java\n    -Xprof            datos de salida de creaci\u00F3n de perfil de CPU\n    -Xfuture          activar las comprobaciones m\u00E1s estrictas, anticip\u00E1ndose al futuro valor por defecto\n    -Xrs              reducir el uso de se\u00F1ales de sistema operativo por parte de Java/VM (consulte la documentaci\u00F3n)\n    -Xcheck:jni       realizar comprobaciones adicionales para las funciones de JNI\n    -Xshare:off       no intentar usar datos de clase compartidos\n    -Xshare:auto      usar datos de clase compartidos si es posible (valor por defecto)\n    -Xshare:on        es obligatorio el uso de datos de clase compartidos, de lo contrario se emitir\u00E1 un fallo.\n    -XshowSettings    mostrar todos los valores y continuar\n    -XshowSettings:all\n                      mostrar todos los valores y continuar\n    -XshowSettings:vm mostrar todos los valores de la VM y continuar\n    -XshowSettings:properties\n                      mostrar todos los valores de las propiedades y continuar\n    -XshowSettings:locale\n                      mostrar todos los valores relacionados con la configuraci\u00F3n regional y continuar\n\nLas opciones -X no son est\u00E1ndar, por lo que podr\u00EDan cambiarse sin previo aviso.\n
--- a/src/share/classes/sun/launcher/resources/launcher_sv.properties	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/launcher/resources/launcher_sv.properties	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 java.launcher.opt.footer     =\    -cp <class search path of directories and zip/jar files>\n    -classpath <class search path of directories and zip/jar files>\n                  En lista \u00F6ver kataloger, JAR-arkiv och och ZIP-arkiv\n                  f\u00F6r s\u00F6kning efter klassfiler avgr\u00E4nsad med {0}.\n    -D<name>=<value>\n                  ange en systemegenskap\n    -verbose:[class|gc|jni]\n                  aktivera utf\u00F6rliga utdata\n    -version      skriv ut produktversion och avsluta\n    -version:<value>\n                  Varning: den h\u00E4r funktionen \u00E4r inaktuell och kommer\n                  att tas bort i en framtida utg\u00E5va.\n                  kr\u00E4v den angivna versionen f\u00F6r att k\u00F6ra\n    -showversion  skriv ut produktversion och forts\u00E4tt\n    -jre-restrict-search | -no-jre-restrict-search\n                  Varning: den h\u00E4r funktionen \u00E4r inaktuell och kommer\n                  att tas bort i en framtida utg\u00E5va.\n                  inkludera/exkludera anv\u00E4ndarprivata JRE:er i versionss\u00F6kningen\n    -? -help      skriv ut det h\u00E4r hj\u00E4lpmeddelandet\n    -X            skriv ut hj\u00E4lp f\u00F6r icke-standardalternativ\n    -ea[:<packagename>...|:<classname>]\n    -enableassertions[:<packagename>...|:<classname>]\n                  aktivera verifieringar med den angivna detaljgraden\n    -da[:<packagename>...|:<classname>]\n    -disableassertions[:<packagename>...|:<classname>]\n                  avaktivera verifieringar med den angivna detaljgraden\n    -esa | -enablesystemassertions\n                  aktivera systemverifieringar\n    -dsa | -disablesystemassertions\n                  avaktivera systemverifieringar\n    -agentlib:<libname>[=<options>]\n                  ladda det ursprungliga agentbiblioteket <libname>, t.ex. -agentlib:hprof\n                  se \u00E4ven -agentlib:jdwp=help och -agentlib:hprof=help\n    -agentpath:<pathname>[=<options>]\n                  ladda det ursprungliga agentbiblioteket med det fullst\u00E4ndiga s\u00F6kv\u00E4gsnamnet\n    -javaagent:<jarpath>[=<options>]\n                  ladda agenten f\u00F6r programmeringsspr\u00E5ket Java, se java.lang.instrument\n    -splash:<imagepath>\n                  visa v\u00E4lkomstsk\u00E4rmen med den angivna bilden\nMer information finns p\u00E5 http://www.oracle.com/technetwork/java/javase/documentation/index.html.
 
 # Translators please note do not translate the options themselves
-java.launcher.X.usage=\    -Xmixed           k\u00F6rning i blandat l\u00E4ge (standard)\n    -Xint             endast k\u00F6rning i tolkat l\u00E4ge\n    -Xbootclasspath:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      ange s\u00F6kv\u00E4g f\u00F6r programladdningsklasser och -resurser\n    -Xbootclasspath/a:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      l\u00E4gg till i slutet av programladdningsklassens s\u00F6kv\u00E4g\n    -Xbootclasspath/p:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      l\u00E4gg till i b\u00F6rjan av programladdningsklassens s\u00F6kv\u00E4g\n    -Xdiag            visa ytterligare diagnostiska meddelanden\n    -Xnoclassgc       avaktivera klassens skr\u00E4pinsamling\n    -Xincgc           aktivera inkrementell skr\u00E4pinsamling\n    -Xloggc:<fil>    logga GC-status till en fil med tidsst\u00E4mplar\n    -Xbatch           avaktivera bakgrundskompilering\n    -Xms<storlek>        ange ursprunglig storlek f\u00F6r Java-heap\n    -Xmx<storlek>        ange maximal storlek f\u00F6r Java-heap\n    -Xss<storlek>        ange storlek f\u00F6r java-tr\u00E5dsstack\n    -Xprof            utdata f\u00F6r processorprofilering\n    -Xfuture          aktivera str\u00E4ngaste kontroller, f\u00F6rv\u00E4ntad framtida standard\n    -Xrs              minska OS-signalanv\u00E4ndning av Java/VM (se dokumentation)\n    -Xcheck:jni       utf\u00F6r ytterligare kontroller f\u00F6r JNI-funktioner\n    -Xshare:off       anv\u00E4nd inte delade klassdata\n    -Xshare:auto      anv\u00E4nd delade klassdata om det g\u00E5r (standard)\n    -Xshare:on        kr\u00E4v att delade klassdata anv\u00E4nds, annars slutf\u00F6r inte.\n    -XshowSettings    visa alla inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:all\n                      visa alla inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:vm visa alla vm-relaterade inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:properties\n                      visa alla egenskapsinst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:locale\n                      visa alla spr\u00E5krelaterade inst\u00E4llningar och forts\u00E4tt\n\n-X-alternativen \u00E4r inte standard och kan \u00E4ndras utan f\u00F6reg\u00E5ende meddelande.\n
+java.launcher.X.usage=\    -Xmixed           exekvering i blandat l\u00E4ge (standard)\n    -Xint             endast exekvering i tolkat l\u00E4ge\n    -Xbootclasspath:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      ange s\u00F6kv\u00E4g f\u00F6r programladdningsklasser och -resurser\n    -Xbootclasspath/a:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      l\u00E4gg till i slutet av programladdningsklassens s\u00F6kv\u00E4g\n    -Xbootclasspath/p:<kataloger och zip-/jar-filer avgr\u00E4nsas med {0}>\n                      l\u00E4gg till i b\u00F6rjan av programladdningsklassens s\u00F6kv\u00E4g\n    -Xdiag            visa ytterligare diagnostiska meddelanden\n    -Xnoclassgc       avaktivera klassens skr\u00E4pinsamling\n    -Xincgc           aktivera inkrementell skr\u00E4pinsamling\n    -Xloggc:<fil>    logga GC-status till en fil med tidsst\u00E4mplar\n    -Xbatch           avaktivera bakgrundskompilering\n    -Xms<storlek>        ange ursprunglig storlek f\u00F6r Java-heap\n    -Xmx<storlek>        ange maximal storlek f\u00F6r Java-heap\n    -Xss<storlek>        ange storlek f\u00F6r java-tr\u00E5dsstack\n    -Xprof            utdata f\u00F6r processorprofilering\n    -Xfuture          aktivera str\u00E4ngaste kontroller, f\u00F6rv\u00E4ntad framtida standard\n    -Xrs              minska OS-signalanv\u00E4ndning av Java/VM (se dokumentation)\n    -Xcheck:jni       utf\u00F6r ytterligare kontroller f\u00F6r JNI-funktioner\n    -Xshare:off       anv\u00E4nd inte delade klassdata\n    -Xshare:auto      anv\u00E4nd delade klassdata om det g\u00E5r (standard)\n    -Xshare:on        kr\u00E4v att delade klassdata anv\u00E4nds, annars slutf\u00F6r inte.\n    -XshowSettings    visa alla inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:all\n                      visa alla inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:vm visa alla vm-relaterade inst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:properties\n                      visa alla egenskapsinst\u00E4llningar och forts\u00E4tt\n    -XshowSettings:locale\n                      visa alla spr\u00E5krelaterade inst\u00E4llningar och forts\u00E4tt\n\n-X-alternativen \u00E4r inte standard 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 specifika f\u00F6r Mac OS X:\n    -XstartOnFirstThread\n                      k\u00F6r huvudmetoden() p\u00E5 den f\u00F6rsta (AppKit) tr\u00E5den\n    -Xdock:name=<application name>"\n                      \u00E5sidosatt standardapplikationsnamn visas i docka\n    -Xdock:icon=<path to icon file>\n                      \u00E5sidosatt standardikon visas i docka\n\n
--- a/src/share/classes/sun/management/Agent.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/Agent.java	Thu Sep 07 23:37:21 2017 -0700
@@ -383,11 +383,8 @@
                     adaptorClass.getMethod("initialize",
                         String.class, Properties.class);
             initializeMethod.invoke(null,snmpPort,props);
-        } catch (ClassNotFoundException x) {
-            // The SNMP packages are not present: throws an exception.
-            throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
-        } catch (NoSuchMethodException x) {
-            // should not happen...
+        } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) {
+            // snmp runtime doesn't exist - initialization fails
             throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
         } catch (InvocationTargetException x) {
             final Throwable cause = x.getCause();
@@ -397,9 +394,6 @@
                 throw (Error) cause;
             // should not happen...
             throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause);
-        } catch (IllegalAccessException x) {
-            // should not happen...
-            throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
         }
     }
 
@@ -440,8 +434,8 @@
                 } catch (IOException e) {
                     error(CONFIG_FILE_CLOSE_FAILED, fname);
                 }
-            }
-        }
+             }
+         }
     }
 
     public static void startAgent() throws Exception {
@@ -476,7 +470,7 @@
                 // invoke the premain(String args) method
                 Class<?> clz = ClassLoader.getSystemClassLoader().loadClass(cname);
                 Method premain = clz.getMethod("premain",
-                                               new Class[] { String.class });
+                                               new Class<?>[] { String.class });
                 premain.invoke(null, /* static */
                                new Object[] { args });
             } catch (ClassNotFoundException ex) {
--- a/src/share/classes/sun/management/ConnectorAddressLink.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/ConnectorAddressLink.java	Thu Sep 07 23:37:21 2017 -0700
@@ -117,11 +117,11 @@
         } catch (IllegalArgumentException iae) {
             throw new IOException(iae.getMessage());
         }
-        List counters =
+        List<Counter> counters =
                 new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
-        Iterator i = counters.iterator();
+        Iterator<Counter> i = counters.iterator();
         if (i.hasNext()) {
-            Counter c = (Counter) i.next();
+            Counter c = i.next();
             return (String) c.getValue();
         } else {
             return null;
@@ -167,13 +167,13 @@
         } catch (IllegalArgumentException iae) {
             throw new IOException(iae.getMessage());
         }
-        List counters = new PerfInstrumentation(bb).getAllCounters();
-        Map<String, String> properties = new HashMap<String, String>();
-        for (Object c : counters) {
-            String name = ((Counter) c).getName();
+        List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
+        Map<String, String> properties = new HashMap<>();
+        for (Counter c : counters) {
+            String name =  c.getName();
             if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                     !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
-                properties.put(name, ((Counter) c).getValue().toString());
+                properties.put(name, c.getValue().toString());
             }
         }
         return properties;
--- a/src/share/classes/sun/management/Flag.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/Flag.java	Thu Sep 07 23:37:21 2017 -0700
@@ -91,7 +91,7 @@
         Flag[] flags = new Flag[numFlags];
         int count = getFlags(names, flags, numFlags);
 
-        List<Flag> result = new ArrayList<Flag>();
+        List<Flag> result = new ArrayList<>();
         for (Flag f : flags) {
             if (f != null) {
                 result.add(f);
--- a/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java	Thu Sep 07 23:37:21 2017 -0700
@@ -69,11 +69,7 @@
                         Field f = cl.getDeclaredField("builder");
                         f.setAccessible(true);
                         return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo());
-                    } catch(ClassNotFoundException e) {
-                        return null;
-                    } catch(NoSuchFieldException e) {
-                        return null;
-                    } catch(IllegalAccessException e) {
+                    } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
                         return null;
                     }
                 }
@@ -82,7 +78,7 @@
         synchronized(compositeTypeByBuilder) {
             gict = compositeTypeByBuilder.get(builder);
             if(gict == null) {
-                OpenType[] gcNotifInfoItemTypes = new OpenType[] {
+                OpenType<?>[] gcNotifInfoItemTypes = new OpenType<?>[] {
                     SimpleType.STRING,
                     SimpleType.STRING,
                     SimpleType.STRING,
@@ -141,7 +137,7 @@
         GC_INFO
     };
     private static HashMap<GcInfoBuilder,CompositeType> compositeTypeByBuilder =
-        new HashMap<GcInfoBuilder,CompositeType>();
+        new HashMap<>();
 
     public static String getGcName(CompositeData cd) {
         String gcname = getString(cd, GC_NAME);
@@ -195,7 +191,7 @@
     private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
         if (baseGcNotifInfoCompositeType == null) {
             try {
-                OpenType[] baseGcNotifInfoItemTypes = new OpenType[] {
+                OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                     SimpleType.STRING,
                     SimpleType.STRING,
                     SimpleType.STRING,
--- a/src/share/classes/sun/management/GarbageCollectorImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/GarbageCollectorImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,14 +70,11 @@
     private String[] poolNames = null;
     synchronized String[] getAllPoolNames() {
         if (poolNames == null) {
-            List pools = ManagementFactory.getMemoryPoolMXBeans();
+            List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
             poolNames = new String[pools.size()];
             int i = 0;
-            for (ListIterator iter = pools.listIterator();
-                 iter.hasNext();
-                 i++) {
-                MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
-                poolNames[i] = p.getName();
+            for (MemoryPoolMXBean m : pools) {
+                poolNames[i++] = m.getName();
             }
         }
         return poolNames;
--- a/src/share/classes/sun/management/GcInfoBuilder.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/GcInfoBuilder.java	Thu Sep 07 23:37:21 2017 -0700
@@ -104,7 +104,7 @@
         int itemCount = numGcInfoItems + gcExtItemCount;
         allItemNames = new String[itemCount];
         String[] allItemDescs = new String[itemCount];
-        OpenType[] allItemTypes = new OpenType[itemCount];
+        OpenType<?>[] allItemTypes = new OpenType<?>[itemCount];
 
         System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
         System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
--- a/src/share/classes/sun/management/GcInfoCompositeData.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/GcInfoCompositeData.java	Thu Sep 07 23:37:21 2017 -0700
@@ -76,11 +76,7 @@
                                 Field f = cl.getDeclaredField("builder");
                                 f.setAccessible(true);
                                 return (GcInfoBuilder)f.get(info);
-                            } catch(ClassNotFoundException e) {
-                                return null;
-                            } catch(NoSuchFieldException e) {
-                                return null;
-                            } catch(IllegalAccessException e) {
+                            } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
                                 return null;
                             }
                         }
@@ -92,11 +88,7 @@
                                 Field f = cl.getDeclaredField("extAttributes");
                                 f.setAccessible(true);
                                 return (Object[])f.get(info);
-                            } catch(ClassNotFoundException e) {
-                                return null;
-                            } catch(NoSuchFieldException e) {
-                                return null;
-                            } catch(IllegalAccessException e) {
+                            } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
                                 return null;
                             }
                         }
@@ -180,10 +172,7 @@
             Method m = GcInfo.class.getMethod("getMemoryUsageBeforeGc");
             memoryUsageMapType =
                 MappedMXBeanType.getMappedType(m.getGenericReturnType());
-        } catch (NoSuchMethodException e) {
-            // Should never reach here
-            throw new AssertionError(e);
-        } catch (OpenDataException e) {
+        } catch (NoSuchMethodException | OpenDataException e) {
             // Should never reach here
             throw new AssertionError(e);
         }
@@ -197,7 +186,7 @@
     static synchronized OpenType[] getBaseGcInfoItemTypes() {
         if (baseGcInfoItemTypes == null) {
             OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
-            baseGcInfoItemTypes = new OpenType[] {
+            baseGcInfoItemTypes = new OpenType<?>[] {
                 SimpleType.LONG,
                 SimpleType.LONG,
                 SimpleType.LONG,
@@ -225,10 +214,7 @@
         try {
             TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
             return cast(memoryUsageMapType.toJavaTypeData(td));
-        } catch (InvalidObjectException e) {
-            // Should never reach here
-            throw new AssertionError(e);
-        } catch (OpenDataException e) {
+        } catch (InvalidObjectException | OpenDataException e) {
             // Should never reach here
             throw new AssertionError(e);
         }
@@ -244,10 +230,7 @@
             TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
             //return (Map<String,MemoryUsage>)
             return cast(memoryUsageMapType.toJavaTypeData(td));
-        } catch (InvalidObjectException e) {
-            // Should never reach here
-            throw new AssertionError(e);
-        } catch (OpenDataException e) {
+        } catch (InvalidObjectException | OpenDataException e) {
             // Should never reach here
             throw new AssertionError(e);
         }
--- a/src/share/classes/sun/management/HotSpotDiagnostic.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/HotSpotDiagnostic.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
 
 import com.sun.management.HotSpotDiagnosticMXBean;
 import com.sun.management.VMOption;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * Implementation of the diagnostic MBean for Hotspot VM.
@@ -41,6 +43,19 @@
     }
 
     public void dumpHeap(String outputFile, boolean live) throws IOException {
+
+        final String propertyName = "jdk.management.heapdump.allowAnyFileSuffix";
+        PrivilegedAction<Boolean> pa = new PrivilegedAction<Boolean>() {
+            @Override
+            public Boolean run() {
+                return Boolean.parseBoolean(System.getProperty(propertyName, "false"));
+            }
+        };
+        boolean allowAnyFileSuffix = AccessController.doPrivileged(pa);
+        if (!allowAnyFileSuffix && !outputFile.endsWith(".hprof")) {
+            throw new IllegalArgumentException("heapdump file must have .hprof extention");
+        }
+
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkWrite(outputFile);
@@ -54,7 +69,7 @@
 
     public List<VMOption> getDiagnosticOptions() {
         List<Flag> allFlags = Flag.getAllFlags();
-        List<VMOption> result = new ArrayList<VMOption>();
+        List<VMOption> result = new ArrayList<>();
         for (Flag flag : allFlags) {
             if (flag.isWriteable() && flag.isExternal()) {
                 result.add(flag.getVMOption());
--- a/src/share/classes/sun/management/HotspotCompilation.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/HotspotCompilation.java	Thu Sep 07 23:37:21 2017 -0700
@@ -120,13 +120,13 @@
         // current implementation.  We first look up in the SUN_CI namespace
         // since most counters are in SUN_CI namespace.
 
-        if ((c = (Counter) counters.get(SUN_CI + name)) != null) {
+        if ((c = counters.get(SUN_CI + name)) != null) {
             return c;
         }
-        if ((c = (Counter) counters.get(COM_SUN_CI + name)) != null) {
+        if ((c = counters.get(COM_SUN_CI + name)) != null) {
             return c;
         }
-        if ((c = (Counter) counters.get(JAVA_CI + name)) != null) {
+        if ((c = counters.get(JAVA_CI + name)) != null) {
             return c;
         }
 
@@ -136,10 +136,8 @@
 
     private void initCompilerCounters() {
         // Build a tree map of the current list of performance counters
-        ListIterator iter = getInternalCompilerCounters().listIterator();
-        counters = new TreeMap<String, Counter>();
-        while (iter.hasNext()) {
-            Counter c = (Counter) iter.next();
+        counters = new TreeMap<>();
+        for (Counter c: getInternalCompilerCounters()) {
             counters.put(c.getName(), c);
         }
 
@@ -200,7 +198,7 @@
     }
 
     public java.util.List<CompilerThreadStat> getCompilerThreadStats() {
-        List<CompilerThreadStat> list = new ArrayList<CompilerThreadStat>(threads.length);
+        List<CompilerThreadStat> list = new ArrayList<>(threads.length);
         int i = 0;
         if (threads[0] == null) {
             // no adaptor thread
--- a/src/share/classes/sun/management/HotspotThread.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/HotspotThread.java	Thu Sep 07 23:37:21 2017 -0700
@@ -58,7 +58,7 @@
         String[] names = new String[count];
         long[] times = new long[count];
         int numThreads = getInternalThreadTimes0(names, times);
-        Map<String, Long> result = new HashMap<String, Long>(numThreads);
+        Map<String, Long> result = new HashMap<>(numThreads);
         for (int i = 0; i < numThreads; i++) {
             result.put(names[i], new Long(times[i]));
         }
--- a/src/share/classes/sun/management/LazyCompositeData.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/LazyCompositeData.java	Thu Sep 07 23:37:21 2017 -0700
@@ -27,6 +27,7 @@
 
 import java.io.Serializable;
 import java.util.*;
+import javax.management.openmbean.ArrayType;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenType;
@@ -48,40 +49,49 @@
     private CompositeData compositeData;
 
     // Implementation of the CompositeData interface
+    @Override
     public boolean containsKey(String key) {
         return compositeData().containsKey(key);
     }
 
+    @Override
     public boolean containsValue(Object value) {
         return compositeData().containsValue(value);
     }
 
+    @Override
     public boolean equals(Object obj) {
         return compositeData().equals(obj);
     }
 
+    @Override
     public Object get(String key) {
         return compositeData().get(key);
     }
 
+    @Override
     public Object[] getAll(String[] keys) {
         return compositeData().getAll(keys);
     }
 
+    @Override
     public CompositeType getCompositeType() {
         return compositeData().getCompositeType();
     }
 
+    @Override
     public int hashCode() {
         return compositeData().hashCode();
     }
 
+    @Override
     public String toString() {
         /** FIXME: What should this be?? */
         return compositeData().toString();
     }
 
-    public Collection values() {
+    @Override
+    public Collection<?> values() {
         return compositeData().values();
     }
 
@@ -126,54 +136,45 @@
         if (cd == null)
             throw new IllegalArgumentException("Null CompositeData");
 
-        return ((Boolean) cd.get(itemName)).booleanValue();
+        return ((Boolean) cd.get(itemName));
     }
 
     static long getLong(CompositeData cd, String itemName) {
         if (cd == null)
             throw new IllegalArgumentException("Null CompositeData");
 
-        return ((Long) cd.get(itemName)).longValue();
+        return ((Long) cd.get(itemName));
     }
 
     static int getInt(CompositeData cd, String itemName) {
         if (cd == null)
             throw new IllegalArgumentException("Null CompositeData");
 
-        return ((Integer) cd.get(itemName)).intValue();
+        return ((Integer) cd.get(itemName));
     }
 
     /**
      * Compares two CompositeTypes and returns true if
      * all items in type1 exist in type2 and their item types
      * are the same.
+     * @param type1 the base composite type
+     * @param type2 the checked composite type
+     * @return {@code true} if all items in type1 exist in type2 and their item
+     *         types are the same.
      */
     protected static boolean isTypeMatched(CompositeType type1, CompositeType type2) {
         if (type1 == type2) return true;
 
         // We can't use CompositeType.isValue() since it returns false
         // if the type name doesn't match.
-        Set allItems = type1.keySet();
+        Set<String> allItems = type1.keySet();
 
         // Check all items in the type1 exist in type2
         if (!type2.keySet().containsAll(allItems))
             return false;
 
-        for (Iterator iter = allItems.iterator(); iter.hasNext(); ) {
-            String item = (String) iter.next();
-            OpenType ot1 = type1.getType(item);
-            OpenType ot2 = type2.getType(item);
-            if (ot1 instanceof CompositeType) {
-                if (! (ot2 instanceof CompositeType))
-                    return false;
-                if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
-                    return false;
-            } else if (ot1 instanceof TabularType) {
-                if (! (ot2 instanceof TabularType))
-                    return false;
-                if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
-                    return false;
-            } else if (!ot1.equals(ot2)) {
+        for (String item: allItems) {
+            if (!isTypeMatched(type1.getType(item), type2.getType(item))) {
                 return false;
             }
         }
@@ -183,8 +184,8 @@
     protected static boolean isTypeMatched(TabularType type1, TabularType type2) {
         if (type1 == type2) return true;
 
-        List list1 = type1.getIndexNames();
-        List list2 = type2.getIndexNames();
+        List<String> list1 = type1.getIndexNames();
+        List<String> list2 = type2.getIndexNames();
 
         // check if the list of index names are the same
         if (!list1.equals(list2))
@@ -193,5 +194,41 @@
         return isTypeMatched(type1.getRowType(), type2.getRowType());
     }
 
+    protected static boolean isTypeMatched(ArrayType<?> type1, ArrayType<?> type2) {
+        if (type1 == type2) return true;
+
+        int dim1 = type1.getDimension();
+        int dim2 = type2.getDimension();
+
+        // check if the array dimensions are the same
+        if (dim1 != dim2)
+            return false;
+
+        return isTypeMatched(type1.getElementOpenType(), type2.getElementOpenType());
+    }
+
+    private static boolean isTypeMatched(OpenType<?> ot1, OpenType<?> ot2) {
+        if (ot1 instanceof CompositeType) {
+            if (! (ot2 instanceof CompositeType))
+                return false;
+            if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
+                return false;
+        } else if (ot1 instanceof TabularType) {
+            if (! (ot2 instanceof TabularType))
+                return false;
+            if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
+                return false;
+        } else if (ot1 instanceof ArrayType) {
+            if (! (ot2 instanceof ArrayType))
+                return false;
+            if (!isTypeMatched((ArrayType<?>) ot1, (ArrayType<?>) ot2)) {
+                return false;
+            }
+        } else if (!ot1.equals(ot2)) {
+            return false;
+        }
+        return true;
+    }
+
     private static final long serialVersionUID = -2190411934472666714L;
 }
--- a/src/share/classes/sun/management/ManagementFactoryHelper.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/ManagementFactoryHelper.java	Thu Sep 07 23:37:21 2017 -0700
@@ -110,7 +110,7 @@
 
     public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
         MemoryPoolMXBean[] pools = MemoryImpl.getMemoryPools();
-        List<MemoryPoolMXBean> list = new ArrayList<MemoryPoolMXBean>(pools.length);
+        List<MemoryPoolMXBean> list = new ArrayList<>(pools.length);
         for (MemoryPoolMXBean p : pools) {
             list.add(p);
         }
@@ -119,7 +119,7 @@
 
     public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
         MemoryManagerMXBean[]  mgrs = MemoryImpl.getMemoryManagers();
-        List<MemoryManagerMXBean> result = new ArrayList<MemoryManagerMXBean>(mgrs.length);
+        List<MemoryManagerMXBean> result = new ArrayList<>(mgrs.length);
         for (MemoryManagerMXBean m : mgrs) {
             result.add(m);
         }
@@ -128,7 +128,7 @@
 
     public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
         MemoryManagerMXBean[]  mgrs = MemoryImpl.getMemoryManagers();
-        List<GarbageCollectorMXBean> result = new ArrayList<GarbageCollectorMXBean>(mgrs.length);
+        List<GarbageCollectorMXBean> result = new ArrayList<>(mgrs.length);
         for (MemoryManagerMXBean m : mgrs) {
             if (GarbageCollectorMXBean.class.isInstance(m)) {
                  result.add(GarbageCollectorMXBean.class.cast(m));
--- a/src/share/classes/sun/management/MappedMXBeanType.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/MappedMXBeanType.java	Thu Sep 07 23:37:21 2017 -0700
@@ -62,18 +62,18 @@
 @SuppressWarnings("unchecked")
 public abstract class MappedMXBeanType {
     private static final WeakHashMap<Type,MappedMXBeanType> convertedTypes =
-        new WeakHashMap<Type,MappedMXBeanType>();
+        new WeakHashMap<>();
 
     boolean  isBasicType = false;
-    OpenType openType = inProgress;
-    Class    mappedTypeClass;
+    OpenType<?> openType = inProgress;
+    Class<?>    mappedTypeClass;
 
     static synchronized MappedMXBeanType newMappedType(Type javaType)
             throws OpenDataException {
 
         MappedMXBeanType mt = null;
         if (javaType instanceof Class) {
-            final Class c = (Class) javaType;
+            final Class<?> c = (Class<?>) javaType;
             if (c.isEnum()) {
                 mt = new EnumMXBeanType(c);
             } else if (c.isArray()) {
@@ -85,7 +85,7 @@
             final ParameterizedType pt = (ParameterizedType) javaType;
             final Type rawType = pt.getRawType();
             if (rawType instanceof Class) {
-                final Class rc = (Class) rawType;
+                final Class<?> rc = (Class<?>) rawType;
                 if (rc == List.class) {
                     mt = new ListMXBeanType(pt);
                 } else if (rc == Map.class) {
@@ -106,7 +106,7 @@
     }
 
     // basic types do not require data mapping
-    static synchronized MappedMXBeanType newBasicType(Class c, OpenType ot)
+    static synchronized MappedMXBeanType newBasicType(Class<?> c, OpenType<?> ot)
             throws OpenDataException {
         MappedMXBeanType mt = new BasicMXBeanType(c, ot);
         convertedTypes.put(c, mt);
@@ -127,7 +127,7 @@
     }
 
     // Convert a class to an OpenType
-    public static synchronized OpenType toOpenType(Type t)
+    public static synchronized OpenType<?> toOpenType(Type t)
             throws OpenDataException {
         MappedMXBeanType mt = getMappedType(t);
         return mt.getOpenType();
@@ -152,7 +152,7 @@
     }
 
     // Return the mapped open type
-    OpenType getOpenType() {
+    OpenType<?> getOpenType() {
         return openType;
     }
 
@@ -168,7 +168,7 @@
     }
 
     // Return the mapped open type
-    Class getMappedTypeClass() {
+    Class<?> getMappedTypeClass() {
         return mappedTypeClass;
     }
 
@@ -192,8 +192,8 @@
     //   T <-> T (no conversion)
     //
     static class BasicMXBeanType extends MappedMXBeanType {
-        final Class basicType;
-        BasicMXBeanType(Class c, OpenType openType) {
+        final Class<?> basicType;
+        BasicMXBeanType(Class<?> c, OpenType<?> openType) {
             this.basicType = c;
             this.openType = openType;
             this.mappedTypeClass = c;
@@ -228,7 +228,7 @@
     //
     static class EnumMXBeanType extends MappedMXBeanType {
         final Class enumClass;
-        EnumMXBeanType(Class c) {
+        EnumMXBeanType(Class<?> c) {
             this.enumClass = c;
             this.openType = STRING;
             this.mappedTypeClass = String.class;
@@ -269,16 +269,16 @@
     //   E[] <-> openTypeData(E)[]
     //
     static class ArrayMXBeanType extends MappedMXBeanType {
-        final Class arrayClass;
+        final Class<?> arrayClass;
         protected MappedMXBeanType componentType;
         protected MappedMXBeanType baseElementType;
 
-        ArrayMXBeanType(Class c) throws OpenDataException {
+        ArrayMXBeanType(Class<?> c) throws OpenDataException {
             this.arrayClass = c;
             this.componentType = getMappedType(c.getComponentType());
 
             StringBuilder className = new StringBuilder();
-            Class et = c;
+            Class<?> et = c;
             int dim;
             for (dim = 0; et.isArray(); dim++) {
                 className.append('[');
@@ -299,7 +299,7 @@
                 throw ode;
             }
 
-            openType = new ArrayType(dim, baseElementType.getOpenType());
+            openType = new ArrayType<>(dim, baseElementType.getOpenType());
         }
 
         protected ArrayMXBeanType() {
@@ -395,7 +395,7 @@
                 throw ode;
             }
 
-            openType = new ArrayType(dim, baseElementType.getOpenType());
+            openType = new ArrayType<>(dim, baseElementType.getOpenType());
         }
 
         Type getJavaType() {
@@ -428,7 +428,7 @@
                 throw new OpenDataException("Element Type for " + pt +
                    " not supported");
             }
-            final Class et = (Class) argTypes[0];
+            final Class<?> et = (Class<?>) argTypes[0];
             if (et.isArray()) {
                 throw new OpenDataException("Element Type for " + pt +
                    " not supported");
@@ -445,7 +445,7 @@
                 ode.initCause(e);
                 throw ode;
             }
-            openType = new ArrayType(1, paramType.getOpenType());
+            openType = new ArrayType<>(1, paramType.getOpenType());
         }
 
         Type getJavaType() {
@@ -473,7 +473,7 @@
             throws OpenDataException, InvalidObjectException {
 
             final Object[] openArray = (Object[]) data;
-            List<Object> result = new ArrayList<Object>(openArray.length);
+            List<Object> result = new ArrayList<>(openArray.length);
             for (Object o : openArray) {
                 result.add(paramType.toJavaTypeData(o));
             }
@@ -514,7 +514,7 @@
             // FIXME: generate typeName for generic
             typeName = "Map<" + keyType.getName() + "," +
                                 valueType.getName() + ">";
-            final OpenType[] mapItemTypes = new OpenType[] {
+            final OpenType<?>[] mapItemTypes = new OpenType<?>[] {
                                                 keyType.getOpenType(),
                                                 valueType.getOpenType(),
                                             };
@@ -543,7 +543,7 @@
             final TabularData table = new TabularDataSupport(tabularType);
             final CompositeType rowType = tabularType.getRowType();
 
-            for (Map.Entry entry : map.entrySet()) {
+            for (Map.Entry<Object, Object> entry : map.entrySet()) {
                 final Object key = keyType.toOpenTypeData(entry.getKey());
                 final Object value = valueType.toOpenTypeData(entry.getValue());
                 final CompositeData row =
@@ -560,7 +560,7 @@
 
             final TabularData td = (TabularData) data;
 
-            Map<Object, Object> result = new HashMap<Object, Object>();
+            Map<Object, Object> result = new HashMap<>();
             for (CompositeData row : (Collection<CompositeData>) td.values()) {
                 Object key = keyType.toJavaTypeData(row.get(KEY));
                 Object value = valueType.toJavaTypeData(row.get(VALUE));
@@ -607,7 +607,7 @@
         final boolean isCompositeData;
         Method fromMethod = null;
 
-        CompositeDataMXBeanType(Class c) throws OpenDataException {
+        CompositeDataMXBeanType(Class<?> c) throws OpenDataException {
             this.javaClass = c;
             this.mappedTypeClass = COMPOSITE_DATA_CLASS;
 
@@ -639,8 +639,8 @@
                             return javaClass.getMethods();
                         }
                     });
-                final List<String> names = new ArrayList<String>();
-                final List<OpenType> types = new ArrayList<OpenType>();
+                final List<String> names = new ArrayList<>();
+                final List<OpenType<?>> types = new ArrayList<>();
 
                 /* Select public methods that look like "T getX()" or "boolean
                    isX()", where T is not void and X is not the empty
@@ -678,7 +678,7 @@
                                              c.getName(),
                                              nameArray, // field names
                                              nameArray, // field descriptions
-                                             types.toArray(new OpenType[0]));
+                                             types.toArray(new OpenType<?>[0]));
             }
         }
 
@@ -722,7 +722,7 @@
                 // so that no other classes are sent over the wire
                 CompositeData cd = (CompositeData) data;
                 CompositeType ct = cd.getCompositeType();
-                String[] itemNames = (String[]) ct.keySet().toArray(new String[0]);
+                String[] itemNames = ct.keySet().toArray(new String[0]);
                 Object[] itemValues = cd.getAll(itemNames);
                 return new CompositeDataSupport(ct, itemNames, itemValues);
             }
@@ -779,9 +779,9 @@
         }
         private static final long serialVersionUID = -3413063475064374490L;
     }
-    private static final OpenType inProgress;
+    private static final OpenType<?> inProgress;
     static {
-        OpenType t;
+        OpenType<?> t;
         try {
             t = new InProgress();
         } catch (OpenDataException e) {
@@ -799,8 +799,8 @@
     static {
         try {
             for (int i = 0; i < simpleTypes.length; i++) {
-                final OpenType t = simpleTypes[i];
-                Class c;
+                final OpenType<?> t = simpleTypes[i];
+                Class<?> c;
                 try {
                     c = Class.forName(t.getClassName(), false,
                                       String.class.getClassLoader());
@@ -816,7 +816,7 @@
                 if (c.getName().startsWith("java.lang.")) {
                     try {
                         final Field typeField = c.getField("TYPE");
-                        final Class primitiveType = (Class) typeField.get(null);
+                        final Class<?> primitiveType = (Class<?>) typeField.get(null);
                         MappedMXBeanType.newBasicType(primitiveType, t);
                     } catch (NoSuchFieldException e) {
                         // OK: must not be a primitive wrapper
--- a/src/share/classes/sun/management/MonitorInfoCompositeData.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/MonitorInfoCompositeData.java	Thu Sep 07 23:37:21 2017 -0700
@@ -92,7 +92,7 @@
             monitorInfoCompositeType = (CompositeType)
                 MappedMXBeanType.toOpenType(MonitorInfo.class);
             Set<String> s = monitorInfoCompositeType.keySet();
-            monitorInfoItemNames = (String[]) s.toArray(new String[0]);
+            monitorInfoItemNames =  s.toArray(new String[0]);
         } catch (OpenDataException e) {
             // Should never reach here
             throw new AssertionError(e);
--- a/src/share/classes/sun/management/NotificationEmitterSupport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/NotificationEmitterSupport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,7 +71,7 @@
            efficient solution would be to clone the listener list
            every time a notification is sent.  */
         synchronized (listenerLock) {
-            List<ListenerInfo> newList = new ArrayList<ListenerInfo>(listenerList.size() + 1);
+            List<ListenerInfo> newList = new ArrayList<>(listenerList.size() + 1);
             newList.addAll(listenerList);
             newList.add(new ListenerInfo(listener, filter, handback));
             listenerList = newList;
@@ -82,12 +82,12 @@
         throws ListenerNotFoundException {
 
         synchronized (listenerLock) {
-            List<ListenerInfo> newList = new ArrayList<ListenerInfo>(listenerList);
+            List<ListenerInfo> newList = new ArrayList<>(listenerList);
             /* We scan the list of listeners in reverse order because
                in forward order we would have to repeat the loop with
                the same index after a remove.  */
             for (int i=newList.size()-1; i>=0; i--) {
-                ListenerInfo li = (ListenerInfo)newList.get(i);
+                ListenerInfo li = newList.get(i);
 
                 if (li.listener == listener)
                     newList.remove(i);
@@ -106,10 +106,10 @@
         boolean found = false;
 
         synchronized (listenerLock) {
-            List<ListenerInfo> newList = new ArrayList<ListenerInfo>(listenerList);
+            List<ListenerInfo> newList = new ArrayList<>(listenerList);
             final int size = newList.size();
             for (int i = 0; i < size; i++) {
-                ListenerInfo li = (ListenerInfo) newList.get(i);
+                ListenerInfo li =  newList.get(i);
 
                 if (li.listener == listener) {
                     found = true;
@@ -148,7 +148,7 @@
 
         final int size = currentList.size();
         for (int i = 0; i < size; i++) {
-            ListenerInfo li = (ListenerInfo) currentList.get(i);
+            ListenerInfo li =  currentList.get(i);
 
             if (li.filter == null
                 || li.filter.isNotificationEnabled(notification)) {
--- a/src/share/classes/sun/management/RuntimeImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/RuntimeImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -128,7 +128,7 @@
 
     public Map<String,String> getSystemProperties() {
         Properties sysProps = System.getProperties();
-        Map<String,String> map = new HashMap<String, String>();
+        Map<String,String> map = new HashMap<>();
 
         // Properties.entrySet() does not include the entries in
         // the default properties.  So use Properties.stringPropertyNames()
--- a/src/share/classes/sun/management/ThreadInfoCompositeData.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/ThreadInfoCompositeData.java	Thu Sep 07 23:37:21 2017 -0700
@@ -190,7 +190,7 @@
                                       threadInfoV6Attributes.length;
             String[] v5ItemNames = new String[numV5Attributes];
             String[] v5ItemDescs = new String[numV5Attributes];
-            OpenType[] v5ItemTypes = new OpenType[numV5Attributes];
+            OpenType<?>[] v5ItemTypes = new OpenType<?>[numV5Attributes];
             int i = 0;
             for (String n : itemNames) {
                 if (isV5Attribute(n)) {
--- a/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java	Thu Sep 07 23:37:21 2017 -0700
@@ -73,7 +73,7 @@
         buffer.position(prologue.getEntryOffset());
         nextEntry = buffer.position();
         // rebuild all the counters
-        map = new TreeMap<String, Counter>();
+        map = new TreeMap<>();
     }
 
     boolean hasNext() {
@@ -154,7 +154,7 @@
                 map.put(c.getName(), c);
             }
         }
-        return new ArrayList<Counter>(map.values());
+        return new ArrayList<>(map.values());
     }
 
     public synchronized List<Counter> findByPattern(String patternString) {
@@ -167,19 +167,18 @@
 
         Pattern pattern = Pattern.compile(patternString);
         Matcher matcher = pattern.matcher("");
-        List<Counter> matches = new ArrayList<Counter>();
+        List<Counter> matches = new ArrayList<>();
 
-        Iterator iter = map.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry me = (Map.Entry) iter.next();
-            String name = (String) me.getKey();
+
+        for (Map.Entry<String,Counter> me: map.entrySet()) {
+            String name = me.getKey();
 
             // apply pattern to counter name
             matcher.reset(name);
 
             // if the pattern matches, then add Counter to list
             if (matcher.lookingAt()) {
-                matches.add((Counter)me.getValue());
+                matches.add(me.getValue());
             }
         }
         return matches;
--- a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Thu Sep 07 23:37:21 2017 -0700
@@ -237,17 +237,16 @@
                         "the access file [" + accessFile + "] as the " +
                         "authenticated Subject is null");
             }
-            final Set principals = subject.getPrincipals();
-            for (Iterator i = principals.iterator(); i.hasNext();) {
-                final Principal p = (Principal) i.next();
-                if (properties.containsKey(p.getName())) {
+            final Set<Principal> principals = subject.getPrincipals();
+            for (Principal p1: principals) {
+                if (properties.containsKey(p1.getName())) {
                     return;
                 }
             }
-            final Set<String> principalsStr = new HashSet<String>();
-            for (Iterator i = principals.iterator(); i.hasNext();) {
-                final Principal p = (Principal) i.next();
-                principalsStr.add(p.getName());
+
+            final Set<String> principalsStr = new HashSet<>();
+            for (Principal p2: principals) {
+                principalsStr.add(p2.getName());
             }
             throw new SecurityException(
                     "Access denied! No entries found in the access file [" +
@@ -261,9 +260,9 @@
             if (fname == null) {
                 return p;
             }
-            FileInputStream fin = new FileInputStream(fname);
-            p.load(fin);
-            fin.close();
+            try (FileInputStream fin = new FileInputStream(fname)) {
+                p.load(fin);
+            }
             return p;
         }
         private final Map<String, Object> environment;
@@ -484,7 +483,7 @@
         try {
             // Export remote connector address and associated configuration
             // properties to the instrumentation buffer.
-            Map<String, String> properties = new HashMap<String, String>();
+            Map<String, String> properties = new HashMap<>();
             properties.put("remoteAddress", url.toString());
             properties.put("authenticate", useAuthenticationStr);
             properties.put("ssl", useSslStr);
@@ -510,7 +509,7 @@
         System.setProperty("java.rmi.server.randomIDs", "true");
 
         // This RMI server should not keep the VM alive
-        Map<String, Object> env = new HashMap<String, Object>();
+        Map<String, Object> env = new HashMap<>();
         env.put(RMIExporter.EXPORTER_ATTRIBUTE, new PermanentExporter());
         env.put(EnvHelp.CREDENTIAL_TYPES, new String[]{
             String[].class.getName(), String.class.getName()
@@ -657,12 +656,9 @@
             try {
                 // Load the SSL keystore properties from the config file
                 Properties p = new Properties();
-                InputStream in = new FileInputStream(sslConfigFileName);
-                try {
+                try (InputStream in = new FileInputStream(sslConfigFileName)) {
                     BufferedInputStream bin = new BufferedInputStream(in);
                     p.load(bin);
-                } finally {
-                    in.close();
                 }
                 String keyStore =
                         p.getProperty("javax.net.ssl.keyStore");
@@ -686,11 +682,8 @@
                 KeyStore ks = null;
                 if (keyStore != null) {
                     ks = KeyStore.getInstance(KeyStore.getDefaultType());
-                    FileInputStream ksfis = new FileInputStream(keyStore);
-                    try {
+                    try (FileInputStream ksfis = new FileInputStream(keyStore)) {
                         ks.load(ksfis, keyStorePasswd);
-                    } finally {
-                        ksfis.close();
                     }
                 }
                 KeyManagerFactory kmf = KeyManagerFactory.getInstance(
@@ -700,16 +693,13 @@
                 KeyStore ts = null;
                 if (trustStore != null) {
                     ts = KeyStore.getInstance(KeyStore.getDefaultType());
-                    FileInputStream tsfis = new FileInputStream(trustStore);
-                    try {
+                    try (FileInputStream tsfis = new FileInputStream(trustStore)) {
                         ts.load(tsfis, trustStorePasswd);
-                    } finally {
-                        tsfis.close();
                     }
                 }
                 TrustManagerFactory tmf = TrustManagerFactory.getInstance(
                         TrustManagerFactory.getDefaultAlgorithm());
-                tmf.init((KeyStore) ts);
+                tmf.init(ts);
 
                 SSLContext ctx = SSLContext.getInstance("SSL");
                 ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
@@ -749,7 +739,7 @@
 
         JMXServiceURL url = new JMXServiceURL("rmi", bindAddress, rmiPort);
 
-        Map<String, Object> env = new HashMap<String, Object>();
+        Map<String, Object> env = new HashMap<>();
 
         PermanentExporter exporter = new PermanentExporter();
 
--- a/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Thu Sep 07 23:37:21 2017 -0700
@@ -32,6 +32,7 @@
 
 package sun.management.jmxremote;
 
+import sun.misc.ObjectInputFilter;
 import java.rmi.AccessException;
 import java.rmi.NotBoundException;
 import java.rmi.Remote;
@@ -56,7 +57,12 @@
                         String name,
                         Remote object)
             throws RemoteException {
-        super(port, csf, ssf);
+        super(port, csf, ssf, new ObjectInputFilter() {
+            @Override
+            public Status checkInput(ObjectInputFilter.FilterInfo info) {
+                return SingleEntryRegistry.singleRegistryFilter(info);
+            }
+        });
         this.name = name;
         this.object = object;
     }
@@ -84,6 +90,23 @@
         throw new AccessException("Cannot modify this registry");
     }
 
+    /**
+     * ObjectInputFilter to check parameters to SingleEntryRegistry.
+     * Since it is a read-only Registry, no classes are accepted.
+     * String arguments are accepted without passing them to the serialFilter.
+     *
+     * @param info a reference to the serialization filter information
+     * @return Status.REJECTED if parameters are out of range
+     */
+    private static ObjectInputFilter.Status singleRegistryFilter(ObjectInputFilter.FilterInfo info) {
+        return (info.serialClass() != null ||
+                info.depth() > 2 ||
+                info.references() > 4 ||
+                info.arrayLength() >= 0)
+        ? ObjectInputFilter.Status.REJECTED
+        : ObjectInputFilter.Status.ALLOWED;
+    }
+
     private final String name;
     private final Remote object;
 
--- a/src/share/classes/sun/management/resources/agent_sv.properties	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/resources/agent_sv.properties	Thu Sep 07 23:37:21 2017 -0700
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -70,10 +70,10 @@
 agent.err.invalid.snmp.port        = Ogiltigt com.sun.management.snmp.port-nummer
 agent.err.invalid.snmp.trap.port   = Ogiltigt com.sun.management.snmp.trap-nummer
 agent.err.unknown.snmp.interface   = Ok\u00E4nt SNMP-gr\u00E4nssnitt
-agent.err.acl.file.notset          = Ingen SNMP ACL-fil har angetts, men com.sun.management.snmp.acl=true
-agent.err.acl.file.notfound        = SNMP ACL-filen hittades inte
-agent.err.acl.file.not.readable    = SNMP ACL-filen \u00E4r inte l\u00E4sbar
-agent.err.acl.file.read.failed     = Kunde inte l\u00E4sa filen SNMP ACL
+agent.err.acl.file.notset          = Ingen SNMP \u00E5tkomstkontrollista-fil har angetts, men com.sun.management.snmp.acl=true
+agent.err.acl.file.notfound        = SNMP \u00E5tkomstkontrollista-filen hittades inte
+agent.err.acl.file.not.readable    = SNMP \u00E5tkomstkontrollista-filen \u00E4r inte l\u00E4sbar
+agent.err.acl.file.read.failed     = Kunde inte l\u00E4sa filen SNMP \u00E5tkomstkontrollista
 agent.err.acl.file.access.notrestricted = L\u00E4sbeh\u00F6righeten f\u00F6r filen m\u00E5ste begr\u00E4nsas
 
 agent.err.snmp.adaptor.start.failed = Kunde inte starta SNMP-adaptern med adressen
@@ -85,7 +85,7 @@
 jmxremote.ConnectorBootstrap.password.readonly = L\u00E4sbeh\u00F6righeten f\u00F6r l\u00F6senordsfilen m\u00E5ste begr\u00E4nsas: {0}
 jmxremote.ConnectorBootstrap.file.readonly = Fill\u00E4snings\u00E5tkomst m\u00E5ste begr\u00E4nsas {0}
 
-jmxremote.AdaptorBootstrap.getTargetList.processing = ACL bearbetas
+jmxremote.AdaptorBootstrap.getTargetList.processing = \u00E5tkomstkontrollista bearbetas
 jmxremote.AdaptorBootstrap.getTargetList.adding = M\u00E5l l\u00E4ggs till: {0}
 jmxremote.AdaptorBootstrap.getTargetList.starting = Adapterservern startas:
 jmxremote.AdaptorBootstrap.getTargetList.initialize1 = Adaptern redo.
--- a/src/share/classes/sun/management/snmp/AdaptorBootstrap.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/AdaptorBootstrap.java	Thu Sep 07 23:37:21 2017 -0700
@@ -118,21 +118,22 @@
     /**
      * Retrieve the Trap Target List from the ACL file.
      **/
+    @SuppressWarnings("unchecked")
     private static List<NotificationTarget> getTargetList(InetAddressAcl acl,
                                                           int defaultTrapPort) {
         final ArrayList<NotificationTarget> result =
-                new ArrayList<NotificationTarget>();
+                new ArrayList<>();
         if (acl != null) {
             if (log.isDebugOn())
                 log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing"));
 
-            final Enumeration td=acl.getTrapDestinations();
+            final Enumeration td = acl.getTrapDestinations();
             for (; td.hasMoreElements() ;) {
                 final InetAddress targetAddr = (InetAddress)td.nextElement();
                 final Enumeration tc =
                     acl.getTrapCommunities(targetAddr);
                 for (;tc.hasMoreElements() ;) {
-                    final String community = (String) tc.nextElement();
+                    final String community = (String)tc.nextElement();
                     final NotificationTarget target =
                         new NotificationTargetImpl(targetAddr,
                                                    defaultTrapPort,
--- a/src/share/classes/sun/management/snmp/jvminstr/JVM_MANAGEMENT_MIB_IMPL.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JVM_MANAGEMENT_MIB_IMPL.java	Thu Sep 07 23:37:21 2017 -0700
@@ -90,14 +90,14 @@
         SnmpOidTable table = null;
         if(tableRef == null) {
             table =  new JVM_MANAGEMENT_MIBOidTable();
-            tableRef = new WeakReference<SnmpOidTable>(table);
+            tableRef = new WeakReference<>(table);
             return table;
         }
 
         table = tableRef.get();
         if(table == null) {
             table = new JVM_MANAGEMENT_MIBOidTable();
-            tableRef = new WeakReference<SnmpOidTable>(table);
+            tableRef = new WeakReference<>(table);
         }
 
         return table;
@@ -198,7 +198,7 @@
      * List of notification targets.
      */
     private ArrayList<NotificationTarget> notificationTargets =
-            new ArrayList<NotificationTarget>();
+            new ArrayList<>();
     private final NotificationEmitter emitter;
     private final NotificationHandler handler;
 
@@ -215,7 +215,7 @@
     }
 
     private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) {
-        final Iterator iterator = notificationTargets.iterator();
+        final Iterator<NotificationTarget> iterator = notificationTargets.iterator();
         final SnmpAdaptorServer adaptor =
             (SnmpAdaptorServer) getSnmpAdaptor();
 
@@ -232,7 +232,7 @@
         while(iterator.hasNext()) {
             NotificationTarget target = null;
             try {
-                target = (NotificationTarget) iterator.next();
+                target = iterator.next();
                 SnmpPeer peer =
                     new SnmpPeer(target.getAddress(), target.getPort());
                 SnmpParameters p = new SnmpParameters();
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemGCTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemGCTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -58,6 +58,8 @@
  */
 public class JvmMemGCTableMetaImpl extends  JvmMemGCTableMeta {
 
+    static final long serialVersionUID = 8250461197108867607L;
+
     /**
      * This class acts as a filter over the SnmpTableHandler
      * used for the JvmMemoryManagerTable. It filters out
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemManagerTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemManagerTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -61,12 +61,17 @@
  */
 public class JvmMemManagerTableMetaImpl extends JvmMemManagerTableMeta {
 
+    static final long serialVersionUID = 36176771566817592L;
+
     /**
      * A concrete implementation of {@link SnmpNamedListTableCache}, for the
      * jvmMemManagerTable.
      **/
     private static class JvmMemManagerTableCache
         extends SnmpNamedListTableCache {
+
+        static final long serialVersionUID = 6564294074653009240L;
+
         /**
          * Create a weak cache for the jvmMemManagerTable.
          * @param validity validity of the cached data, in ms.
@@ -87,7 +92,7 @@
          *        <code>MemoryManagerMXBean</code> in the list.
          * @return  <code>((MemoryManagerMXBean)item).getName()</code>
          **/
-        protected String getKey(Object context, List rawDatas,
+        protected String getKey(Object context, List<?> rawDatas,
                                 int rank, Object item) {
             if (item == null) return null;
             final String name = ((MemoryManagerMXBean)item).getName();
@@ -99,7 +104,7 @@
          * Call <code>getTableHandler(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object, Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
@@ -114,7 +119,7 @@
          * Call ManagementFactory.getMemoryManagerMXBeans() to
          * load the raw data of this table.
          **/
-        protected List   loadRawDatas(Map userData) {
+        protected List<MemoryManagerMXBean> loadRawDatas(Map<Object, Object> userData) {
             return ManagementFactory.getMemoryManagerMXBeans();
         }
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemMgrPoolRelTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemMgrPoolRelTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -64,13 +64,17 @@
 public class JvmMemMgrPoolRelTableMetaImpl extends JvmMemMgrPoolRelTableMeta
     implements Serializable {
 
+    static final long serialVersionUID = 1896509775012355443L;
+
     /**
      * A concrete implementation of {@link SnmpTableCache}, for the
      * jvmMemMgrPoolRelTable.
      **/
+
     private static class JvmMemMgrPoolRelTableCache
         extends SnmpTableCache {
 
+        static final long serialVersionUID = 6059937161990659184L;
         final private JvmMemMgrPoolRelTableMetaImpl meta;
 
         /**
@@ -87,7 +91,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object,Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
@@ -101,7 +105,7 @@
                 return buildPoolIndexMap((SnmpCachedData)handler);
 
             // not optimizable... too bad.
-            final Map<String, SnmpOid> m = new HashMap<String, SnmpOid>();
+            final Map<String, SnmpOid> m = new HashMap<>();
             SnmpOid index=null;
             while ((index = handler.getNext(index))!=null) {
                 final MemoryPoolMXBean mpm =
@@ -124,7 +128,7 @@
             final SnmpOid[] indexes = cached.indexes;
             final Object[]  datas   = cached.datas;
             final int len = indexes.length;
-            final Map<String, SnmpOid> m = new HashMap<String, SnmpOid>(len);
+            final Map<String, SnmpOid> m = new HashMap<>(len);
             for (int i=0; i<len; i++) {
                 final SnmpOid index = indexes[i];
                 if (index == null) continue;
@@ -165,13 +169,13 @@
             final long time = System.currentTimeMillis();
 
             //     Build a Map poolname -> index
-            final Map poolIndexMap = buildPoolIndexMap(mpHandler);
+            final Map<String,SnmpOid> poolIndexMap = buildPoolIndexMap(mpHandler);
 
             // For each memory manager, get the list of memory pools
             // For each memory pool, find its index in the memory pool table
             // Create a row in the relation table.
             final TreeMap<SnmpOid, Object> table =
-                    new TreeMap<SnmpOid, Object>(SnmpCachedData.oidComparator);
+                    new TreeMap<>(SnmpCachedData.oidComparator);
             updateTreeMap(table,userData,mmHandler,mpHandler,poolIndexMap);
 
             return new SnmpCachedData(time,table);
@@ -207,7 +211,7 @@
         protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                                      MemoryManagerMXBean mmm,
                                      SnmpOid mmIndex,
-                                     Map poolIndexMap) {
+                                     Map<String, SnmpOid> poolIndexMap) {
 
             // The MemoryManager index is an int, so it's the first
             // and only subidentifier.
@@ -230,7 +234,7 @@
             for (int i = 0; i < mpList.length; i++) {
                 final String mpmName = mpList[i];
                 if (mpmName == null) continue;
-                final SnmpOid mpIndex = (SnmpOid)poolIndexMap.get(mpmName);
+                final SnmpOid mpIndex = poolIndexMap.get(mpmName);
                 if (mpIndex == null) continue;
 
                 // The MemoryPool index is an int, so it's the first
@@ -261,7 +265,7 @@
         protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                                      SnmpTableHandler mmHandler,
                                      SnmpTableHandler mpHandler,
-                                     Map poolIndexMap) {
+                                     Map<String, SnmpOid> poolIndexMap) {
             if (mmHandler instanceof SnmpCachedData) {
                 updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
                               mpHandler,poolIndexMap);
@@ -280,7 +284,7 @@
         protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
                                      SnmpCachedData mmHandler,
                                      SnmpTableHandler mpHandler,
-                                     Map poolIndexMap) {
+                                     Map<String, SnmpOid> poolIndexMap) {
 
             final SnmpOid[] indexes = mmHandler.indexes;
             final Object[]  datas   = mmHandler.datas;
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -61,11 +61,16 @@
  */
 public class JvmMemPoolTableMetaImpl extends JvmMemPoolTableMeta {
 
+    static final long serialVersionUID = -2525820976094284957L;
+
     /**
      * A concrete implementation of {@link SnmpNamedListTableCache}, for the
      * jvmMemPoolTable.
      **/
     private static class JvmMemPoolTableCache extends SnmpNamedListTableCache {
+
+        static final long serialVersionUID = -1755520683086760574L;
+
         /**
          * Create a weak cache for the jvmMemPoolTable.
          * @param validity validity of the cached data, in ms.
@@ -86,7 +91,7 @@
          *        <code>MemoryPoolMXBean</code> in the list.
          * @return  <code>((MemoryPoolMXBean)item).getName()</code>
          **/
-        protected String getKey(Object context, List rawDatas,
+        protected String getKey(Object context, List<?> rawDatas,
                                 int rank, Object item) {
             if (item == null) return null;
             final String name = ((MemoryPoolMXBean)item).getName();
@@ -98,7 +103,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object, Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
@@ -113,7 +118,7 @@
          * Call ManagementFactory.getMemoryPoolMXBeans() to
          * load the raw data of this table.
          **/
-        protected List   loadRawDatas(Map userData) {
+        protected List<MemoryPoolMXBean> loadRawDatas(Map<Object, Object> userData) {
             return ManagementFactory.getMemoryPoolMXBeans();
         }
     }
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -275,7 +275,7 @@
      */
     public EnumJvmMemoryGCCall getJvmMemoryGCCall()
         throws SnmpStatusException {
-        final Map m = JvmContextFactory.getUserData();
+        final Map<Object,Object> m = JvmContextFactory.getUserData();
 
         if (m != null) {
             final EnumJvmMemoryGCCall cached
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -50,6 +50,8 @@
  * The class is used for representing SNMP metadata for the "JvmMemory" group.
  */
 public class JvmMemoryMetaImpl extends JvmMemoryMeta {
+
+    static final long serialVersionUID = -6500448253825893071L;
     /**
      * Constructor for the metadata associated to "JvmMemory".
      */
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmOSImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmOSImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -47,6 +47,8 @@
  */
 public class JvmOSImpl implements JvmOSMBean, Serializable {
 
+     static final long serialVersionUID = 1839834731763310809L;
+
     /**
      * Constructor for the "JvmOS" group.
      * If the group contains a table, the entries created through an
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTBootClassPathEntryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTBootClassPathEntryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -44,6 +44,8 @@
 public class JvmRTBootClassPathEntryImpl
     implements JvmRTBootClassPathEntryMBean, Serializable {
 
+    static final long serialVersionUID = -2282652055235913013L;
+
     private final String item;
     private final int index;
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTBootClassPathTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTBootClassPathTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,8 @@
 public class JvmRTBootClassPathTableMetaImpl
     extends JvmRTBootClassPathTableMeta {
 
+    static final long serialVersionUID = -8659886610487538299L;
+
     private SnmpTableCache cache;
 
      /**
@@ -78,6 +80,7 @@
      * JvmRTBootClassPathTable.
      **/
     private static class JvmRTBootClassPathTableCache extends SnmpTableCache {
+        static final long serialVersionUID = -2637458695413646098L;
         private JvmRTBootClassPathTableMetaImpl meta;
 
         JvmRTBootClassPathTableCache(JvmRTBootClassPathTableMetaImpl meta,
@@ -90,7 +93,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object,Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTClassPathEntryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTClassPathEntryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -44,6 +44,7 @@
 public class JvmRTClassPathEntryImpl implements JvmRTClassPathEntryMBean,
                                                 Serializable {
 
+    static final long serialVersionUID = 8524792845083365742L;
     private final String item;
     private final int index;
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTClassPathTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTClassPathTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,8 @@
   */
 public class JvmRTClassPathTableMetaImpl extends JvmRTClassPathTableMeta {
 
+    static final long serialVersionUID = -6914494148818455166L;
+
     private SnmpTableCache cache;
 
      /**
@@ -77,6 +79,7 @@
      * JvmRTClassPathTable.
      **/
     private static class JvmRTClassPathTableCache extends SnmpTableCache {
+        static final long serialVersionUID = 3805032372592117315L;
         private JvmRTClassPathTableMetaImpl meta;
 
         JvmRTClassPathTableCache(JvmRTClassPathTableMetaImpl meta,
@@ -89,7 +92,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object, Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTInputArgsEntryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTInputArgsEntryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -44,6 +44,7 @@
 public class JvmRTInputArgsEntryImpl implements JvmRTInputArgsEntryMBean,
                                                 Serializable {
 
+    static final long serialVersionUID = 1000306518436503395L;
     private final String item;
     private final int index;
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTInputArgsTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTInputArgsTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
  */
 public class JvmRTInputArgsTableMetaImpl extends JvmRTInputArgsTableMeta {
 
+    static final long serialVersionUID = -2083438094888099238L;
     private SnmpTableCache cache;
 
      /**
@@ -77,6 +78,8 @@
      * JvmRTInputArgsTable.
      **/
     private static class JvmRTInputArgsTableCache extends SnmpTableCache {
+
+        static final long serialVersionUID = 1693751105464785192L;
         private JvmRTInputArgsTableMetaImpl meta;
 
         JvmRTInputArgsTableCache(JvmRTInputArgsTableMetaImpl meta,
@@ -89,7 +92,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object,Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTLibraryPathEntryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTLibraryPathEntryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -44,6 +44,7 @@
 public class JvmRTLibraryPathEntryImpl implements JvmRTLibraryPathEntryMBean,
                                                 Serializable {
 
+    static final long serialVersionUID = -3322438153507369765L;
     private final String item;
     private final int index;
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRTLibraryPathTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRTLibraryPathTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
   */
 public class JvmRTLibraryPathTableMetaImpl extends JvmRTLibraryPathTableMeta {
 
+    static final long serialVersionUID = 6713252710712502068L;
     private SnmpTableCache cache;
 
      /**
@@ -77,6 +78,7 @@
      * JvmRTLibraryPathTable.
      **/
     private static class JvmRTLibraryPathTableCache extends SnmpTableCache {
+        static final long serialVersionUID = 2035304445719393195L;
         private JvmRTLibraryPathTableMetaImpl meta;
 
         JvmRTLibraryPathTableCache(JvmRTLibraryPathTableMetaImpl meta,
@@ -89,7 +91,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object,Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmRuntimeMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmRuntimeMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmRuntimeMetaImpl extends JvmRuntimeMeta {
 
+     static final long serialVersionUID = -6570428414857608618L;
     /**
      * Constructor for the metadata associated to "JvmRuntime".
      */
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -53,6 +53,8 @@
 public class JvmThreadInstanceEntryImpl
     implements JvmThreadInstanceEntryMBean, Serializable {
 
+    static final long serialVersionUID = 910173589985461347L;
+
     public final static class ThreadStateMap {
         public final static class Byte0 {
             public final static byte inNative     = (byte)0x80; // bit 1
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceTableMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceTableMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -78,6 +78,8 @@
 public class JvmThreadInstanceTableMetaImpl
     extends JvmThreadInstanceTableMeta {
 
+    static final long serialVersionUID = -8432271929226397492L;
+
     /**
      * Maximum depth of the stacktrace that might be returned through
      * SNMP.
@@ -135,6 +137,7 @@
     private static class JvmThreadInstanceTableCache
         extends SnmpTableCache {
 
+        static final long serialVersionUID = 4947330124563406878L;
         final private JvmThreadInstanceTableMetaImpl meta;
 
         /**
@@ -151,7 +154,7 @@
          * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
          **/
         public SnmpTableHandler getTableHandler() {
-            final Map userData = JvmContextFactory.getUserData();
+            final Map<Object, Object> userData = JvmContextFactory.getUserData();
             return getTableDatas(userData);
         }
 
@@ -172,7 +175,7 @@
 
             SnmpOid indexes[] = new SnmpOid[id.length];
             final TreeMap<SnmpOid, Object> table =
-                    new TreeMap<SnmpOid, Object>(SnmpCachedData.oidComparator);
+                    new TreeMap<>(SnmpCachedData.oidComparator);
             for(int i = 0; i < id.length; i++) {
                 log.debug("", "Making index for thread id [" + id[i] +"]");
                 //indexes[i] = makeOid(id[i]);
@@ -277,7 +280,7 @@
 
         // Get the request contextual cache (userData).
         //
-        final Map m = JvmContextFactory.getUserData();
+        final Map<Object,Object> m = JvmContextFactory.getUserData();
 
         // Get the handler.
         //
--- a/src/share/classes/sun/management/snmp/jvminstr/JvmThreadingMetaImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvminstr/JvmThreadingMetaImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -66,6 +66,8 @@
  */
 public class JvmThreadingMetaImpl extends JvmThreadingMeta {
 
+    static final long serialVersionUID = -2104788458393251457L;
+
     /**
      * Constructor for the metadata associated to "JvmThreading".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmClassesVerboseLevel.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmClassesVerboseLevel.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmClassesVerboseLevel extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -620710366914810374L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "verbose");
         intTable.put(new Integer(1), "silent");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmJITCompilerTimeMonitoring.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmJITCompilerTimeMonitoring.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmJITCompilerTimeMonitoring extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 3953565918146461236L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "supported");
         intTable.put(new Integer(1), "unsupported");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer, String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String, Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemManagerState.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemManagerState.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,12 @@
  */
 public class EnumJvmMemManagerState extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 8249515157795166343L;
+
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "valid");
         intTable.put(new Integer(1), "invalid");
@@ -70,11 +72,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer, String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String, Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolCollectThreshdSupport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolCollectThreshdSupport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemPoolCollectThreshdSupport extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 8610091819732806282L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "supported");
         intTable.put(new Integer(1), "unsupported");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer, String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String, Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolState.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolState.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemPoolState extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 3038175407527743027L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "valid");
         intTable.put(new Integer(1), "invalid");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolThreshdSupport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolThreshdSupport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemPoolThreshdSupport extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 7014693561120661029L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "supported");
         intTable.put(new Integer(1), "unsupported");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolType.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemPoolType.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemPoolType extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -7214498472962396555L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "heap");
         intTable.put(new Integer(1), "nonheap");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemoryGCCall.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemoryGCCall.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemoryGCCall extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -2869147994287351375L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "supported");
         intTable.put(new Integer(5), "failed");
@@ -76,11 +77,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer, String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String, Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemoryGCVerboseLevel.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmMemoryGCVerboseLevel.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmMemoryGCVerboseLevel extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = 1362427628755978190L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "verbose");
         intTable.put(new Integer(1), "silent");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmRTBootClassPathSupport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmRTBootClassPathSupport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmRTBootClassPathSupport extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -5957542680437939894L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(2), "supported");
         intTable.put(new Integer(1), "unsupported");
@@ -70,11 +71,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer, String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String, Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmThreadContentionMonitoring.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmThreadContentionMonitoring.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmThreadContentionMonitoring extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -6411827583604137210L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(3), "enabled");
         intTable.put(new Integer(4), "disabled");
@@ -72,11 +73,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/EnumJvmThreadCpuTimeMonitoring.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/EnumJvmThreadCpuTimeMonitoring.java	Thu Sep 07 23:37:21 2017 -0700
@@ -43,10 +43,11 @@
  */
 public class EnumJvmThreadCpuTimeMonitoring extends Enumerated implements Serializable {
 
+    static final long serialVersionUID = -532837824105215699L;
     protected static Hashtable<Integer, String> intTable =
-            new Hashtable<Integer, String>();
+            new Hashtable<>();
     protected static Hashtable<String, Integer> stringTable =
-            new Hashtable<String, Integer>();
+            new Hashtable<>();
     static  {
         intTable.put(new Integer(3), "enabled");
         intTable.put(new Integer(4), "disabled");
@@ -72,11 +73,11 @@
         super(x);
     }
 
-    protected Hashtable getIntTable() {
+    protected Hashtable<Integer,String> getIntTable() {
         return intTable ;
     }
 
-    protected Hashtable getStringTable() {
+    protected Hashtable<String,Integer> getStringTable() {
         return stringTable ;
     }
 
--- a/src/share/classes/sun/management/snmp/jvmmib/JVM_MANAGEMENT_MIB.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JVM_MANAGEMENT_MIB.java	Thu Sep 07 23:37:21 2017 -0700
@@ -53,6 +53,7 @@
  */
 public abstract class JVM_MANAGEMENT_MIB extends SnmpMib implements Serializable {
 
+    static final long serialVersionUID = 6895037919735816732L;
     /**
      * Default constructor. Initialize the Mib tree.
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JVM_MANAGEMENT_MIBOidTable.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JVM_MANAGEMENT_MIBOidTable.java	Thu Sep 07 23:37:21 2017 -0700
@@ -47,6 +47,7 @@
  */
 public class JVM_MANAGEMENT_MIBOidTable extends SnmpOidTableSupport implements Serializable {
 
+    static final long serialVersionUID = -5010870014488732061L;
     /**
      * Default constructor. Initialize the Mib tree.
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmClassLoadingMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmClassLoadingMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
 public class JvmClassLoadingMeta extends SnmpMibGroup
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 5722857476941218568L;
     /**
      * Constructor for the metadata associated to "JvmClassLoading".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmCompilationMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmCompilationMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
 public class JvmCompilationMeta extends SnmpMibGroup
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = -95492874115033638L;
     /**
      * Constructor for the metadata associated to "JvmCompilation".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemGCEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemGCEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmMemGCEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+     static final long serialVersionUID = 6082082529298387063L;
     /**
      * Constructor for the metadata associated to "JvmMemGCEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemGCTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemGCTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmMemGCTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = -8843296871149264612L;
     /**
      * Constructor for the table. Initialize metadata for "JvmMemGCTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemManagerEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemManagerEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmMemManagerEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 8166956416408970453L;
     /**
      * Constructor for the metadata associated to "JvmMemManagerEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemManagerTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemManagerTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmMemManagerTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = 5026520607518015233L;
     /**
      * Constructor for the table. Initialize metadata for "JvmMemManagerTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemMgrPoolRelEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemMgrPoolRelEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmMemMgrPoolRelEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 7414270971113459798L;
     /**
      * Constructor for the metadata associated to "JvmMemMgrPoolRelEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemMgrPoolRelTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemMgrPoolRelTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmMemMgrPoolRelTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = -310733366542788998L;
     /**
      * Constructor for the table. Initialize metadata for "JvmMemMgrPoolRelTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemPoolEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemPoolEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmMemPoolEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 7220682779249102830L;
     /**
      * Constructor for the metadata associated to "JvmMemPoolEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmMemPoolTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmMemPoolTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,8 @@
  */
 public class JvmMemPoolTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = -2799470815264898659L;
+
     /**
      * Constructor for the table. Initialize metadata for "JvmMemPoolTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmOSMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmOSMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,8 @@
 public class JvmOSMeta extends SnmpMibGroup
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = -2024138733580127133L;
+
     /**
      * Constructor for the metadata associated to "JvmOS".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTBootClassPathEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTBootClassPathEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmRTBootClassPathEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 7703840715080588941L;
     /**
      * Constructor for the metadata associated to "JvmRTBootClassPathEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTBootClassPathTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTBootClassPathTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmRTBootClassPathTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = 42471379600792135L;
     /**
      * Constructor for the table. Initialize metadata for "JvmRTBootClassPathTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTClassPathEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTClassPathEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmRTClassPathEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 3388703998226830801L;
     /**
      * Constructor for the metadata associated to "JvmRTClassPathEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTClassPathTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTClassPathTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmRTClassPathTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = -1518727175345404443L;
     /**
      * Constructor for the table. Initialize metadata for "JvmRTClassPathTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTInputArgsEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTInputArgsEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmRTInputArgsEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = -7729576810347358025L;
     /**
      * Constructor for the metadata associated to "JvmRTInputArgsEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTInputArgsTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTInputArgsTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmRTInputArgsTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = 5395531763015738645L;
     /**
      * Constructor for the table. Initialize metadata for "JvmRTInputArgsTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTLibraryPathEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTLibraryPathEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmRTLibraryPathEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = -5851555586263475792L;
     /**
      * Constructor for the metadata associated to "JvmRTLibraryPathEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRTLibraryPathTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRTLibraryPathTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmRTLibraryPathTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = -632403620113109468L;
     /**
      * Constructor for the table. Initialize metadata for "JvmRTLibraryPathTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmRuntimeMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmRuntimeMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
 public class JvmRuntimeMeta extends SnmpMibGroup
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 1994595220765880109L;
     /**
      * Constructor for the metadata associated to "JvmRuntime".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmThreadInstanceEntryMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmThreadInstanceEntryMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -71,6 +71,7 @@
 public class JvmThreadInstanceEntryMeta extends SnmpMibEntry
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = -2015330111801477399L;
     /**
      * Constructor for the metadata associated to "JvmThreadInstanceEntry".
      */
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmThreadInstanceTableMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmThreadInstanceTableMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  */
 public class JvmThreadInstanceTableMeta extends SnmpMibTable implements Serializable {
 
+    static final long serialVersionUID = 2519514732589115954L;
     /**
      * Constructor for the table. Initialize metadata for "JvmThreadInstanceTableMeta".
      * The reference on the MBean server is updated so the entries created through an SNMP SET will be AUTOMATICALLY REGISTERED in Java DMK.
--- a/src/share/classes/sun/management/snmp/jvmmib/JvmThreadingMeta.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/jvmmib/JvmThreadingMeta.java	Thu Sep 07 23:37:21 2017 -0700
@@ -70,6 +70,7 @@
 public class JvmThreadingMeta extends SnmpMibGroup
      implements Serializable, SnmpStandardMetaServer {
 
+    static final long serialVersionUID = 5223833578005322854L;
     /**
      * Constructor for the metadata associated to "JvmThreading".
      */
--- a/src/share/classes/sun/management/snmp/util/MibLogger.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/util/MibLogger.java	Thu Sep 07 23:37:21 2017 -0700
@@ -32,7 +32,7 @@
     final Logger logger;
     final String className;
 
-    static String getClassName(Class clazz) {
+    static String getClassName(Class<?> clazz) {
         if (clazz == null) return null;
         if (clazz.isArray())
             return getClassName(clazz.getComponentType()) + "[]";
@@ -44,7 +44,7 @@
         else return fullname.substring(lastpoint+1,len);
     }
 
-    static String getLoggerName(Class clazz) {
+    static String getLoggerName(Class<?> clazz) {
         if (clazz == null) return "sun.management.snmp.jvminstr";
         Package p = clazz.getPackage();
         if (p == null) return "sun.management.snmp.jvminstr";
@@ -53,11 +53,11 @@
         else return pname;
     }
 
-    public MibLogger(Class clazz) {
+    public MibLogger(Class<?> clazz) {
         this(getLoggerName(clazz),getClassName(clazz));
     }
 
-    public MibLogger(Class clazz, String postfix) {
+    public MibLogger(Class<?> clazz, String postfix) {
         this(getLoggerName(clazz)+((postfix==null)?"":"."+postfix),
              getClassName(clazz));
     }
--- a/src/share/classes/sun/management/snmp/util/SnmpListTableCache.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/util/SnmpListTableCache.java	Thu Sep 07 23:37:21 2017 -0700
@@ -59,7 +59,7 @@
      *        <var>rawDatas</var> list iterator.
      * @param item The raw data object for which an index must be determined.
      **/
-    protected abstract SnmpOid getIndex(Object context, List rawDatas,
+    protected abstract SnmpOid getIndex(Object context, List<?> rawDatas,
                                         int rank, Object item);
 
     /**
@@ -75,7 +75,7 @@
      *        extracted.
      * @return By default <var>item</var> is returned.
      **/
-    protected Object getData(Object context, List rawDatas,
+    protected Object getData(Object context, List<?> rawDatas,
                              int rank, Object item) {
         return item;
     }
@@ -95,14 +95,14 @@
      *        computed.
      * @return the computed cached data.
      **/
-    protected SnmpCachedData updateCachedDatas(Object context, List rawDatas) {
+    protected SnmpCachedData updateCachedDatas(Object context, List<?> rawDatas) {
         final int size = ((rawDatas == null)?0:rawDatas.size());
         if (size == 0) return  null;
 
         final long time = System.currentTimeMillis();
-        final Iterator it  = rawDatas.iterator();
+        final Iterator<?> it  = rawDatas.iterator();
         final TreeMap<SnmpOid, Object> map =
-                new TreeMap<SnmpOid, Object>(SnmpCachedData.oidComparator);
+                new TreeMap<>(SnmpCachedData.oidComparator);
         for (int rank=0; it.hasNext() ; rank++) {
             final Object  item  = it.next();
             final SnmpOid index = getIndex(context, rawDatas, rank, item);
--- a/src/share/classes/sun/management/snmp/util/SnmpNamedListTableCache.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/util/SnmpNamedListTableCache.java	Thu Sep 07 23:37:21 2017 -0700
@@ -55,7 +55,7 @@
      * This map associate an entry name with the SnmpOid index that's
      * been allocated for it.
      **/
-    protected TreeMap names = new TreeMap();
+    protected TreeMap<String, SnmpOid> names = new TreeMap<>();
 
     /**
      * The last allocate index.
@@ -80,7 +80,7 @@
      *        <var>rawDatas</var> list iterator.
      * @param item The raw data object for which a key name must be determined.
      **/
-    protected abstract String getKey(Object context, List rawDatas,
+    protected abstract String getKey(Object context, List<?> rawDatas,
                                      int rank, Object item);
 
     /**
@@ -97,7 +97,7 @@
      *        <var>rawDatas</var> list iterator.
      * @param item The raw data object for which an index must be determined.
      **/
-    protected SnmpOid makeIndex(Object context, List rawDatas,
+    protected SnmpOid makeIndex(Object context, List<?> rawDatas,
                                 int rank, Object item) {
 
         // check we are in the limits of an unsigned32.
@@ -151,7 +151,7 @@
      *        <var>rawDatas</var> list iterator.
      * @param item The raw data object for which an index must be determined.
      **/
-    protected SnmpOid getIndex(Object context, List rawDatas,
+    protected SnmpOid getIndex(Object context, List<?> rawDatas,
                                int rank, Object item) {
         final String key   = getKey(context,rawDatas,rank,item);
         final Object index = (names==null||key==null)?null:names.get(key);
@@ -174,8 +174,8 @@
      * @param rawDatas The table datas from which the cached data will be
      *        computed.
      **/
-    protected SnmpCachedData updateCachedDatas(Object context, List rawDatas) {
-        TreeMap ctxt = new TreeMap();
+    protected SnmpCachedData updateCachedDatas(Object context, List<?> rawDatas) {
+        TreeMap<String,SnmpOid> ctxt = new TreeMap<>();
         final SnmpCachedData result =
             super.updateCachedDatas(context,rawDatas);
         names = ctxt;
@@ -191,7 +191,7 @@
      *        the {@link JvmContextFactory}.
      *
      **/
-    protected abstract List   loadRawDatas(Map userData);
+    protected abstract List<?>  loadRawDatas(Map<Object,Object> userData);
 
     /**
      *The name under which the raw data is to be found/put in
@@ -212,16 +212,16 @@
      *        the request contextual cache.
      *
      **/
-    protected List getRawDatas(Map<Object, Object> userData, String key) {
-        List rawDatas = null;
+    protected List<?> getRawDatas(Map<Object, Object> userData, String key) {
+        List<?> rawDatas = null;
 
         // Look for memory manager list in request contextual cache.
         if (userData != null)
-            rawDatas = (List) userData.get(key);
+            rawDatas =  (List<?>)userData.get(key);
 
         if (rawDatas == null) {
             // No list in contextual cache, get it from API
-            rawDatas =  loadRawDatas(userData);
+            rawDatas = loadRawDatas(userData);
 
 
             // Put list in cache...
@@ -250,12 +250,12 @@
             (context instanceof Map)?Util.<Map<Object, Object>>cast(context):null;
 
         // Look for memory manager list in request contextual cache.
-        final List rawDatas = getRawDatas(userData,getRawDatasKey());
+        final List<?> rawDatas = getRawDatas(userData,getRawDatasKey());
 
         log.debug("updateCachedDatas","rawDatas.size()=" +
               ((rawDatas==null)?"<no data>":""+rawDatas.size()));
 
-        TreeMap ctxt = new TreeMap();
+        TreeMap<String,SnmpOid> ctxt = new TreeMap<>();
         final SnmpCachedData result =
             super.updateCachedDatas(ctxt,rawDatas);
         names = ctxt;
--- a/src/share/classes/sun/management/snmp/util/SnmpTableCache.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/management/snmp/util/SnmpTableCache.java	Thu Sep 07 23:37:21 2017 -0700
@@ -98,7 +98,7 @@
         final SnmpCachedData cached   = getCachedDatas();
         if (cached != null) return cached;
         final SnmpCachedData computedDatas = updateCachedDatas(context);
-        if (validity != 0) datas = new WeakReference<SnmpCachedData>(computedDatas);
+        if (validity != 0) datas = new WeakReference<>(computedDatas);
         return computedDatas;
     }
 
--- a/src/share/classes/sun/net/RegisteredDomain.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/net/RegisteredDomain.java	Thu Sep 07 23:37:21 2017 -0700
@@ -118,8 +118,8 @@
 private static Set<String>  usSubStateSet = new HashSet<String>(Arrays.asList("state",
                 "lib", "k12", "cc", "tec", "gen", "cog", "mus", "dst"));
 
-private static Map<String,Set> topMap = new HashMap<String,Set>();
-private static Map<String,Set> top3Map = new HashMap<String,Set>();
+private static Map<String,Set<String>> topMap = new HashMap<>();
+private static Map<String,Set<String>> top3Map = new HashMap<>();
 
 static {
     /*
@@ -764,7 +764,7 @@
          */
         String str = cname.substring(third + 1);
         if (third != -1) {
-            Set set = top3Map.get(s);
+            Set<String> set = top3Map.get(s);
             if (set != null) {
                 if (set.contains(str)) {
                     return cname.substring(fourth + 1);
@@ -801,7 +801,7 @@
         /*
          * XX.MA.US.
          */
-        Set topSet = topMap.get(s);
+        Set<String> topSet = topMap.get(s);
         if (topSet != null) {
             if (topSet.contains(s2)) {
                 return cname.substring(third + 1);
--- a/src/share/classes/sun/net/www/protocol/jar/Handler.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/net/www/protocol/jar/Handler.java	Thu Sep 07 23:37:21 2017 -0700
@@ -123,6 +123,7 @@
 
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void parseURL(URL url, String spec,
                             int start, int limit) {
         String file = null;
--- a/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 import java.security.PrivilegedAction;
 import java.security.AccessController;
 import java.security.AccessControlContext;
+import sun.misc.SharedSecrets;
 import sun.security.action.GetIntegerAction;
 
 /**
@@ -246,13 +247,16 @@
     abstract void shutdownHandlerTasks();
 
     private void shutdownExecutors() {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                pool.executor().shutdown();
-                timeoutExecutor.shutdown();
-                return null;
-            }
-        });
+        SharedSecrets.getJavaSecurityAccess().doPrivileged(
+            new PrivilegedAction<Void>() {
+                public Void run() {
+                    pool.executor().shutdown();
+                    timeoutExecutor.shutdown();
+                    return null;
+                }
+            },
+            null,
+            new RuntimePermission("modifyThread"));
     }
 
     @Override
--- a/src/share/classes/sun/rmi/registry/RegistryImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/registry/RegistryImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,6 +69,10 @@
  * registry.
  *
  * The LocateRegistry class is used to obtain registry for different hosts.
+ * <p>
+ * The default RegistryImpl exported restricts access to clients on the local host
+ * for the methods {@link #bind}, {@link #rebind}, {@link #unbind} by checking
+ * the client host in the skeleton.
  *
  * @see java.rmi.registry.LocateRegistry
  */
@@ -96,10 +100,10 @@
     private static final String REGISTRY_FILTER_PROPNAME = "sun.rmi.registry.registryFilter";
 
     /** Registry max depth of remote invocations. **/
-    private static int REGISTRY_MAX_DEPTH = 5;
+    private static final int REGISTRY_MAX_DEPTH = 20;
 
     /** Registry maximum array size in remote invocations. **/
-    private static int REGISTRY_MAX_ARRAY_SIZE = 10000;
+    private static final int REGISTRY_MAX_ARRAY_SIZE = 10000;
 
     /**
      * The registryFilter created from the value of the {@code "sun.rmi.registry.registryFilter"}
@@ -107,11 +111,18 @@
      */
     private static final ObjectInputFilter registryFilter =
         AccessController.doPrivileged(new PrivilegedAction<ObjectInputFilter>() {
-                @Override
-                public ObjectInputFilter run() {
-                    return initRegistryFilter();
-                }
-            });
+            @Override
+            public ObjectInputFilter run() {
+                return initRegistryFilter();
+            }
+        });
+
+    private static final ObjectInputFilter defaultFilter = new ObjectInputFilter() {
+        @Override
+        public Status checkInput(ObjectInputFilter.FilterInfo info) {
+            return RegistryImpl.registryFilter(info);
+        }
+    };
 
     /**
      * Initialize the registryFilter from the security properties or system property; if any
@@ -142,8 +153,22 @@
                         RMIServerSocketFactory ssf)
         throws RemoteException
     {
+        this(port, csf, ssf, defaultFilter);
+    }
+
+
+    /**
+     * Construct a new RegistryImpl on the specified port with the
+     * given custom socket factory pair and ObjectInputFilter.
+     */
+    public RegistryImpl(int port,
+                        RMIClientSocketFactory csf,
+                        RMIServerSocketFactory ssf,
+                        ObjectInputFilter serialFilter)
+        throws RemoteException
+    {
         LiveRef lref = new LiveRef(id, port, csf, ssf);
-        setup(new UnicastServerRef2(lref, registryFilter()));
+        setup(new UnicastServerRef2(lref, serialFilter));
     }
 
     /**
@@ -153,7 +178,7 @@
         throws RemoteException
     {
         LiveRef lref = new LiveRef(id, port);
-        setup(new UnicastServerRef(lref, registryFilter()));
+        setup(new UnicastServerRef(lref, defaultFilter));
     }
 
     /*
@@ -194,7 +219,8 @@
     public void bind(String name, Remote obj)
         throws RemoteException, AlreadyBoundException, AccessException
     {
-        checkAccess("Registry.bind");
+        // The access check preventing remote access is done in the skeleton
+        // and is not applicable to local access.
         synchronized (bindings) {
             Remote curr = bindings.get(name);
             if (curr != null)
@@ -211,7 +237,8 @@
     public void unbind(String name)
         throws RemoteException, NotBoundException, AccessException
     {
-        checkAccess("Registry.unbind");
+        // The access check preventing remote access is done in the skeleton
+        // and is not applicable to local access.
         synchronized (bindings) {
             Remote obj = bindings.get(name);
             if (obj == null)
@@ -227,7 +254,8 @@
     public void rebind(String name, Remote obj)
         throws RemoteException, AccessException
     {
-        checkAccess("Registry.rebind");
+        // The access check preventing remote access is done in the skeleton
+        // and is not applicable to local access.
         bindings.put(name, obj);
     }
 
@@ -254,7 +282,6 @@
      * The client must be on same the same host as this server.
      */
     public static void checkAccess(String op) throws AccessException {
-
         try {
             /*
              * Get client host that this registry operation was made from.
@@ -280,7 +307,7 @@
 
                 if (clientHost.isAnyLocalAddress()) {
                     throw new AccessException(
-                        "Registry." + op + " disallowed; origin unknown");
+                        op + " disallowed; origin unknown");
                 }
 
                 try {
@@ -303,7 +330,7 @@
                     // must have been an IOException
 
                     throw new AccessException(
-                        "Registry." + op + " disallowed; origin " +
+                        op + " disallowed; origin " +
                         clientHost + " is non-local host");
                 }
             }
@@ -312,8 +339,7 @@
              * Local call from this VM: allow access.
              */
         } catch (java.net.UnknownHostException ex) {
-            throw new AccessException("Registry." + op +
-                                      " disallowed; origin is unknown host");
+            throw new AccessException(op + " disallowed; origin is unknown host");
         }
     }
 
@@ -360,53 +386,48 @@
      *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
      *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
      */
-    private static ObjectInputFilter registryFilter() {
-        return new ObjectInputFilter() {
-            @Override
-            public ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
-                if (registryFilter != null) {
-                    ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
-                    if (status != ObjectInputFilter.Status.UNDECIDED) {
-                        // The Registry filter can override the built-in white-list
-                        return status;
-                    }
-                }
+    private static ObjectInputFilter.Status registryFilter(ObjectInputFilter.FilterInfo filterInfo) {
+        if (registryFilter != null) {
+            ObjectInputFilter.Status status = registryFilter.checkInput(filterInfo);
+            if (status != ObjectInputFilter.Status.UNDECIDED) {
+                // The Registry filter can override the built-in white-list
+                return status;
+            }
+        }
 
-                if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
+        if (filterInfo.depth() > REGISTRY_MAX_DEPTH) {
+            return ObjectInputFilter.Status.REJECTED;
+        }
+        Class<?> clazz = filterInfo.serialClass();
+        if (clazz != null) {
+            if (clazz.isArray()) {
+                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE) {
                     return ObjectInputFilter.Status.REJECTED;
                 }
-                Class<?> clazz = filterInfo.serialClass();
-                if (clazz != null) {
-                    if (clazz.isArray()) {
-                        if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE) {
-                            return ObjectInputFilter.Status.REJECTED;
-                        }
-                        do {
-                            // Arrays are allowed depending on the component type
-                            clazz = clazz.getComponentType();
-                        } while (clazz.isArray());
-                    }
-                    if (clazz.isPrimitive()) {
-                        // Arrays of primitives are allowed
-                        return ObjectInputFilter.Status.ALLOWED;
-                    }
-                    if (String.class == clazz
-                        || java.lang.Number.class.isAssignableFrom(clazz)
-                        || Remote.class.isAssignableFrom(clazz)
-                        || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
-                        || UnicastRef.class.isAssignableFrom(clazz)
-                        || RMIClientSocketFactory.class.isAssignableFrom(clazz)
-                        || RMIServerSocketFactory.class.isAssignableFrom(clazz)
-                        || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
-                        || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
-                        return ObjectInputFilter.Status.ALLOWED;
-                    } else {
-                        return ObjectInputFilter.Status.REJECTED;
-                    }
-                }
-                return ObjectInputFilter.Status.UNDECIDED;
+                do {
+                    // Arrays are allowed depending on the component type
+                    clazz = clazz.getComponentType();
+                } while (clazz.isArray());
             }
-        };
+            if (clazz.isPrimitive()) {
+                // Arrays of primitives are allowed
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            if (String.class == clazz
+                    || java.lang.Number.class.isAssignableFrom(clazz)
+                    || Remote.class.isAssignableFrom(clazz)
+                    || java.lang.reflect.Proxy.class.isAssignableFrom(clazz)
+                    || UnicastRef.class.isAssignableFrom(clazz)
+                    || RMIClientSocketFactory.class.isAssignableFrom(clazz)
+                    || RMIServerSocketFactory.class.isAssignableFrom(clazz)
+                    || java.rmi.activation.ActivationID.class.isAssignableFrom(clazz)
+                    || java.rmi.server.UID.class.isAssignableFrom(clazz)) {
+                return ObjectInputFilter.Status.ALLOWED;
+            } else {
+                return ObjectInputFilter.Status.REJECTED;
+            }
+        }
+        return ObjectInputFilter.Status.UNDECIDED;
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/rmi/registry/RegistryImpl_Skel.java	Thu Sep 07 23:37:21 2017 -0700
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.rmi.registry;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.AccessException;
+import java.rmi.server.RemoteCall;
+
+import sun.rmi.transport.Connection;
+import sun.rmi.transport.StreamRemoteCall;
+import sun.rmi.transport.tcp.TCPConnection;
+
+/**
+ * Skeleton to dispatch RegistryImpl methods.
+ * Originally generated by RMIC but frozen to match the stubs.
+ */
+@SuppressWarnings({"deprecation", "serial"})
+public final class RegistryImpl_Skel
+        implements java.rmi.server.Skeleton {
+    private static final java.rmi.server.Operation[] operations = {
+            new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
+            new java.rmi.server.Operation("java.lang.String list()[]"),
+            new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
+            new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
+            new java.rmi.server.Operation("void unbind(java.lang.String)")
+    };
+
+    private static final long interfaceHash = 4905912898345647071L;
+
+    public java.rmi.server.Operation[] getOperations() {
+        return operations.clone();
+    }
+
+    public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash)
+            throws java.lang.Exception {
+        if (hash != interfaceHash)
+            throw new java.rmi.server.SkeletonMismatchException("interface hash mismatch");
+
+        sun.rmi.registry.RegistryImpl server = (sun.rmi.registry.RegistryImpl) obj;
+        switch (opnum) {
+            case 0: // bind(String, Remote)
+            {
+                // Check access before reading the arguments
+                RegistryImpl.checkAccess("Registry.bind");
+
+                java.lang.String $param_String_1;
+                java.rmi.Remote $param_Remote_2;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_String_1 = (java.lang.String) in.readObject();
+                    $param_Remote_2 = (java.rmi.Remote) in.readObject();
+                } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                server.bind($param_String_1, $param_Remote_2);
+                try {
+                    call.getResultStream(true);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            case 1: // list()
+            {
+                call.releaseInputStream();
+                java.lang.String[] $result = server.list();
+                try {
+                    java.io.ObjectOutput out = call.getResultStream(true);
+                    out.writeObject($result);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            case 2: // lookup(String)
+            {
+                java.lang.String $param_String_1;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_String_1 = (java.lang.String) in.readObject();
+                } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                java.rmi.Remote $result = server.lookup($param_String_1);
+                try {
+                    java.io.ObjectOutput out = call.getResultStream(true);
+                    out.writeObject($result);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            case 3: // rebind(String, Remote)
+            {
+                // Check access before reading the arguments
+                RegistryImpl.checkAccess("Registry.rebind");
+
+                java.lang.String $param_String_1;
+                java.rmi.Remote $param_Remote_2;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_String_1 = (java.lang.String) in.readObject();
+                    $param_Remote_2 = (java.rmi.Remote) in.readObject();
+                } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                server.rebind($param_String_1, $param_Remote_2);
+                try {
+                    call.getResultStream(true);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            case 4: // unbind(String)
+            {
+                // Check access before reading the arguments
+                RegistryImpl.checkAccess("Registry.unbind");
+
+                java.lang.String $param_String_1;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_String_1 = (java.lang.String) in.readObject();
+                } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                server.unbind($param_String_1);
+                try {
+                    call.getResultStream(true);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            default:
+                throw new java.rmi.UnmarshalException("invalid method number");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/rmi/registry/RegistryImpl_Stub.java	Thu Sep 07 23:37:21 2017 -0700
@@ -0,0 +1,189 @@
+/*
+ * 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.rmi.registry;
+/**
+ * Stubs to invoke RegistryImpl remote methods.
+ * Originally generated from RMIC but frozen to match RegistryImpl_Skel.
+ */
+@SuppressWarnings({"deprecation", "serial"})
+public final class RegistryImpl_Stub
+        extends java.rmi.server.RemoteStub
+        implements java.rmi.registry.Registry, java.rmi.Remote {
+    private static final java.rmi.server.Operation[] operations = {
+            new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
+            new java.rmi.server.Operation("java.lang.String list()[]"),
+            new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
+            new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
+            new java.rmi.server.Operation("void unbind(java.lang.String)")
+    };
+
+    private static final long interfaceHash = 4905912898345647071L;
+
+    // constructors
+    public RegistryImpl_Stub() {
+        super();
+    }
+
+    public RegistryImpl_Stub(java.rmi.server.RemoteRef ref) {
+        super(ref);
+    }
+
+    // methods from remote interfaces
+
+    // implementation of bind(String, Remote)
+    public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
+            throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_String_1);
+                out.writeObject($param_Remote_2);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            ref.done(call);
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.AlreadyBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    // implementation of list()
+    public java.lang.String[] list()
+            throws java.rmi.AccessException, java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
+            ref.invoke(call);
+            java.lang.String[] $result;
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $result = (java.lang.String[]) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("error unmarshalling return", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("error unmarshalling return", e);
+            } finally {
+                ref.done(call);
+            }
+            return $result;
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    // implementation of lookup(String)
+    public java.rmi.Remote lookup(java.lang.String $param_String_1)
+            throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_String_1);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            java.rmi.Remote $result;
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+                $result = (java.rmi.Remote) in.readObject();
+            } catch (java.io.IOException e) {
+                throw new java.rmi.UnmarshalException("error unmarshalling return", e);
+            } catch (java.lang.ClassNotFoundException e) {
+                throw new java.rmi.UnmarshalException("error unmarshalling return", e);
+            } finally {
+                ref.done(call);
+            }
+            return $result;
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.NotBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    // implementation of rebind(String, Remote)
+    public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
+            throws java.rmi.AccessException, java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_String_1);
+                out.writeObject($param_Remote_2);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            ref.done(call);
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    // implementation of unbind(String)
+    public void unbind(java.lang.String $param_String_1)
+            throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_String_1);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            ref.done(call);
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.rmi.NotBoundException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+}
--- a/src/share/classes/sun/rmi/runtime/Log.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/runtime/Log.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,7 @@
  * @author Laird Dornin
  * @since 1.4
  */
+@SuppressWarnings("deprecation")
 public abstract class Log {
 
     /** Logger re-definition of old RMI log values */
--- a/src/share/classes/sun/rmi/server/ActivatableRef.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/ActivatableRef.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,7 @@
 import java.rmi.server.RemoteRef;
 import java.rmi.server.RemoteStub;
 
+@SuppressWarnings("deprecation")
 public class ActivatableRef implements RemoteRef {
 
     private static final long serialVersionUID = 7579060052569229166L;
--- a/src/share/classes/sun/rmi/server/Activation.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/Activation.java	Thu Sep 07 23:37:21 2017 -0700
@@ -30,6 +30,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ObjectInput;
 import java.io.ObjectInputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
@@ -105,7 +106,6 @@
 import sun.rmi.log.ReliableLog;
 import sun.rmi.registry.RegistryImpl;
 import sun.rmi.runtime.NewThreadAction;
-import sun.rmi.server.UnicastServerRef;
 import sun.rmi.transport.LiveRef;
 import sun.security.action.GetBooleanAction;
 import sun.security.action.GetIntegerAction;
@@ -345,6 +345,7 @@
                 throw new AccessException(
                     "binding ActivationSystem is disallowed");
             } else {
+                RegistryImpl.checkAccess("ActivationSystem.bind");
                 super.bind(name, obj);
             }
         }
@@ -356,6 +357,7 @@
                 throw new AccessException(
                     "unbinding ActivationSystem is disallowed");
             } else {
+                RegistryImpl.checkAccess("ActivationSystem.unbind");
                 super.unbind(name);
             }
         }
@@ -368,6 +370,7 @@
                 throw new AccessException(
                     "binding ActivationSystem is disallowed");
             } else {
+                RegistryImpl.checkAccess("ActivationSystem.rebind");
                 super.rebind(name, obj);
             }
         }
@@ -458,6 +461,33 @@
     }
 
 
+    /**
+     * SameHostOnlyServerRef checks that access is from a local client
+     * before the parameters are deserialized.  The unmarshalCustomCallData
+     * hook is used to check the network address of the caller
+     * with RegistryImpl.checkAccess().
+     * The kind of access is retained for an exception if one is thrown.
+     */
+    static class SameHostOnlyServerRef extends UnicastServerRef {
+        private static final long serialVersionUID = 1234L;
+        private String accessKind;      // an exception message
+
+        /**
+         * Construct a new SameHostOnlyServerRef from a LiveRef.
+         * @param lref a LiveRef
+         */
+        SameHostOnlyServerRef(LiveRef lref, String accessKind) {
+            super(lref);
+            this.accessKind = accessKind;
+        }
+
+        @Override
+        protected void unmarshalCustomCallData(ObjectInput in) throws IOException, ClassNotFoundException {
+            RegistryImpl.checkAccess(accessKind);
+            super.unmarshalCustomCallData(in);
+        }
+    }
+
     class ActivationSystemImpl
         extends RemoteServer
         implements ActivationSystem
@@ -475,7 +505,8 @@
              * 'this' can be exported.
              */
             LiveRef lref = new LiveRef(new ObjID(4), port, null, ssf);
-            UnicastServerRef uref = new UnicastServerRef(lref);
+            UnicastServerRef uref = new SameHostOnlyServerRef(lref,
+                    "ActivationSystem.nonLocalAccess");
             ref = uref;
             uref.exportObject(this, null);
         }
@@ -484,8 +515,8 @@
             throws ActivationException, UnknownGroupException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.registerObject");
-
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
             ActivationGroupID groupID = desc.getGroupID();
             ActivationID id = new ActivationID(activatorStub);
             getGroupEntry(groupID).registerObject(id, desc, true);
@@ -496,15 +527,18 @@
             throws ActivationException, UnknownObjectException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.unregisterObject");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
             getGroupEntry(id).unregisterObject(id, true);
         }
 
         public ActivationGroupID registerGroup(ActivationGroupDesc desc)
             throws ActivationException, RemoteException
         {
+            Thread.dumpStack();
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.registerGroup");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
             checkArgs(desc, null);
 
             ActivationGroupID id = new ActivationGroupID(systemStub);
@@ -521,7 +555,8 @@
             throws ActivationException, UnknownGroupException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.activeGroup");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             getGroupEntry(id).activeGroup(group, incarnation);
             return monitor;
@@ -531,7 +566,8 @@
             throws ActivationException, UnknownGroupException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.unregisterGroup");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             // remove entry before unregister so state is updated before
             // logged
@@ -543,7 +579,8 @@
             throws ActivationException, UnknownObjectException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.setActivationDesc");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             if (!getGroupID(id).equals(desc.getGroupID())) {
                 throw new ActivationException(
@@ -557,8 +594,8 @@
             throws ActivationException, UnknownGroupException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess(
-                "ActivationSystem.setActivationGroupDesc");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             checkArgs(desc, null);
             return getGroupEntry(id).setActivationGroupDesc(id, desc, true);
@@ -568,7 +605,8 @@
             throws ActivationException, UnknownObjectException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess("ActivationSystem.getActivationDesc");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             return getGroupEntry(id).getActivationDesc(id);
         }
@@ -577,8 +615,8 @@
             throws ActivationException, UnknownGroupException, RemoteException
         {
             checkShutdown();
-            RegistryImpl.checkAccess
-                ("ActivationSystem.getActivationGroupDesc");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             return getGroupEntry(id).desc;
         }
@@ -588,7 +626,8 @@
          * the activation daemon and exits the activation daemon.
          */
         public void shutdown() throws AccessException {
-            RegistryImpl.checkAccess("ActivationSystem.shutdown");
+            // RegistryImpl.checkAccess() is done in the SameHostOnlyServerRef
+            // during unmarshallCustomData and is not applicable to local access.
 
             Object lock = startupLock;
             if (lock != null) {
--- a/src/share/classes/sun/rmi/server/Dispatcher.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/Dispatcher.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
  * The Dispatcher interface allows the transport to make
  * the upcall to the server side remote reference.
  */
+@SuppressWarnings("deprecation")
 public interface Dispatcher {
 
     /**
--- a/src/share/classes/sun/rmi/server/LoaderHandler.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/LoaderHandler.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,7 @@
  * @author      Peter Jones
  * @author      Laird Dornin
  */
+@SuppressWarnings("deprecation")
 public final class LoaderHandler {
 
     /** RMI class loader log level */
--- a/src/share/classes/sun/rmi/server/UnicastRef.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/UnicastRef.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 import java.rmi.MarshalException;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
-import java.rmi.ServerException;
 import java.rmi.UnmarshalException;
 import java.rmi.server.Operation;
 import java.rmi.server.RemoteCall;
@@ -49,7 +48,8 @@
  * NOTE: There is a JDK-internal dependency on the existence of this
  * class's getLiveRef method (as it is inherited by UnicastRef2) in
  * the implementation of javax.management.remote.rmi.RMIConnector.
- **/
+ */
+@SuppressWarnings("deprecation")
 public class UnicastRef implements RemoteRef {
 
     /**
@@ -186,14 +186,11 @@
 
                 return returnValue;
 
-            } catch (IOException e) {
+            } catch (IOException | ClassNotFoundException e) {
+                // disable saving any refs in the inputStream for GC
+                ((StreamRemoteCall)call).discardPendingRefs();
                 clientRefLog.log(Log.BRIEF,
-                                 "IOException unmarshalling return: ", e);
-                throw new UnmarshalException("error unmarshalling return", e);
-            } catch (ClassNotFoundException e) {
-                clientRefLog.log(Log.BRIEF,
-                    "ClassNotFoundException unmarshalling return: ", e);
-
+                                 e.getClass().getName() + " unmarshalling return: ", e);
                 throw new UnmarshalException("error unmarshalling return", e);
             } finally {
                 try {
--- a/src/share/classes/sun/rmi/server/UnicastServerRef.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/UnicastServerRef.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.io.ObjectStreamClass;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.rmi.AccessException;
 import java.rmi.MarshalException;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
@@ -57,6 +58,7 @@
 import sun.misc.ObjectInputFilter;
 import sun.rmi.runtime.Log;
 import sun.rmi.transport.LiveRef;
+import sun.rmi.transport.StreamRemoteCall;
 import sun.rmi.transport.Target;
 import sun.rmi.transport.tcp.TCPTransport;
 import sun.security.action.GetBooleanAction;
@@ -74,6 +76,7 @@
  * @author  Roger Riggs
  * @author  Peter Jones
  */
+@SuppressWarnings("deprecation")
 public class UnicastServerRef extends UnicastRef
     implements ServerRef, Dispatcher
 {
@@ -288,20 +291,25 @@
             try {
                 in = call.getInputStream();
                 num = in.readInt();
-                if (num >= 0) {
-                    if (skel != null) {
-                        oldDispatch(obj, call, num);
-                        return;
-                    } else {
-                        throw new UnmarshalException(
-                            "skeleton class not found but required " +
-                            "for client version");
-                    }
+            } catch (Exception readEx) {
+                throw new UnmarshalException("error unmarshalling call header",
+                                             readEx);
+            }
+            if (num >= 0) {
+                if (skel != null) {
+                    oldDispatch(obj, call, num);
+                    return;
+                } else {
+                    throw new UnmarshalException(
+                        "skeleton class not found but required " +
+                        "for client version");
                 }
+            }
+            try {
                 op = in.readLong();
             } catch (Exception readEx) {
                 throw new UnmarshalException("error unmarshalling call header",
-                                             readEx);
+                        readEx);
             }
 
             /*
@@ -329,10 +337,14 @@
             try {
                 unmarshalCustomCallData(in);
                 params = unmarshalParameters(obj, method, marshalStream);
-            } catch (java.io.IOException e) {
-                throw new UnmarshalException(
-                    "error unmarshalling arguments", e);
-            } catch (ClassNotFoundException e) {
+            } catch (AccessException aex) {
+                // For compatibility, AccessException is not wrapped in UnmarshalException
+                // disable saving any refs in the inputStream for GC
+                ((StreamRemoteCall) call).discardPendingRefs();
+                throw aex;
+            } catch (java.io.IOException | ClassNotFoundException e) {
+                // disable saving any refs in the inputStream for GC
+                ((StreamRemoteCall) call).discardPendingRefs();
                 throw new UnmarshalException(
                     "error unmarshalling arguments", e);
             } finally {
@@ -366,6 +378,7 @@
                  */
             }
         } catch (Throwable e) {
+            Throwable origEx = e;
             logCallException(e);
 
             ObjectOutput out = call.getResultStream(false);
@@ -381,6 +394,12 @@
                 clearStackTraces(e);
             }
             out.writeObject(e);
+
+            // AccessExceptions should cause Transport.serviceCall
+            // to flag the connection as unusable.
+            if (origEx instanceof AccessException) {
+                throw new IOException("Connection is not reusable", origEx);
+            }
         } finally {
             call.releaseInputStream(); // in case skeleton doesn't
             call.releaseOutputStream();
@@ -412,62 +431,41 @@
      * Handle server-side dispatch using the RMI 1.1 stub/skeleton
      * protocol, given a non-negative operation number that has
      * already been read from the call stream.
+     * Exceptions are handled by the caller to be sent to the remote client.
      *
      * @param obj the target remote object for the call
      * @param call the "remote call" from which operation and
      * method arguments can be obtained.
      * @param op the operation number
-     * @exception IOException if unable to marshal return result or
+     * @throws Exception if unable to marshal return result or
      * release input or output streams
      */
-    public void oldDispatch(Remote obj, RemoteCall call, int op)
-        throws IOException
+    private void oldDispatch(Remote obj, RemoteCall call, int op)
+        throws Exception
     {
         long hash;              // hash for matching stub with skeleton
 
+        // read remote call header
+        ObjectInput in;
+        in = call.getInputStream();
         try {
-            // read remote call header
-            ObjectInput in;
-            try {
-                in = call.getInputStream();
-                try {
-                    Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
-                    if (clazz.isAssignableFrom(skel.getClass())) {
-                        ((MarshalInputStream)in).useCodebaseOnly();
-                    }
-                } catch (ClassNotFoundException ignore) { }
-                hash = in.readLong();
-            } catch (Exception readEx) {
-                throw new UnmarshalException("error unmarshalling call header",
-                                             readEx);
+            Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
+            if (clazz.isAssignableFrom(skel.getClass())) {
+                ((MarshalInputStream)in).useCodebaseOnly();
             }
+        } catch (ClassNotFoundException ignore) { }
 
-            // if calls are being logged, write out object id and operation
-            logCall(obj, skel.getOperations()[op]);
-            unmarshalCustomCallData(in);
-            // dispatch to skeleton for remote object
-            skel.dispatch(obj, call, op, hash);
+        try {
+            hash = in.readLong();
+        } catch (Exception ioe) {
+            throw new UnmarshalException("error unmarshalling call header", ioe);
+        }
 
-        } catch (Throwable e) {
-            logCallException(e);
-
-            ObjectOutput out = call.getResultStream(false);
-            if (e instanceof Error) {
-                e = new ServerError(
-                    "Error occurred in server thread", (Error) e);
-            } else if (e instanceof RemoteException) {
-                e = new ServerException(
-                    "RemoteException occurred in server thread",
-                    (Exception) e);
-            }
-            if (suppressStackTraces) {
-                clearStackTraces(e);
-            }
-            out.writeObject(e);
-        } finally {
-            call.releaseInputStream(); // in case skeleton doesn't
-            call.releaseOutputStream();
-        }
+        // if calls are being logged, write out object id and operation
+        logCall(obj, skel.getOperations()[op]);
+        unmarshalCustomCallData(in);
+        // dispatch to skeleton for remote object
+        skel.dispatch(obj, call, op, hash);
     }
 
     /**
--- a/src/share/classes/sun/rmi/server/Util.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/server/Util.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,7 @@
  * A utility class with static methods for creating stubs/proxies and
  * skeletons for remote objects.
  */
+@SuppressWarnings("deprecation")
 public final class Util {
 
     /** "server" package log level */
--- a/src/share/classes/sun/rmi/transport/ConnectionInputStream.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/ConnectionInputStream.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,6 +82,14 @@
     }
 
     /**
+     * Discard the saved incoming refs so there is nothing to register
+     * when {@code registerRefs} is called.
+     */
+    void discardRefs() {
+        incomingRefTable.clear();
+    }
+
+    /**
      * Add references to DGC table (and possibly send dirty call).
      * RegisterRefs now calls DGCClient.referenced on all
      * refs with the same endpoint at once to achieve batching of
--- a/src/share/classes/sun/rmi/transport/DGCClient.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/DGCClient.java	Thu Sep 07 23:37:21 2017 -0700
@@ -24,9 +24,11 @@
  */
 package sun.rmi.transport;
 
+import java.io.InvalidClassException;
 import java.lang.ref.PhantomReference;
 import java.lang.ref.ReferenceQueue;
 import java.net.SocketPermission;
+import java.rmi.UnmarshalException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
@@ -41,7 +43,9 @@
 import java.rmi.dgc.Lease;
 import java.rmi.dgc.VMID;
 import java.rmi.server.ObjID;
+
 import sun.misc.GC;
+import sun.rmi.runtime.Log;
 import sun.rmi.runtime.NewThreadAction;
 import sun.rmi.server.UnicastRef;
 import sun.rmi.server.Util;
@@ -393,6 +397,12 @@
                 synchronized (this) {
                     dirtyFailures++;
 
+                    if (e instanceof UnmarshalException
+                            && e.getCause() instanceof InvalidClassException) {
+                        DGCImpl.dgcLog.log(Log.BRIEF, "InvalidClassException exception in DGC dirty call", e);
+                        return;             // protocol error, do not register these refs
+                    }
+
                     if (dirtyFailures == 1) {
                         /*
                          * If this was the first recent failed dirty call,
--- a/src/share/classes/sun/rmi/transport/DGCImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/DGCImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -68,6 +68,7 @@
  *
  * @author Ann Wollrath
  */
+@SuppressWarnings("deprecation")
 final class DGCImpl implements DGC {
 
     /* dgc system log */
@@ -344,7 +345,13 @@
                         final ObjID dgcID = new ObjID(ObjID.DGC_ID);
                         LiveRef ref = new LiveRef(dgcID, 0);
                         final UnicastServerRef disp = new UnicastServerRef(ref,
-                                                                           inputFilter());
+                               new ObjectInputFilter() {
+                                   @Override
+                                   public ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
+                                       return DGCImpl.checkInput(filterInfo);
+                                   }
+                               }
+                        );
                         final Remote stub =
                             Util.createProxy(DGCImpl.class,
                                              new UnicastRef(ref), true);
@@ -385,47 +392,43 @@
      *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
      *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
      */
-    private static ObjectInputFilter inputFilter() {
-        return new ObjectInputFilter() {
-            @Override
-            public ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
-                if (dgcFilter != null) {
-                    ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
-                    if (status != ObjectInputFilter.Status.UNDECIDED) {
-                        // The DGC filter can override the built-in white-list
-                        return status;
-                    }
-                }
+    private static ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo filterInfo) {
+        if (dgcFilter != null) {
+            ObjectInputFilter.Status status = dgcFilter.checkInput(filterInfo);
+            if (status != ObjectInputFilter.Status.UNDECIDED) {
+                // The DGC filter can override the built-in white-list
+                return status;
+            }
+        }
 
-                if (filterInfo.depth() > DGC_MAX_DEPTH) {
+        if (filterInfo.depth() > DGC_MAX_DEPTH) {
+            return ObjectInputFilter.Status.REJECTED;
+        }
+        Class<?> clazz = filterInfo.serialClass();
+        if (clazz != null) {
+            while (clazz.isArray()) {
+                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
                     return ObjectInputFilter.Status.REJECTED;
                 }
-                Class<?> clazz = filterInfo.serialClass();
-                if (clazz != null) {
-                    while (clazz.isArray()) {
-                        if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGC_MAX_ARRAY_SIZE) {
-                            return ObjectInputFilter.Status.REJECTED;
-                        }
-                        // Arrays are allowed depending on the component type
-                        clazz = clazz.getComponentType();
-                    }
-                    if (clazz.isPrimitive()) {
-                        // Arrays of primitives are allowed
-                        return ObjectInputFilter.Status.ALLOWED;
-                    }
-                    return (clazz == ObjID.class ||
-                            clazz == UID.class ||
-                            clazz == VMID.class ||
-                            clazz == Lease.class)
-                        ? ObjectInputFilter.Status.ALLOWED
-                        : ObjectInputFilter.Status.REJECTED;
-                }
-                // Not a class, not size limited
-                return ObjectInputFilter.Status.UNDECIDED;
+                // Arrays are allowed depending on the component type
+                clazz = clazz.getComponentType();
             }
-        };
+            if (clazz.isPrimitive()) {
+                // Arrays of primitives are allowed
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            return (clazz == ObjID.class ||
+                    clazz == UID.class ||
+                    clazz == VMID.class ||
+                    clazz == Lease.class)
+                    ? ObjectInputFilter.Status.ALLOWED
+                    : ObjectInputFilter.Status.REJECTED;
+        }
+        // Not a class, not size limited
+        return ObjectInputFilter.Status.UNDECIDED;
     }
 
+
     private static class LeaseInfo {
         VMID vmid;
         long expiration;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/rmi/transport/DGCImpl_Skel.java	Thu Sep 07 23:37:21 2017 -0700
@@ -0,0 +1,112 @@
+/*
+ * 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.rmi.transport;
+
+/**
+ * Skeleton to dispatch DGC methods.
+ * Originally generated by RMIC but frozen to match the stubs.
+ */
+@SuppressWarnings({"deprecation", "serial"})
+public final class DGCImpl_Skel
+        implements java.rmi.server.Skeleton {
+    private static final java.rmi.server.Operation[] operations = {
+            new java.rmi.server.Operation("void clean(java.rmi.server.ObjID[], long, java.rmi.dgc.VMID, boolean)"),
+            new java.rmi.server.Operation("java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)")
+    };
+
+    private static final long interfaceHash = -669196253586618813L;
+
+    public java.rmi.server.Operation[] getOperations() {
+        return operations.clone();
+    }
+
+    public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash)
+            throws java.lang.Exception {
+        if (hash != interfaceHash)
+            throw new java.rmi.server.SkeletonMismatchException("interface hash mismatch");
+
+        sun.rmi.transport.DGCImpl server = (sun.rmi.transport.DGCImpl) obj;
+        switch (opnum) {
+            case 0: // clean(ObjID[], long, VMID, boolean)
+            {
+                java.rmi.server.ObjID[] $param_arrayOf_ObjID_1;
+                long $param_long_2;
+                java.rmi.dgc.VMID $param_VMID_3;
+                boolean $param_boolean_4;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_arrayOf_ObjID_1 = (java.rmi.server.ObjID[]) in.readObject();
+                    $param_long_2 = in.readLong();
+                    $param_VMID_3 = (java.rmi.dgc.VMID) in.readObject();
+                    $param_boolean_4 = in.readBoolean();
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } catch (java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                server.clean($param_arrayOf_ObjID_1, $param_long_2, $param_VMID_3, $param_boolean_4);
+                try {
+                    call.getResultStream(true);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            case 1: // dirty(ObjID[], long, Lease)
+            {
+                java.rmi.server.ObjID[] $param_arrayOf_ObjID_1;
+                long $param_long_2;
+                java.rmi.dgc.Lease $param_Lease_3;
+                try {
+                    java.io.ObjectInput in = call.getInputStream();
+                    $param_arrayOf_ObjID_1 = (java.rmi.server.ObjID[]) in.readObject();
+                    $param_long_2 = in.readLong();
+                    $param_Lease_3 = (java.rmi.dgc.Lease) in.readObject();
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } catch (java.lang.ClassNotFoundException e) {
+                    throw new java.rmi.UnmarshalException("error unmarshalling arguments", e);
+                } finally {
+                    call.releaseInputStream();
+                }
+                java.rmi.dgc.Lease $result = server.dirty($param_arrayOf_ObjID_1, $param_long_2, $param_Lease_3);
+                try {
+                    java.io.ObjectOutput out = call.getResultStream(true);
+                    out.writeObject($result);
+                } catch (java.io.IOException e) {
+                    throw new java.rmi.MarshalException("error marshalling return", e);
+                }
+                break;
+            }
+
+            default:
+                throw new java.rmi.UnmarshalException("invalid method number");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/rmi/transport/DGCImpl_Stub.java	Thu Sep 07 23:37:21 2017 -0700
@@ -0,0 +1,192 @@
+/*
+ * 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.rmi.transport;
+
+import java.io.ObjectInputStream;
+import java.rmi.dgc.Lease;
+import java.rmi.dgc.VMID;
+import java.rmi.server.UID;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import sun.misc.ObjectInputFilter;
+import sun.rmi.server.UnicastRef;
+import sun.rmi.transport.tcp.TCPConnection;
+
+/**
+ * Stubs to invoke DGC remote methods.
+ * Originally generated from RMIC but frozen to insert serialFilter.
+ */
+@SuppressWarnings({"deprecation", "serial"})
+public final class DGCImpl_Stub
+        extends java.rmi.server.RemoteStub
+        implements java.rmi.dgc.DGC {
+    private static final java.rmi.server.Operation[] operations = {
+            new java.rmi.server.Operation("void clean(java.rmi.server.ObjID[], long, java.rmi.dgc.VMID, boolean)"),
+            new java.rmi.server.Operation("java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)")
+    };
+
+    private static final long interfaceHash = -669196253586618813L;
+
+    /** Registry max depth of remote invocations. **/
+    private static int DGCCLIENT_MAX_DEPTH = 6;
+
+    /** Registry maximum array size in remote invocations. **/
+    private static int DGCCLIENT_MAX_ARRAY_SIZE = 10000;
+
+    // constructors
+    public DGCImpl_Stub() {
+        super();
+    }
+
+    public DGCImpl_Stub(java.rmi.server.RemoteRef ref) {
+        super(ref);
+    }
+
+    // methods from remote interfaces
+
+    // implementation of clean(ObjID[], long, VMID, boolean)
+    public void clean(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.VMID $param_VMID_3, boolean $param_boolean_4)
+            throws java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_arrayOf_ObjID_1);
+                out.writeLong($param_long_2);
+                out.writeObject($param_VMID_3);
+                out.writeBoolean($param_boolean_4);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            ref.done(call);
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    // implementation of dirty(ObjID[], long, Lease)
+    public java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.Lease $param_Lease_3)
+            throws java.rmi.RemoteException {
+        try {
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
+            try {
+                java.io.ObjectOutput out = call.getOutputStream();
+                out.writeObject($param_arrayOf_ObjID_1);
+                out.writeLong($param_long_2);
+                out.writeObject($param_Lease_3);
+            } catch (java.io.IOException e) {
+                throw new java.rmi.MarshalException("error marshalling arguments", e);
+            }
+            ref.invoke(call);
+            java.rmi.dgc.Lease $result;
+            Connection connection = ((StreamRemoteCall) call).getConnection();
+            try {
+                java.io.ObjectInput in = call.getInputStream();
+
+                if (in instanceof ObjectInputStream) {
+                    /**
+                     * Set a filter on the stream for the return value.
+                     */
+                    final ObjectInputStream ois = (ObjectInputStream) in;
+                    AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                        @Override
+                        public Void run() {
+                            ObjectInputFilter.Config.setObjectInputFilter(ois,
+                                new ObjectInputFilter() {
+                                    @Override
+                                    public Status checkInput(FilterInfo info) {
+                                        return DGCImpl_Stub.leaseFilter(info);
+                                    }
+                                });
+                            return null;
+                        }
+                    });
+                }
+                $result = (java.rmi.dgc.Lease) in.readObject();
+            } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
+                if (connection instanceof TCPConnection) {
+                    // Modified to prevent re-use of the connection after an exception
+                    ((TCPConnection) connection).getChannel().free(connection, false);
+                }
+                throw new java.rmi.UnmarshalException("error unmarshalling return", e);
+            } finally {
+                ref.done(call);
+            }
+            return $result;
+        } catch (java.lang.RuntimeException e) {
+            throw e;
+        } catch (java.rmi.RemoteException e) {
+            throw e;
+        } catch (java.lang.Exception e) {
+            throw new java.rmi.UnexpectedException("undeclared checked exception", e);
+        }
+    }
+
+    /**
+     * ObjectInputFilter to filter DGCClient return value (a Lease).
+     * The list of acceptable classes is very short and explicit.
+     * The depth and array sizes are limited.
+     *
+     * @param filterInfo access to class, arrayLength, etc.
+     * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
+     *          {@link ObjectInputFilter.Status#REJECTED} if rejected,
+     *          otherwise {@link ObjectInputFilter.Status#UNDECIDED}
+     */
+    private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo filterInfo) {
+
+        if (filterInfo.depth() > DGCCLIENT_MAX_DEPTH) {
+            return ObjectInputFilter.Status.REJECTED;
+        }
+        Class<?> clazz = filterInfo.serialClass();
+        if (clazz != null) {
+            while (clazz.isArray()) {
+                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > DGCCLIENT_MAX_ARRAY_SIZE) {
+                    return ObjectInputFilter.Status.REJECTED;
+                }
+                // Arrays are allowed depending on the component type
+                clazz = clazz.getComponentType();
+            }
+            if (clazz.isPrimitive()) {
+                // Arrays of primitives are allowed
+                return ObjectInputFilter.Status.ALLOWED;
+            }
+            return (clazz == UID.class ||
+                    clazz == VMID.class ||
+                    clazz == Lease.class)
+                    ? ObjectInputFilter.Status.ALLOWED
+                    : ObjectInputFilter.Status.REJECTED;
+        }
+        // Not a class, not size limited
+        return ObjectInputFilter.Status.UNDECIDED;
+    }
+
+}
--- a/src/share/classes/sun/rmi/transport/StreamRemoteCall.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/StreamRemoteCall.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@
  *
  * @author Ann Wollrath
  */
+@SuppressWarnings("deprecation")
 public class StreamRemoteCall implements RemoteCall {
     private ConnectionInputStream in = null;
     private ConnectionOutputStream out = null;
@@ -167,6 +168,13 @@
     }
 
     /**
+     * Discard any post-processing of refs the InputStream.
+     */
+    public void discardPendingRefs() {
+        in.discardRefs();
+    }
+
+    /**
      * Returns an output stream (may put out header information
      * relating to the success of the call).
      * @param success If true, indicates normal return, else indicates
--- a/src/share/classes/sun/rmi/transport/Transport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/Transport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -51,6 +51,7 @@
  *
  * @author Ann Wollrath
  */
+@SuppressWarnings("deprecation")
 public abstract class Transport {
 
     /** "transport" package log level */
--- a/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/proxy/RMIMasterSocketFactory.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@
  * connect to the same host will automatically use the same
  * mechanism.
  */
+@SuppressWarnings("deprecation")
 public class RMIMasterSocketFactory extends RMISocketFactory {
 
     /** "proxy" package log level */
--- a/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/tcp/ConnectionMultiplexer.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
  *
  * @author Peter Jones
  */
+@SuppressWarnings("deprecation")
 final class ConnectionMultiplexer {
 
     /** "multiplex" log level */
--- a/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/rmi/transport/tcp/TCPTransport.java	Thu Sep 07 23:37:21 2017 -0700
@@ -87,6 +87,7 @@
  * @author Ann Wollrath
  * @author Peter Jones
  */
+@SuppressWarnings("deprecation")
 public class TCPTransport extends Transport {
 
     /* tcp package log */
--- a/src/share/classes/sun/security/ec/ECDSASignature.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/ec/ECDSASignature.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -286,11 +286,15 @@
         }
         random.nextBytes(seed);
 
+        // random bits needed for timing countermeasures
+        int timingArgument = random.nextInt();
+        // values must be non-zero to enable countermeasures
+        timingArgument |= 1;
+
         try {
-
             return encodeSignature(
-                signDigest(getDigestValue(), s, encodedParams, seed));
-
+                signDigest(getDigestValue(), s, encodedParams, seed,
+                    timingArgument));
         } catch (GeneralSecurityException e) {
             throw new SignatureException("Could not sign data", e);
         }
@@ -416,11 +420,19 @@
      * @param s the private key's S value.
      * @param encodedParams the curve's DER encoded object identifier.
      * @param seed the random seed.
+     * @param timing When non-zero, the implmentation will use timing
+     *     countermeasures to hide secrets from timing channels. The EC
+     *     implementation will disable the countermeasures when this value is
+     *     zero, because the underlying EC functions are shared by several
+     *     crypto operations, some of which do not use the countermeasures.
+     *     The high-order 31 bits must be uniformly random. The entropy from
+     *     these bits is used by the countermeasures.
      *
      * @return byte[] the signature.
      */
     private static native byte[] signDigest(byte[] digest, byte[] s,
-        byte[] encodedParams, byte[] seed) throws GeneralSecurityException;
+        byte[] encodedParams, byte[] seed, int timing)
+            throws GeneralSecurityException;
 
     /**
      * Verifies the signed digest using the public key.
--- a/src/share/classes/sun/security/pkcs/PKCS8Key.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/pkcs/PKCS8Key.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.security.KeyRep;
 import java.security.PrivateKey;
 import java.security.KeyFactory;
+import java.security.MessageDigest;
 import java.security.Security;
 import java.security.Provider;
 import java.security.InvalidKeyException;
@@ -420,18 +421,9 @@
             // that encoding
             byte[] b2 = ((Key)object).getEncoded();
 
-            // do the comparison
-            int i;
-            if (b1.length != b2.length)
-                return false;
-            for (i = 0; i < b1.length; i++) {
-                if (b1[i] != b2[i]) {
-                    return false;
-                }
-            }
-            return true;
+            // time-constant comparison
+            return MessageDigest.isEqual(b1, b2);
         }
-
         return false;
     }
 
--- a/src/share/classes/sun/security/provider/ByteArrayAccess.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/provider/ByteArrayAccess.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -94,7 +94,7 @@
         String arch = java.security.AccessController.doPrivileged
             (new sun.security.action.GetPropertyAction("os.arch", ""));
         return arch.equals("i386") || arch.equals("x86") || arch.equals("amd64")
-            || arch.equals("x86_64");
+            || arch.equals("x86_64") || arch.equals("ppc64") || arch.equals("ppc64le");
     }
 
     /**
--- a/src/share/classes/sun/security/provider/DSA.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/provider/DSA.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,13 @@
     /* Are we debugging? */
     private static final boolean debug = false;
 
+    /* The number of bits used in exponent blinding */
+    private static final int BLINDING_BITS = 7;
+
+    /* The constant component of the exponent blinding value */
+    private static final BigInteger BLINDING_CONSTANT =
+        BigInteger.valueOf(1 << BLINDING_BITS);
+
     /* The parameter object */
     private DSAParams params;
 
@@ -312,8 +319,19 @@
         return null;
     }
 
+
     private BigInteger generateR(BigInteger p, BigInteger q, BigInteger g,
                          BigInteger k) {
+
+        // exponent blinding to hide information from timing channel
+        SecureRandom random = getSigningRandom();
+        // start with a random blinding component
+        BigInteger blindingValue = new BigInteger(BLINDING_BITS, random);
+        // add the fixed blinding component
+        blindingValue = blindingValue.add(BLINDING_CONSTANT);
+        // replace k with a blinded value that is congruent (mod q)
+        k = k.add(q.multiply(blindingValue));
+
         BigInteger temp = g.modPow(k, p);
         return temp.mod(q);
     }
@@ -378,43 +396,8 @@
         byte[] kValue = new byte[(q.bitLength() + 7)/8 + 8];
 
         random.nextBytes(kValue);
-        BigInteger k = new BigInteger(1, kValue).mod(
+        return new BigInteger(1, kValue).mod(
                 q.subtract(BigInteger.ONE)).add(BigInteger.ONE);
-
-        // Using an equivalent exponent of fixed length (same as q or 1 bit
-        // less than q) to keep the kG timing relatively constant.
-        //
-        // Note that this is an extra step on top of the approach defined in
-        // FIPS 186-4 AppendixB.2.1 so as to make a fixed length K.
-        k = k.add(q).divide(BigInteger.valueOf(2));
-
-        // An alternative implementation based on FIPS 186-4 AppendixB2.2
-        // with fixed-length K.
-        //
-        // Please keep it here as we may need to switch to it in the future.
-        //
-        // SecureRandom random = getSigningRandom();
-        // byte[] kValue = new byte[(q.bitLength() + 7)/8];
-        // BigInteger d = q.subtract(BigInteger.TWO);
-        // BigInteger k;
-        // do {
-        //     random.nextBytes(kValue);
-        //     BigInteger c = new BigInteger(1, kValue);
-        //     if (c.compareTo(d) <= 0) {
-        //         k = c.add(BigInteger.ONE);
-        //         // Using an equivalent exponent of fixed length to keep
-        //         // the g^k timing relatively constant.
-        //         //
-        //         // Note that this is an extra step on top of the approach
-        //         // defined in FIPS 186-4 AppendixB.2.2 so as to make a
-        //         // fixed length K.
-        //         if (k.bitLength() >= q.bitLength()) {
-        //             break;
-        //         }
-        //     }
-        // } while (true);
-
-        return k;
     }
 
     // Use the application-specified SecureRandom Object if provided.
--- a/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java	Thu Sep 07 23:37:21 2017 -0700
@@ -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
@@ -264,7 +264,7 @@
              */
             Hashtable<?,?> currentEnv = ctx.getEnvironment();
             if (currentEnv.get(Context.REFERRAL) == null) {
-                ctx.addToEnvironment(Context.REFERRAL, "follow");
+                ctx.addToEnvironment(Context.REFERRAL, "follow-scheme");
             }
         } catch (NamingException e) {
             if (debug != null) {
--- a/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -191,14 +191,22 @@
             if (version != 0) {
                 throw new IOException("Version must be 0");
             }
-            n = getBigInteger(data);
-            e = getBigInteger(data);
-            d = getBigInteger(data);
-            p = getBigInteger(data);
-            q = getBigInteger(data);
-            pe = getBigInteger(data);
-            qe = getBigInteger(data);
-            coeff = getBigInteger(data);
+
+            /*
+             * Some implementations do not correctly encode ASN.1 INTEGER values
+             * in 2's complement format, resulting in a negative integer when
+             * decoded. Correct the error by converting it to a positive integer.
+             *
+             * See CR 6255949
+             */
+            n = data.getPositiveBigInteger();
+            e = data.getPositiveBigInteger();
+            d = data.getPositiveBigInteger();
+            p = data.getPositiveBigInteger();
+            q = data.getPositiveBigInteger();
+            pe = data.getPositiveBigInteger();
+            qe = data.getPositiveBigInteger();
+            coeff = data.getPositiveBigInteger();
             if (derValue.data.available() != 0) {
                 throw new IOException("Extra data available");
             }
@@ -206,23 +214,4 @@
             throw new InvalidKeyException("Invalid RSA private key", e);
         }
     }
-
-    /**
-     * Read a BigInteger from the DerInputStream.
-     */
-    static BigInteger getBigInteger(DerInputStream data) throws IOException {
-        BigInteger b = data.getBigInteger();
-
-        /*
-         * Some implementations do not correctly encode ASN.1 INTEGER values
-         * in 2's complement format, resulting in a negative integer when
-         * decoded. Correct the error by converting it to a positive integer.
-         *
-         * See CR 6255949
-         */
-        if (b.signum() < 0) {
-            b = new BigInteger(1, b.toByteArray());
-        }
-        return b;
-    }
 }
--- a/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -110,8 +110,8 @@
                 throw new IOException("Not a SEQUENCE");
             }
             DerInputStream data = derValue.data;
-            n = RSAPrivateCrtKeyImpl.getBigInteger(data);
-            e = RSAPrivateCrtKeyImpl.getBigInteger(data);
+            n = data.getPositiveBigInteger();
+            e = data.getPositiveBigInteger();
             if (derValue.data.available() != 0) {
                 throw new IOException("Extra data available");
             }
--- a/src/share/classes/sun/security/tools/keytool/Resources_sv.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/tools/keytool/Resources_sv.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
         {"Changes.an.entry.s.alias",
                 "\u00C4ndrar postalias"}, //-changealias
         {"Deletes.an.entry",
-                "Tar bort post"}, //-delete
+                "Tar bort en post"}, //-delete
         {"Exports.certificate",
                 "Exporterar certifikat"}, //-exportcert
         {"Generates.a.key.pair",
@@ -175,7 +175,7 @@
         {"validity.number.of.days",
                 "antal dagar f\u00F6r giltighet"}, //-validity
         {"Serial.ID.of.cert.to.revoke",
-                 "Seriellt id f\u00F6r certifikat som ska \u00E5terkallas"}, //-id
+                 "Serienummer p\u00E5 certifikat som ska \u00E5terkallas"}, //-id
         // keytool: Running part
         {"keytool.error.", "nyckelverktygsfel: "},
         {"Illegal.option.", "Otill\u00E5tet alternativ:  "},
@@ -264,7 +264,7 @@
                 "Certifikatet har inte lagts till i nyckellagret"},
         {".Storing.ksfname.", "[Lagrar {0}]"},
         {"alias.has.no.public.key.certificate.",
-                "{0} saknar offentlig nyckel (certifikat)"},
+                "{0} saknar \u00F6ppen nyckel (certifikat)"},
         {"Cannot.derive.signature.algorithm",
                 "Kan inte h\u00E4rleda signaturalgoritm"},
         {"Alias.alias.does.not.exist",
@@ -314,7 +314,7 @@
         {"Failed.to.parse.input", "Kunde inte tolka indata"},
         {"Empty.input", "Inga indata"},
         {"Not.X.509.certificate", "Inte ett X.509-certifikat"},
-        {"alias.has.no.public.key", "{0} saknar offentlig nyckel"},
+        {"alias.has.no.public.key", "{0} saknar \u00F6ppen nyckel"},
         {"alias.has.no.X.509.certificate", "{0} saknar X.509-certifikat"},
         {"New.certificate.self.signed.", "Nytt certifikat (sj\u00E4lvsignerat):"},
         {"Reply.has.no.certificates", "Svaret saknar certifikat"},
@@ -369,7 +369,7 @@
 
         {".WARNING.WARNING.WARNING.",
             "*****************  WARNING WARNING WARNING  *****************"},
-        {"Signer.d.", "Signerare #%d:"},
+        {"Signer.d.", "Undertecknare %d:"},
         {"Timestamp.", "Tidsst\u00E4mpel:"},
         {"Signature.", "Signatur:"},
         {"CRLs.", "CRL:er:"},
@@ -384,7 +384,7 @@
             "* Integriteten f\u00F6r den information som lagras i srckeystore*\n* har INTE verifierats!  Om du vill verifiera dess integritet *\n* m\u00E5ste du ange l\u00F6senordet f\u00F6r srckeystore.                *"},
 
         {"Certificate.reply.does.not.contain.public.key.for.alias.",
-                "Certifikatsvaret inneh\u00E5ller inte n\u00E5gon offentlig nyckel f\u00F6r <{0}>"},
+                "Certifikatsvaret inneh\u00E5ller inte n\u00E5gon \u00F6ppen nyckel f\u00F6r <{0}>"},
         {"Incomplete.certificate.chain.in.reply",
                 "Ofullst\u00E4ndig certifikatskedja i svaret"},
         {"Certificate.chain.in.reply.does.not.verify.",
@@ -411,7 +411,7 @@
         {".Empty.value.", "(Tomt v\u00E4rde)"},
         {"Extension.Request.", "Till\u00E4ggsbeg\u00E4ran:"},
         {"PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key.",
-                "PKCS #10 certifikatbeg\u00E4ran (version 1.0)\n\u00C4mne: %s\nAllm\u00E4n nyckel: %s-format %s-nyckel\n"},
+                "PKCS #10 certifikatbeg\u00E4ran (version 1.0)\n\u00C4rende: %s\n\u00D6ppen nyckel: %s-format %s-nyckel\n"},
         {"Unknown.keyUsage.type.", "Ok\u00E4nd keyUsage-typ: "},
         {"Unknown.extendedkeyUsage.type.", "Ok\u00E4nd extendedkeyUsage-typ: "},
         {"Unknown.AccessDescription.type.", "Ok\u00E4nd AccessDescription-typ: "},
--- a/src/share/classes/sun/security/tools/policytool/Resources_sv.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/tools/policytool/Resources_sv.java	Thu Sep 07 23:37:21 2017 -0700
@@ -35,7 +35,7 @@
     private static final Object[][] contents = {
         {"NEWLINE", "\n"},
         {"Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.",
-                "Varning! Det finns ingen offentlig nyckel f\u00F6r aliaset {0}. Kontrollera att det aktuella nyckellagret \u00E4r korrekt konfigurerat."},
+                "Varning! Det finns ingen \u00F6ppen nyckel f\u00F6r aliaset {0}. Kontrollera att det aktuella nyckellagret \u00E4r korrekt konfigurerat."},
         {"Warning.Class.not.found.class", "Varning! Klassen hittades inte: {0}"},
         {"Warning.Invalid.argument.s.for.constructor.arg",
                 "Varning! Ogiltiga argument f\u00F6r konstruktor: {0}"},
@@ -59,8 +59,8 @@
         {"Warning.File.name.may.include.escaped.backslash.characters.It.is.not.necessary.to.escape.backslash.characters.the.tool.escapes",
             "Varning! Filnamnet kan inneh\u00E5lla omv\u00E4nda snedstreck inom citattecken. Citattecken kr\u00E4vs inte f\u00F6r omv\u00E4nda snedstreck (verktyget hanterar detta n\u00E4r policyinneh\u00E5llet skrivs till det best\u00E4ndiga lagret).\n\nKlicka p\u00E5 Beh\u00E5ll f\u00F6r att beh\u00E5lla det angivna namnet, eller klicka p\u00E5 Redigera f\u00F6r att \u00E4ndra det."},
 
-        {"Add.Public.Key.Alias", "L\u00E4gg till offentligt nyckelalias"},
-        {"Remove.Public.Key.Alias", "Ta bort offentligt nyckelalias"},
+        {"Add.Public.Key.Alias", "L\u00E4gg till alias till \u00F6ppen nyckel"},
+        {"Remove.Public.Key.Alias", "Ta bort alias f\u00F6r \u00F6ppen nyckel"},
         {"File", "&Arkiv"},
         {"KeyStore", "&KeyStore"},
         {"Policy.File.", "Policyfil:"},
--- a/src/share/classes/sun/security/util/AuthResources_sv.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/AuthResources_sv.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,7 +137,7 @@
         // provided.null.name is the NullPointerException message when a
         // developer incorrectly passes a null name to the constructor of
         // subclasses of java.security.Principal
-        {"provided.null.name", "angav null-namn"}
+        {"provided.null.name", "null-namn angavs"}
 
     };
 
--- a/src/share/classes/sun/security/util/DerInputBuffer.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/DerInputBuffer.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,16 +44,26 @@
  */
 class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
 
-    DerInputBuffer(byte[] buf) { super(buf); }
+    boolean allowBER = true;
 
-    DerInputBuffer(byte[] buf, int offset, int len) {
+    // used by sun/security/util/DerInputBuffer/DerInputBufferEqualsHashCode.java
+    DerInputBuffer(byte[] buf) {
+        this(buf, true);
+    }
+
+    DerInputBuffer(byte[] buf, boolean allowBER) {
+        super(buf);
+        this.allowBER = allowBER;
+    }
+
+    DerInputBuffer(byte[] buf, int offset, int len, boolean allowBER) {
         super(buf, offset, len);
+        this.allowBER = allowBER;
     }
 
     DerInputBuffer dup() {
         try {
             DerInputBuffer retval = (DerInputBuffer)clone();
-
             retval.mark(Integer.MAX_VALUE);
             return retval;
         } catch (CloneNotSupportedException e) {
@@ -147,8 +157,8 @@
         System.arraycopy(buf, pos, bytes, 0, len);
         skip(len);
 
-        // check to make sure no extra leading 0s for DER
-        if (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0)) {
+        // BER allows leading 0s but DER does not
+        if (!allowBER && (len >= 2 && (bytes[0] == 0) && (bytes[1] >= 0))) {
             throw new IOException("Invalid encoding: redundant leading 0s");
         }
 
--- a/src/share/classes/sun/security/util/DerInputStream.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/DerInputStream.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,6 +81,25 @@
     }
 
     /**
+     * Create a DER input stream from part of a data buffer with
+     * additional arg to control whether DER checks are enforced.
+     * The buffer is not copied, it is shared.  Accordingly, the
+     * buffer should be treated as read-only.
+     *
+     * @param data the buffer from which to create the string (CONSUMED)
+     * @param offset the first index of <em>data</em> which will
+     *          be read as DER input in the new stream
+     * @param len how long a chunk of the buffer to use,
+     *          starting at "offset"
+     * @param allowBER whether to allow constructed indefinite-length
+     *          encoding as well as tolerate leading 0s
+     */
+    public DerInputStream(byte[] data, int offset, int len,
+        boolean allowBER) throws IOException {
+        init(data, offset, len, allowBER);
+    }
+
+    /**
      * Create a DER input stream from part of a data buffer.
      * The buffer is not copied, it is shared.  Accordingly, the
      * buffer should be treated as read-only.
@@ -95,47 +114,27 @@
         init(data, offset, len, true);
     }
 
-    /**
-     * Create a DER input stream from part of a data buffer with
-     * additional arg to indicate whether to allow constructed
-     * indefinite-length encoding.
-     * The buffer is not copied, it is shared.  Accordingly, the
-     * buffer should be treated as read-only.
-     *
-     * @param data the buffer from which to create the string (CONSUMED)
-     * @param offset the first index of <em>data</em> which will
-     *          be read as DER input in the new stream
-     * @param len how long a chunk of the buffer to use,
-     *          starting at "offset"
-     * @param allowIndefiniteLength whether to allow constructed
-     *          indefinite-length encoding
-     */
-    public DerInputStream(byte[] data, int offset, int len,
-        boolean allowIndefiniteLength) throws IOException {
-        init(data, offset, len, allowIndefiniteLength);
-    }
-
     /*
      * private helper routine
      */
-    private void init(byte[] data, int offset, int len,
-        boolean allowIndefiniteLength) throws IOException {
+    private void init(byte[] data, int offset, int len, boolean allowBER) throws IOException {
         if ((offset+2 > data.length) || (offset+len > data.length)) {
             throw new IOException("Encoding bytes too short");
         }
         // check for indefinite length encoding
         if (DerIndefLenConverter.isIndefinite(data[offset+1])) {
-            if (!allowIndefiniteLength) {
+            if (!allowBER) {
                 throw new IOException("Indefinite length BER encoding found");
             } else {
                 byte[] inData = new byte[len];
                 System.arraycopy(data, offset, inData, 0, len);
 
                 DerIndefLenConverter derIn = new DerIndefLenConverter();
-                buffer = new DerInputBuffer(derIn.convert(inData));
+                buffer = new DerInputBuffer(derIn.convert(inData), allowBER);
             }
-        } else
-            buffer = new DerInputBuffer(data, offset, len);
+        } else {
+            buffer = new DerInputBuffer(data, offset, len, allowBER);
+        }
         buffer.mark(Integer.MAX_VALUE);
     }
 
@@ -156,7 +155,7 @@
      */
     public DerInputStream subStream(int len, boolean do_skip)
     throws IOException {
-        DerInputBuffer  newbuf = buffer.dup();
+        DerInputBuffer newbuf = buffer.dup();
 
         newbuf.truncate(len);
         if (do_skip) {
@@ -393,7 +392,8 @@
            dis.readFully(indefData, offset, readLen);
            dis.close();
            DerIndefLenConverter derIn = new DerIndefLenConverter();
-           buffer = new DerInputBuffer(derIn.convert(indefData));
+           buffer = new DerInputBuffer(derIn.convert(indefData), buffer.allowBER);
+
            if (tag != buffer.read())
                 throw new IOException("Indefinite length encoding" +
                         " not supported");
@@ -421,7 +421,7 @@
         DerValue value;
 
         do {
-            value = new DerValue(newstr.buffer);
+            value = new DerValue(newstr.buffer, buffer.allowBER);
             vec.addElement(value);
         } while (newstr.available() > 0);
 
--- a/src/share/classes/sun/security/util/DerValue.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/DerValue.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+/**
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -226,6 +226,16 @@
         data = init(stringTag, value);
     }
 
+    // Creates a DerValue from a tag and some DER-encoded data w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte tag, byte[] data, boolean allowBER) {
+        this.tag = tag;
+        buffer = new DerInputBuffer(data.clone(), allowBER);
+        length = data.length;
+        this.data = new DerInputStream(buffer);
+        this.data.mark(Integer.MAX_VALUE);
+    }
+
     /**
      * Creates a DerValue from a tag and some DER-encoded data.
      *
@@ -233,20 +243,16 @@
      * @param data the DER-encoded data
      */
     public DerValue(byte tag, byte[] data) {
-        this.tag = tag;
-        buffer = new DerInputBuffer(data.clone());
-        length = data.length;
-        this.data = new DerInputStream(buffer);
-        this.data.mark(Integer.MAX_VALUE);
+        this(tag, data, true);
     }
 
     /*
      * package private
      */
     DerValue(DerInputBuffer in) throws IOException {
+
         // XXX must also parse BER-encoded constructed
         // values such as sequences, sets...
-
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
         length = DerInputStream.getLength(lenByte, in);
@@ -261,7 +267,7 @@
             dis.readFully(indefData, offset, readLen);
             dis.close();
             DerIndefLenConverter derIn = new DerIndefLenConverter();
-            inbuf = new DerInputBuffer(derIn.convert(indefData));
+            inbuf = new DerInputBuffer(derIn.convert(indefData), in.allowBER);
             if (tag != inbuf.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
@@ -283,6 +289,12 @@
         }
     }
 
+    // Get an ASN.1/DER encoded datum from a buffer w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte[] buf, boolean allowBER) throws IOException {
+        data = init(true, new ByteArrayInputStream(buf), allowBER);
+    }
+
     /**
      * Get an ASN.1/DER encoded datum from a buffer.  The
      * entire buffer must hold exactly one datum, including
@@ -291,7 +303,14 @@
      * @param buf buffer holding a single DER-encoded datum.
      */
     public DerValue(byte[] buf) throws IOException {
-        data = init(true, new ByteArrayInputStream(buf));
+        this(buf, true);
+    }
+
+    // Get an ASN.1/DER encoded datum from part of a buffer w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(byte[] buf, int offset, int len, boolean allowBER)
+        throws IOException {
+        data = init(true, new ByteArrayInputStream(buf, offset, len), allowBER);
     }
 
     /**
@@ -304,7 +323,13 @@
      * @param length how many bytes are in the encoded datum
      */
     public DerValue(byte[] buf, int offset, int len) throws IOException {
-        data = init(true, new ByteArrayInputStream(buf, offset, len));
+        this(buf, offset, len, true);
+    }
+
+    // Get an ASN1/DER encoded datum from an input stream w/ additional
+    // arg to control whether DER checks are enforced.
+    DerValue(InputStream in, boolean allowBER) throws IOException {
+        data = init(false, in, allowBER);
     }
 
     /**
@@ -317,10 +342,11 @@
      *  which may be followed by additional data
      */
     public DerValue(InputStream in) throws IOException {
-        data = init(false, in);
+        this(in, true);
     }
 
-    private DerInputStream init(byte stringTag, String value) throws IOException {
+    private DerInputStream init(byte stringTag, String value)
+        throws IOException {
         String enc = null;
 
         tag = stringTag;
@@ -348,7 +374,7 @@
 
         byte[] buf = value.getBytes(enc);
         length = buf.length;
-        buffer = new DerInputBuffer(buf);
+        buffer = new DerInputBuffer(buf, true);
         DerInputStream result = new DerInputStream(buffer);
         result.mark(Integer.MAX_VALUE);
         return result;
@@ -357,8 +383,8 @@
     /*
      * helper routine
      */
-    private DerInputStream init(boolean fullyBuffered, InputStream in)
-            throws IOException {
+    private DerInputStream init(boolean fullyBuffered, InputStream in,
+        boolean allowBER) throws IOException {
 
         tag = (byte)in.read();
         byte lenByte = (byte)in.read();
@@ -385,7 +411,7 @@
 
         byte[] bytes = IOUtils.readFully(in, length, true);
 
-        buffer = new DerInputBuffer(bytes);
+        buffer = new DerInputBuffer(bytes, allowBER);
         return new DerInputStream(buffer);
     }
 
@@ -480,7 +506,8 @@
         if (buffer.read(bytes) != length)
             throw new IOException("short read on DerValue buffer");
         if (isConstructed()) {
-            DerInputStream in = new DerInputStream(bytes);
+            DerInputStream in = new DerInputStream(bytes, 0, bytes.length,
+                buffer.allowBER);
             bytes = null;
             while (in.available() != 0) {
                 bytes = append(bytes, in.getOctetString());
--- a/src/share/classes/sun/security/util/HostnameChecker.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/HostnameChecker.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package sun.security.util;
 
 import java.io.IOException;
+import java.net.IDN;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.*;
@@ -186,6 +187,15 @@
      */
     private void matchDNS(String expectedName, X509Certificate cert)
             throws CertificateException {
+        // Check that the expected name is a valid domain name.
+        try {
+            // Using the checking taken from OpenJDK 8's SNIHostName
+            checkHostName(expectedName);
+        } catch (IllegalArgumentException iae) {
+            throw new CertificateException(
+                "Illegal given domain name: " + expectedName, iae);
+        }
+
         Collection<List<?>> subjAltNames = cert.getSubjectAlternativeNames();
         if (subjAltNames != null) {
             boolean foundDNS = false;
@@ -257,6 +267,18 @@
      * may contain the wildcard character *
      */
     private boolean isMatched(String name, String template) {
+        // check the validity of the domain name template.
+        try {
+            // Replacing wildcard character '*' with 'x' so as to check
+            // the domain name template validity.
+            //
+            // Using the checking taken from OpenJDK 8's SNIHostName
+            checkHostName(template.replace('*', 'x'));
+        } catch (IllegalArgumentException iae) {
+            // It would be nice to add debug log if not matching.
+            return false;
+        }
+
         if (checkType == TYPE_TLS) {
             return matchAllWildcards(name, template);
         } else if (checkType == TYPE_LDAP) {
@@ -366,4 +388,22 @@
         }
         return name.endsWith(afterWildcard);
     }
+
+    // check the validity of the string hostname
+    private void checkHostName(String hostname) {
+        hostname = IDN.toASCII(Objects.requireNonNull(hostname,
+                                   "Server name value of host_name cannot be null"),
+                               IDN.USE_STD3_ASCII_RULES);
+
+        if (hostname.isEmpty()) {
+            throw new IllegalArgumentException(
+                "Server name value of host_name cannot be empty");
+        }
+
+        if (hostname.endsWith(".")) {
+            throw new IllegalArgumentException(
+                "Server name value of host_name cannot have the trailing dot");
+        }
+    }
+
 }
--- a/src/share/classes/sun/security/util/ManifestEntryVerifier.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/ManifestEntryVerifier.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -109,6 +109,8 @@
         /* get the headers from the manifest for this entry */
         /* if there aren't any, we can't verify any digests for this entry */
 
+        skip = false;
+
         Attributes attr = man.getAttributes(name);
         if (attr == null) {
             // ugh. we should be able to remove this at some point.
@@ -143,7 +145,6 @@
                 }
 
                 if (digest != null) {
-                    skip = false;
                     digest.reset();
                     digests.add(digest);
                     manifestHashes.add(
@@ -199,6 +200,10 @@
             return null;
         }
 
+        if (digests.isEmpty()) {
+            throw new SecurityException("digest missing for " + name);
+        }
+
         if (signers != null)
             return signers;
 
--- a/src/share/classes/sun/security/util/Resources_sv.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/security/util/Resources_sv.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,9 +53,9 @@
                 "CredOwner:\n\tIdentitetshavareklass = {0}\n\tIdentitetshavarenamn = {1}"},
 
         // javax.security.auth.x500
-        {"provided.null.name", "angav null-namn"},
-        {"provided.null.keyword.map", "nullnyckelordsmappning tillhandah\u00F6lls"},
-        {"provided.null.OID.map", "null-OID-mappning tillhandah\u00F6lls"},
+        {"provided.null.name", "null-namn angavs"},
+        {"provided.null.keyword.map", "nullnyckelordsmappning angavs"},
+        {"provided.null.OID.map", "null-OID-mappning angavs"},
 
         // javax.security.auth.Subject
         {"NEWLINE", "\n"},
@@ -73,7 +73,7 @@
                 "\tPrivat inloggning \u00E4r inte tillg\u00E4nglig\n"},
         {"Subject.is.read.only", "Innehavare \u00E4r skrivskyddad"},
         {"attempting.to.add.an.object.which.is.not.an.instance.of.java.security.Principal.to.a.Subject.s.Principal.Set",
-                "f\u00F6rs\u00F6k att l\u00E4gga till ett objekt som inte \u00E4r en f\u00F6rekomst av java.security.Principal till en upps\u00E4ttning av identitetshavare"},
+                "f\u00F6rs\u00F6k att l\u00E4gga till ett objekt som inte \u00E4r en instans av java.security.Principal till ett subjekts upps\u00E4ttning av identitetshavare"},
         {"attempting.to.add.an.object.which.is.not.an.instance.of.class",
                 "f\u00F6rs\u00F6ker l\u00E4gga till ett objekt som inte \u00E4r en instans av {0}"},
 
@@ -84,11 +84,11 @@
         {"Invalid.null.input.name", "Ogiltiga null-indata: namn"},
         {"No.LoginModules.configured.for.name",
          "Inga inloggningsmoduler har konfigurerats f\u00F6r {0}"},
-        {"invalid.null.Subject.provided", "ogiltig null-innehavare"},
+        {"invalid.null.Subject.provided", "ogiltig null-subjekt"},
         {"invalid.null.CallbackHandler.provided",
                 "ogiltig null-CallbackHandler"},
         {"null.subject.logout.called.before.login",
-                "null-innehavare - utloggning anropades f\u00F6re inloggning"},
+                "null-subjekt - utloggning anropades f\u00F6re inloggning"},
         {"unable.to.instantiate.LoginModule.module.because.it.does.not.provide.a.no.argument.constructor",
                 "kan inte instansiera LoginModule, {0}, eftersom den inte tillhandah\u00E5ller n\u00E5gon icke-argumentskonstruktor"},
         {"unable.to.instantiate.LoginModule",
@@ -146,12 +146,12 @@
 
         // sun.security.pkcs11.SunPKCS11
         {"PKCS11.Token.providerName.Password.",
-                "PKCS11-tecken [{0}] L\u00F6senord: "},
+                "L\u00F6senord f\u00F6r PKCS11-token [{0}]: "},
 
         /* --- DEPRECATED --- */
         // javax.security.auth.Policy
         {"unable.to.instantiate.Subject.based.policy",
-                "den innehavarbaserade policyn kan inte skapas"}
+                "kan inte instansiera subjektbaserad policy"}
     };
 
 
--- a/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java	Thu Sep 07 23:37:21 2017 -0700
@@ -75,7 +75,7 @@
             new ArrayList<VirtualMachineDescriptor>();
 
         MonitoredHost host;
-        Set vms;
+        Set<Integer> vms;
         try {
             host = MonitoredHost.getMonitoredHost(new HostIdentifier((String)null));
             vms = host.activeVms();
@@ -92,31 +92,29 @@
             throw new InternalError();          // shouldn't happen
         }
 
-        for (Object vmid: vms) {
-            if (vmid instanceof Integer) {
-                String pid = vmid.toString();
-                String name = pid;      // default to pid if name not available
-                boolean isAttachable = false;
-                MonitoredVm mvm = null;
+        for (Integer vmid: vms) {
+            String pid = vmid.toString();
+            String name = pid;      // default to pid if name not available
+            boolean isAttachable = false;
+            MonitoredVm mvm = null;
+            try {
+                mvm = host.getMonitoredVm(new VmIdentifier(pid));
                 try {
-                    mvm = host.getMonitoredVm(new VmIdentifier(pid));
-                    try {
-                        isAttachable = MonitoredVmUtil.isAttachable(mvm);
-                        // use the command line as the display name
-                        name =  MonitoredVmUtil.commandLine(mvm);
-                    } catch (Exception e) {
-                    }
-                    if (isAttachable) {
-                        result.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
-                    }
-                } catch (Throwable t) {
-                    if (t instanceof ThreadDeath) {
-                        throw (ThreadDeath)t;
-                    }
-                } finally {
-                    if (mvm != null) {
-                        mvm.detach();
-                    }
+                    isAttachable = MonitoredVmUtil.isAttachable(mvm);
+                    // use the command line as the display name
+                    name =  MonitoredVmUtil.commandLine(mvm);
+                } catch (Exception e) {
+                }
+                if (isAttachable) {
+                    result.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
+                }
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath) {
+                    throw (ThreadDeath)t;
+                }
+            } finally {
+                if (mvm != null) {
+                    mvm.detach();
                 }
             }
         }
--- a/src/share/classes/sun/tools/jar/CommandLine.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jar/CommandLine.java	Thu Sep 07 23:37:21 2017 -0700
@@ -55,7 +55,7 @@
     public static String[] parse(String[] args)
         throws IOException
     {
-        ArrayList newArgs = new ArrayList(args.length);
+        List<String> newArgs = new ArrayList<>(args.length);
         for (int i = 0; i < args.length; i++) {
             String arg = args[i];
             if (arg.length() > 1 && arg.charAt(0) == '@') {
@@ -69,10 +69,10 @@
                 newArgs.add(arg);
             }
         }
-        return (String[])newArgs.toArray(new String[newArgs.size()]);
+        return newArgs.toArray(new String[newArgs.size()]);
     }
 
-    private static void loadCmdFile(String name, List args)
+    private static void loadCmdFile(String name, List<String> args)
         throws IOException
     {
         Reader r = new BufferedReader(new FileReader(name));
@@ -83,7 +83,7 @@
         st.commentChar('#');
         st.quoteChar('"');
         st.quoteChar('\'');
-        while (st.nextToken() != st.TT_EOF) {
+        while (st.nextToken() != StreamTokenizer.TT_EOF) {
             args.add(st.sval);
         }
         r.close();
--- a/src/share/classes/sun/tools/jar/Manifest.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jar/Manifest.java	Thu Sep 07 23:37:21 2017 -0700
@@ -47,10 +47,10 @@
     /* list of headers that all pertain to a particular
      * file in the archive
      */
-    private Vector entries = new Vector();
+    private Vector<MessageHeader> entries = new Vector<>();
     private byte[] tmpbuf = new byte[512];
     /* a hashtable of entries, for fast lookup */
-    private Hashtable tableEntries = new Hashtable();
+    private Hashtable<String, MessageHeader> tableEntries = new Hashtable<>();
 
     static final String[] hashes = {"SHA"};
     static final byte[] EOL = {(byte)'\r', (byte)'\n'};
@@ -115,14 +115,14 @@
     }
 
     public MessageHeader getEntry(String name) {
-        return (MessageHeader) tableEntries.get(name);
+        return tableEntries.get(name);
     }
 
     public MessageHeader entryAt(int i) {
-        return (MessageHeader) entries.elementAt(i);
+        return entries.elementAt(i);
     }
 
-    public Enumeration entries() {
+    public Enumeration<MessageHeader> entries() {
         return entries.elements();
     }
 
@@ -214,7 +214,7 @@
         /* the first header in the file should be the global one.
          * It should say "Manifest-Version: x.x"; if not add it
          */
-        MessageHeader globals = (MessageHeader) entries.elementAt(0);
+        MessageHeader globals = entries.elementAt(0);
 
         if (globals.findValue("Manifest-Version") == null) {
             /* Assume this is a user-defined manifest.  If it has a Name: <..>
@@ -238,7 +238,7 @@
         globals.print(ps);
 
         for (int i = 1; i < entries.size(); ++i) {
-            MessageHeader mh = (MessageHeader) entries.elementAt(i);
+            MessageHeader mh = entries.elementAt(i);
             mh.print(ps);
         }
     }
--- a/src/share/classes/sun/tools/jar/SignatureFile.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jar/SignatureFile.java	Thu Sep 07 23:37:21 2017 -0700
@@ -47,7 +47,7 @@
  *
  * <p>Each entry section contains the name of an entry (which must
  * have a counterpart in the manifest). Like the manifest it contains
- * a hash, the hash of the manifest section correspondind to the
+ * a hash, the hash of the manifest section corresponding to the
  * name. Since the manifest entry contains the hash of the data, this
  * is equivalent to a signature of the data, plus the attributes of
  * the manifest entry.
@@ -66,7 +66,7 @@
 
     /* list of headers that all pertain to a particular file in the
      * archive */
-    private Vector entries = new Vector();
+    private Vector<MessageHeader> entries = new Vector<>();
 
     /* Right now we only support SHA hashes */
     static final String[] hashes = {"SHA"};
@@ -98,7 +98,7 @@
      * character in length.  */
     private SignatureFile(String name) throws JarException {
 
-        entries = new Vector();
+        entries = new Vector<>();
 
         if (name != null) {
             if (name.length() > 8 || name.indexOf('.') != -1) {
@@ -142,9 +142,9 @@
         this(name, true);
 
         this.manifest = manifest;
-        Enumeration enum_ = manifest.entries();
+        Enumeration<MessageHeader> enum_ = manifest.entries();
         while (enum_.hasMoreElements()) {
-            MessageHeader mh = (MessageHeader)enum_.nextElement();
+            MessageHeader mh = enum_.nextElement();
             String entryName = mh.findValue("Name");
             if (entryName != null) {
                 add(entryName);
@@ -269,9 +269,9 @@
      *the entry does not exist.
      */
     public MessageHeader getEntry(String name) {
-        Enumeration enum_ = entries();
+        Enumeration<MessageHeader> enum_ = entries();
         while(enum_.hasMoreElements()) {
-            MessageHeader mh = (MessageHeader)enum_.nextElement();
+            MessageHeader mh = enum_.nextElement();
             if (name.equals(mh.findValue("Name"))) {
                 return mh;
             }
@@ -282,13 +282,13 @@
     /**
      * Returns the n-th entry. The global header is a entry 0.  */
     public MessageHeader entryAt(int n) {
-        return (MessageHeader) entries.elementAt(n);
+        return entries.elementAt(n);
     }
 
     /**
      * Returns an enumeration of the entries.
      */
-    public Enumeration entries() {
+    public Enumeration<MessageHeader> entries() {
         return entries.elements();
     }
 
@@ -322,11 +322,11 @@
         }
     }
 
-    private Hashtable digests = new Hashtable();
+    private Hashtable<String, MessageDigest> digests = new Hashtable<>();
 
     private MessageDigest getDigest(String algorithm)
     throws NoSuchAlgorithmException {
-        MessageDigest dig = (MessageDigest)digests.get(algorithm);
+        MessageDigest dig = digests.get(algorithm);
         if (dig == null) {
             dig = MessageDigest.getInstance(algorithm);
             digests.put(algorithm, dig);
@@ -344,7 +344,7 @@
         /* the first header in the file should be the global one.
          * It should say "SignatureFile-Version: x.x"; barf if not
          */
-        MessageHeader globals = (MessageHeader) entries.elementAt(0);
+        MessageHeader globals = entries.elementAt(0);
         if (globals.findValue("Signature-Version") == null) {
             throw new JarException("Signature file requires " +
                             "Signature-Version: 1.0 in 1st header");
@@ -354,7 +354,7 @@
         globals.print(ps);
 
         for (int i = 1; i < entries.size(); ++i) {
-            MessageHeader mh = (MessageHeader) entries.elementAt(i);
+            MessageHeader mh = entries.elementAt(i);
             mh.print(ps);
         }
     }
--- a/src/share/classes/sun/tools/jinfo/JInfo.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jinfo/JInfo.java	Thu Sep 07 23:37:21 2017 -0700
@@ -98,7 +98,7 @@
     }
 
     // loads the given class using the system class loader
-    private static Class loadClass(String name) {
+    private static Class<?> loadClass(String name) {
         //
         // We specify the system clas loader so as to cater for development
         // environments where this class is on the boot class path but sa-jdi.jar
@@ -178,7 +178,7 @@
     // print usage message
     private static void usage() {
 
-        Class c = loadClass("sun.jvm.hotspot.tools.JInfo");
+        Class<?> c = loadClass("sun.jvm.hotspot.tools.JInfo");
         boolean usageSA = (c != null);
 
         System.out.println("Usage:");
--- a/src/share/classes/sun/tools/jmap/JMap.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jmap/JMap.java	Thu Sep 07 23:37:21 2017 -0700
@@ -198,7 +198,7 @@
     }
 
     // loads the given class using the system class loader
-    private static Class loadClass(String name) {
+    private static Class<?> loadClass(String name) {
         //
         // We specify the system clas loader so as to cater for development
         // environments where this class is on the boot class path but sa-jdi.jar
@@ -336,7 +336,7 @@
 
     // returns true if SA is available
     private static boolean haveSA() {
-        Class c = loadClass("sun.jvm.hotspot.tools.HeapSummary");
+        Class<?> c = loadClass("sun.jvm.hotspot.tools.HeapSummary");
         return (c != null);
     }
 
--- a/src/share/classes/sun/tools/jps/Jps.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jps/Jps.java	Thu Sep 07 23:37:21 2017 -0700
@@ -59,13 +59,13 @@
                     MonitoredHost.getMonitoredHost(hostId);
 
             // get the set active JVMs on the specified host.
-            Set jvms = monitoredHost.activeVms();
+            Set<Integer> jvms = monitoredHost.activeVms();
 
-            for (Iterator j = jvms.iterator(); j.hasNext(); /* empty */ ) {
+            for (Integer jvm: jvms) {
                 StringBuilder output = new StringBuilder();
                 Throwable lastError = null;
 
-                int lvmid = ((Integer)j.next()).intValue();
+                int lvmid = jvm;
 
                 output.append(String.valueOf(lvmid));
 
--- a/src/share/classes/sun/tools/jstack/JStack.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/jstack/JStack.java	Thu Sep 07 23:37:21 2017 -0700
@@ -137,7 +137,7 @@
     }
 
     // Returns sun.jvm.hotspot.tools.JStack if available, otherwise null.
-    private static Class loadSAClass() {
+    private static Class<?> loadSAClass() {
         //
         // Attempt to load JStack class - we specify the system class
         // loader so as to cater for development environments where
--- a/src/share/classes/sun/tools/serialver/SerialVer.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/classes/sun/tools/serialver/SerialVer.java	Thu Sep 07 23:37:21 2017 -0700
@@ -98,6 +98,7 @@
         classname_t.requestFocus();
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event ev, Object obj) {
         if (ev.target == classname_t) {
             show((String)ev.arg);
@@ -110,6 +111,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     public boolean handleEvent(Event ev) {
         boolean rc = super.handleEvent(ev);
         return rc;
@@ -206,7 +208,7 @@
     }
 
     static String resolveClass(String classname) throws ClassNotFoundException {
-        Class cl = Class.forName(classname, false, loader);
+        Class<?> cl = Class.forName(classname, false, loader);
         ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
         if (desc != null) {
             return "    static final long serialVersionUID = " +
@@ -216,6 +218,10 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
+    private static void showWindow(Window w) {
+        w.show();
+    }
 
     public static void main(String[] args) {
         boolean show = false;
@@ -316,7 +322,7 @@
 
             f.add("Center", sv);
             f.pack();
-            f.show();
+            showWindow(f);
         }
     }
 
@@ -362,6 +368,7 @@
     /*
      * Handle a window destroy event by exiting.
      */
+    @SuppressWarnings("deprecation")
     public boolean handleEvent(Event e) {
         if (e.id == Event.WINDOW_DESTROY) {
             exit(0);
@@ -371,6 +378,7 @@
     /*
      * Handle an Exit event by exiting.
      */
+    @SuppressWarnings("deprecation")
     public boolean action(Event ev, Object obj) {
         if (ev.target == exit_i) {
             exit(0);
@@ -455,11 +463,7 @@
         }
         try {
             String message = messageRB.getString(key);
-            String[] args = new String[3];
-            args[0] = a1;
-            args[1] = a2;
-            args[2] = a3;
-            return MessageFormat.format(message, args);
+            return MessageFormat.format(message, a1, a2, a3);
         } catch (MissingResourceException e) {
             throw new Error("Fatal: Resource for serialver is broken. There is no " + key + " key in resource.");
         }
--- a/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Thu Sep 07 23:37:21 2017 -0700
@@ -224,10 +224,10 @@
 
             // Calculate remaining size
             float ssH = ascent + descent;
-            float remainingHeight = (float) (y2 - (ssH*2) - 0.5f);
+            float remainingHeight = y2 - (ssH*2) - 0.5f;
             float blockHeight = remainingHeight/10;
             float blockWidth = 20.0f;
-            float remainingWidth = (float) (x2 - blockWidth - 10);
+            float remainingWidth = x2 - blockWidth - 10;
 
             // .. Memory Free ..
             big.setColor(mfColor);
@@ -235,7 +235,7 @@
             int i = 0;
             for ( ; i < MemUsage ; i++) {
                 mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
-                                blockWidth,(float) blockHeight-1);
+                                blockWidth, blockHeight-1);
                 big.fill(mfRect);
             }
 
@@ -243,13 +243,13 @@
             big.setColor(Color.green);
             for ( ; i < 10; i++)  {
                 muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
-                                blockWidth,(float) blockHeight-1);
+                                blockWidth, blockHeight-1);
                 big.fill(muRect);
             }
 
             // .. Draw History Graph ..
             if (remainingWidth <= 30) remainingWidth = (float)30;
-            if (remainingHeight <= ssH) remainingHeight = (float)ssH;
+            if (remainingHeight <= ssH) remainingHeight = ssH;
             big.setColor(graphColor);
             int graphX = x1+30;
             int graphY = y1 + (int) ssH;
@@ -358,8 +358,8 @@
                     big = bimg.createGraphics();
                     big.setFont(font);
                     FontMetrics fm = big.getFontMetrics(font);
-                    ascent = (int) fm.getAscent();
-                    descent = (int) fm.getDescent();
+                    ascent = fm.getAscent();
+                    descent = fm.getDescent();
                 }
                 repaint();
                 try {
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Thu Sep 07 23:37:21 2017 -0700
@@ -61,7 +61,7 @@
     private final ZipFileSystem zfs;
 
     ZipFileStore(ZipPath zpath) {
-        this.zfs = (ZipFileSystem)zpath.getFileSystem();
+        this.zfs = zpath.getFileSystem();
     }
 
     @Override
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Thu Sep 07 23:37:21 2017 -0700
@@ -1616,7 +1616,7 @@
         synchronized (inflaters) {
             int size = inflaters.size();
             if (size > 0) {
-                Inflater inf = (Inflater)inflaters.remove(size - 1);
+                Inflater inf = inflaters.remove(size - 1);
                 return inf;
             } else {
                 return new Inflater(true);
@@ -1645,7 +1645,7 @@
         synchronized (deflaters) {
             int size = deflaters.size();
             if (size > 0) {
-                Deflater def = (Deflater)deflaters.remove(size - 1);
+                Deflater def = deflaters.remove(size - 1);
                 return def;
             } else {
                 return new Deflater(Deflater.DEFAULT_COMPRESSION, true);
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Thu Sep 07 23:37:21 2017 -0700
@@ -211,7 +211,7 @@
     public <V extends FileAttributeView> V
         getFileAttributeView(Path path, Class<V> type, LinkOption... options)
     {
-        return (V)ZipFileAttributeView.get(toZipPath(path), type);
+        return ZipFileAttributeView.get(toZipPath(path), type);
     }
 
     @Override
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Thu Sep 07 23:37:21 2017 -0700
@@ -78,12 +78,12 @@
                 // twice
                 long len = LOCHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENHDR;
                 if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
-                    zfs.zerror("read loc header failed");
+                    ZipFileSystem.zerror("read loc header failed");
                 if (LOCEXT(buf) > CENEXT(cen, pos) + CENHDR) {
                     // have to read the second time;
                     len = LOCHDR + LOCNAM(buf) + LOCEXT(buf);
                     if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
-                        zfs.zerror("read loc header failed");
+                        ZipFileSystem.zerror("read loc header failed");
                 }
                 printLOC(buf);
                 pos += CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos);
--- a/src/share/lib/security/java.security-linux	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/lib/security/java.security-linux	Thu Sep 07 23:37:21 2017 -0700
@@ -147,12 +147,14 @@
                com.sun.org.apache.xalan.internal.xsltc.trax.,\
                com.sun.org.apache.xalan.internal.xsltc.util.,\
                com.sun.org.apache.xml.internal.res.,\
+               com.sun.org.apache.xml.internal.resolver.helpers.,\
+               com.sun.org.apache.xml.internal.resolver.readers.,\
+               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.apache.xml.internal.serializer.utils.,\
                com.sun.org.apache.xml.internal.utils.,\
-               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.glassfish.,\
-               org.jcp.xml.dsig.internal.,\
-               oracle.jrockit.jfr.
+               oracle.jrockit.jfr.,\
+               org.jcp.xml.dsig.internal.
 #
 # List of comma-separated packages that start with or equal this string
 # will cause a security exception to be thrown when
@@ -187,12 +189,14 @@
                    com.sun.org.apache.xalan.internal.xsltc.trax.,\
                    com.sun.org.apache.xalan.internal.xsltc.util.,\
                    com.sun.org.apache.xml.internal.res.,\
+                   com.sun.org.apache.xml.internal.resolver.helpers.,\
+                   com.sun.org.apache.xml.internal.resolver.readers.,\
+                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.apache.xml.internal.serializer.utils.,\
                    com.sun.org.apache.xml.internal.utils.,\
-                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.glassfish.,\
-                   org.jcp.xml.dsig.internal.,\
-                   oracle.jrockit.jfr.
+                   oracle.jrockit.jfr.,\
+                   org.jcp.xml.dsig.internal.
 #
 # Determines whether this properties file can be appended to
 # or overridden on the command line via -Djava.security.properties
--- a/src/share/lib/security/java.security-macosx	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/lib/security/java.security-macosx	Thu Sep 07 23:37:21 2017 -0700
@@ -148,12 +148,14 @@
                com.sun.org.apache.xalan.internal.xsltc.trax.,\
                com.sun.org.apache.xalan.internal.xsltc.util.,\
                com.sun.org.apache.xml.internal.res.,\
+               com.sun.org.apache.xml.internal.resolver.helpers.,\
+               com.sun.org.apache.xml.internal.resolver.readers.,\
+               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.apache.xml.internal.serializer.utils.,\
                com.sun.org.apache.xml.internal.utils.,\
-               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.glassfish.,\
+               oracle.jrockit.jfr.,\
                org.jcp.xml.dsig.internal.,\
-               oracle.jrockit.jfr.,\
                apple.
 
 #
@@ -190,12 +192,14 @@
                    com.sun.org.apache.xalan.internal.xsltc.trax.,\
                    com.sun.org.apache.xalan.internal.xsltc.util.,\
                    com.sun.org.apache.xml.internal.res.,\
+                   com.sun.org.apache.xml.internal.resolver.helpers.,\
+                   com.sun.org.apache.xml.internal.resolver.readers.,\
+                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.apache.xml.internal.serializer.utils.,\
                    com.sun.org.apache.xml.internal.utils.,\
-                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.glassfish.,\
+                   oracle.jrockit.jfr.,\
                    org.jcp.xml.dsig.internal.,\
-                   oracle.jrockit.jfr.,\
                    apple.
 
 #
--- a/src/share/lib/security/java.security-solaris	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/lib/security/java.security-solaris	Thu Sep 07 23:37:21 2017 -0700
@@ -149,12 +149,14 @@
                com.sun.org.apache.xalan.internal.xsltc.trax.,\
                com.sun.org.apache.xalan.internal.xsltc.util.,\
                com.sun.org.apache.xml.internal.res.,\
+               com.sun.org.apache.xml.internal.resolver.helpers.,\
+               com.sun.org.apache.xml.internal.resolver.readers.,\
+               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.apache.xml.internal.serializer.utils.,\
                com.sun.org.apache.xml.internal.utils.,\
-               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.glassfish.,\
-               org.jcp.xml.dsig.internal.,\
-               oracle.jrockit.jfr.
+               oracle.jrockit.jfr.,\
+               org.jcp.xml.dsig.internal.
 
 #
 # List of comma-separated packages that start with or equal this string
@@ -190,12 +192,14 @@
                    com.sun.org.apache.xalan.internal.xsltc.trax.,\
                    com.sun.org.apache.xalan.internal.xsltc.util.,\
                    com.sun.org.apache.xml.internal.res.,\
+                   com.sun.org.apache.xml.internal.resolver.helpers.,\
+                   com.sun.org.apache.xml.internal.resolver.readers.,\
+                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.apache.xml.internal.serializer.utils.,\
                    com.sun.org.apache.xml.internal.utils.,\
-                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.glassfish.,\
-                   org.jcp.xml.dsig.internal.,\
-                   oracle.jrockit.jfr.
+                   oracle.jrockit.jfr.,\
+                   org.jcp.xml.dsig.internal.
 
 #
 # Determines whether this properties file can be appended to
--- a/src/share/lib/security/java.security-windows	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/lib/security/java.security-windows	Thu Sep 07 23:37:21 2017 -0700
@@ -148,13 +148,15 @@
                com.sun.org.apache.xalan.internal.xsltc.trax.,\
                com.sun.org.apache.xalan.internal.xsltc.util.,\
                com.sun.org.apache.xml.internal.res.,\
+               com.sun.org.apache.xml.internal.resolver.helpers.,\
+               com.sun.org.apache.xml.internal.resolver.readers.,\
+               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.apache.xml.internal.serializer.utils.,\
                com.sun.org.apache.xml.internal.utils.,\
-               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.glassfish.,\
+               oracle.jrockit.jfr.,\
                org.jcp.xml.dsig.internal.,\
-               com.sun.java.accessibility.,\
-               oracle.jrockit.jfr.
+               com.sun.java.accessibility.
 
 #
 # List of comma-separated packages that start with or equal this string
@@ -190,13 +192,15 @@
                    com.sun.org.apache.xalan.internal.xsltc.trax.,\
                    com.sun.org.apache.xalan.internal.xsltc.util.,\
                    com.sun.org.apache.xml.internal.res.,\
+                   com.sun.org.apache.xml.internal.resolver.helpers.,\
+                   com.sun.org.apache.xml.internal.resolver.readers.,\
+                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.apache.xml.internal.serializer.utils.,\
                    com.sun.org.apache.xml.internal.utils.,\
-                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.glassfish.,\
+                   oracle.jrockit.jfr.,\
                    org.jcp.xml.dsig.internal.,\
-                   com.sun.java.accessibility.,\
-                   oracle.jrockit.jfr.
+                   com.sun.java.accessibility.
 
 #
 # Determines whether this properties file can be appended to
--- a/src/share/native/com/sun/java/util/jar/pack/coding.cpp	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/com/sun/java/util/jar/pack/coding.cpp	Thu Sep 07 23:37:21 2017 -0700
@@ -32,6 +32,8 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
+#include "jni_util.h"
+
 #include "defines.h"
 #include "bytes.h"
 #include "utils.h"
@@ -147,7 +149,7 @@
       break;
   }
   coding* ptr = NEW(coding, 1);
-  CHECK_NULL_0(ptr);
+  CHECK_NULL_RETURN(ptr, 0);
   coding* c = ptr->initFrom(spec);
   if (c == null) {
     mtrace('f', ptr, 0);
--- a/src/share/native/com/sun/java/util/jar/pack/defines.h	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/com/sun/java/util/jar/pack/defines.h	Thu Sep 07 23:37:21 2017 -0700
@@ -158,10 +158,6 @@
 #define CHECK_(y)               _CHECK_DO(aborting(), return y)
 #define CHECK_0                 _CHECK_DO(aborting(), return 0)
 
-#define CHECK_NULL(p)           _CHECK_DO((p)==null, return)
-#define CHECK_NULL_(y,p)        _CHECK_DO((p)==null, return y)
-#define CHECK_NULL_0(p)         _CHECK_DO((p)==null, return 0)
-
 #define CHECK_COUNT(t)          if (t < 0){abort("bad value count");} CHECK
 
 #define STR_TRUE   "true"
--- a/src/share/native/common/check_code.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/common/check_code.c	Thu Sep 07 23:37:21 2017 -0700
@@ -453,6 +453,8 @@
 
 static fullinfo_type cp_index_to_class_fullinfo(context_type *, int, int);
 
+static const char* get_result_signature(const char* signature);
+
 static char signature_to_fieldtype(context_type *context,
                                    const char **signature_p, fullinfo_type *info);
 
@@ -2750,7 +2752,7 @@
                                                                 operand);
             const char *result_signature;
             check_and_push(context, signature, VM_STRING_UTF);
-            result_signature = strchr(signature, JVM_SIGNATURE_ENDFUNC);
+            result_signature = get_result_signature(signature);
             if (result_signature++ == NULL) {
                 CCerror(context, "Illegal signature %s", signature);
             }
@@ -3673,6 +3675,42 @@
     longjmp(context->jump_buffer, 1);
 }
 
+/*
+ * Need to scan the entire signature to find the result type because
+ * types in the arg list and the result type could contain embedded ')'s.
+ */
+static const char* get_result_signature(const char* signature) {
+    const char *p;
+    for (p = signature; *p != JVM_SIGNATURE_ENDFUNC; p++) {
+        switch (*p) {
+          case JVM_SIGNATURE_BOOLEAN:
+          case JVM_SIGNATURE_BYTE:
+          case JVM_SIGNATURE_CHAR:
+          case JVM_SIGNATURE_SHORT:
+          case JVM_SIGNATURE_INT:
+          case JVM_SIGNATURE_FLOAT:
+          case JVM_SIGNATURE_DOUBLE:
+          case JVM_SIGNATURE_LONG:
+          case JVM_SIGNATURE_FUNC:  /* ignore initial (, if given */
+            break;
+          case JVM_SIGNATURE_CLASS:
+            while (*p != JVM_SIGNATURE_ENDCLASS) p++;
+            break;
+          case JVM_SIGNATURE_ARRAY:
+            while (*p == JVM_SIGNATURE_ARRAY) p++;
+            /* If an array of classes, skip over class name, too. */
+            if (*p == JVM_SIGNATURE_CLASS) {
+                while (*p != JVM_SIGNATURE_ENDCLASS) p++;
+            }
+            break;
+          default:
+            /* Indicate an error. */
+            return NULL;
+        }
+    }
+    return p++; /* skip over ')'. */
+}
+
 static char
 signature_to_fieldtype(context_type *context,
                        const char **signature_p, fullinfo_type *full_info_p)
--- a/src/share/native/common/jni_util.h	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/common/jni_util.h	Thu Sep 07 23:37:21 2017 -0700
@@ -285,6 +285,38 @@
 #define IS_NULL(obj) ((obj) == NULL)
 #define JNU_IsNull(env,obj) ((obj) == NULL)
 
+/************************************************************************
+ * Miscellaneous utilities used by the class libraries to return from
+ * a function if a value is NULL or an exception is pending.
+ */
+
+#define CHECK_NULL(x)                           \
+    do {                                        \
+        if ((x) == NULL) {                      \
+            return;                             \
+        }                                       \
+    } while (0)                                 \
+
+#define CHECK_NULL_RETURN(x, y)                 \
+    do {                                        \
+        if ((x) == NULL) {                      \
+            return (y);                         \
+        }                                       \
+    } while (0)                                 \
+
+#define JNU_CHECK_EXCEPTION(env)                \
+    do {                                        \
+        if ((*env)->ExceptionCheck(env)) {      \
+            return;                             \
+        }                                       \
+    } while (0)                                 \
+
+#define JNU_CHECK_EXCEPTION_RETURN(env, y)      \
+    do {                                        \
+        if ((*env)->ExceptionCheck(env)) {      \
+            return (y);                         \
+        }                                       \
+    } while (0)
 
 /************************************************************************
  * Debugging utilities
--- a/src/share/native/java/net/net_util.h	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/java/net/net_util.h	Thu Sep 07 23:37:21 2017 -0700
@@ -42,9 +42,6 @@
 #define NET_ERROR(env, ex, msg) \
 { if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); }
 
-#define CHECK_NULL(x) if ((x) == NULL) return;
-#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y;
-
 /************************************************************************
  * Cached field IDs
  *
--- a/src/share/native/sun/awt/image/BufImgSurfaceData.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,17 +69,14 @@
     }
 
     clsICMCD = (*env)->NewWeakGlobalRef(env, cd);
-    initICMCDmID = (*env)->GetMethodID(env, cd, "<init>", "(J)V");
-    pDataID = (*env)->GetFieldID(env, cd, "pData", "J");
-
-    rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
-    allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
-    mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
-    colorDataID = (*env)->GetFieldID(env, icm, "colorData",
-        "Lsun/awt/image/BufImgSurfaceData$ICMColorData;");
-    if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || pDataID == 0|| colorDataID == 0 || initICMCDmID == 0) {
-        JNU_ThrowInternalError(env, "Could not get field IDs");
-    }
+    JNU_CHECK_EXCEPTION(env);
+    CHECK_NULL(initICMCDmID = (*env)->GetMethodID(env, cd, "<init>", "(J)V"));
+    CHECK_NULL(pDataID = (*env)->GetFieldID(env, cd, "pData", "J"));
+    CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
+    CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
+    CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
+    CHECK_NULL(colorDataID = (*env)->GetFieldID(env, icm, "colorData",
+                                           "Lsun/awt/image/BufImgSurfaceData$ICMColorData;"));
 }
 
 /*
@@ -120,6 +117,7 @@
     bisdo->sdOps.Unlock = NULL;
     bisdo->sdOps.Dispose = BufImg_Dispose;
     bisdo->array = (*env)->NewWeakGlobalRef(env, array);
+    JNU_CHECK_EXCEPTION(env);
     bisdo->offset = offset;
     bisdo->bitoffset = bitoffset;
     bisdo->scanStr = scanStr;
@@ -131,6 +129,7 @@
     } else {
         jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
         bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
+        JNU_CHECK_EXCEPTION(env);
         bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
         bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
     }
@@ -174,8 +173,8 @@
     {
         bipriv->cData = BufImg_SetupICM(env, bisdo);
         if (bipriv->cData == NULL) {
-            JNU_ThrowNullPointerException(env, "Could not initialize "
-                                          "inverse tables");
+            (*env)->ExceptionClear(env);
+            JNU_ThrowNullPointerException(env, "Could not initialize inverse tables");
             return SD_FAILURE;
         }
     } else {
@@ -201,6 +200,7 @@
     if ((bipriv->lockFlags & (SD_LOCK_RD_WR)) != 0) {
         bipriv->base =
             (*env)->GetPrimitiveArrayCritical(env, bisdo->array, NULL);
+        CHECK_NULL(bipriv->base);
     }
     if ((bipriv->lockFlags & (SD_LOCK_LUT)) != 0) {
         bipriv->lutbase =
@@ -291,6 +291,7 @@
             = (*env)->GetBooleanField(env, bisdo->icm, allGrayID);
         int *pRgb = (int *)
             ((*env)->GetPrimitiveArrayCritical(env, bisdo->lutarray, NULL));
+        CHECK_NULL_RETURN(pRgb, (ColorData*)NULL);
         cData->img_clr_tbl = initCubemap(pRgb, bisdo->lutsize, 32);
         if (allGray == JNI_TRUE) {
             initInverseGrayLut(pRgb, bisdo->lutsize, cData);
@@ -303,6 +304,7 @@
         if (JNU_IsNull(env, colorData)) {
             jlong pData = ptr_to_jlong(cData);
             colorData = (*env)->NewObjectA(env, clsICMCD, initICMCDmID, (jvalue *)&pData);
+            JNU_CHECK_EXCEPTION_RETURN(env, (ColorData*)NULL);
             (*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData);
         }
     }
--- a/src/share/native/sun/awt/image/DataBufferNative.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/DataBufferNative.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,7 @@
     SurfaceDataOps *ops;
 
     ops = SurfaceData_GetOps(env, sd);
+    JNU_CHECK_EXCEPTION_RETURN(env, -1);
 
     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
                                          ops, SD_LOCK_READ)))
@@ -115,6 +116,7 @@
 
 
     ops = SurfaceData_GetOps(env, sd);
+    JNU_CHECK_EXCEPTION(env);
 
     if (!(pixelPtr = DBN_GetPixelPointer(env, x, y, &lockInfo,
                                          ops, SD_LOCK_WRITE)))
--- a/src/share/native/sun/awt/image/awt_ImageRep.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/awt_ImageRep.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -97,9 +97,9 @@
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ImageRepresentation_initIDs(JNIEnv *env, jclass cls) {
-    s_JnumSrcLUTID = (*env)->GetFieldID(env, cls, "numSrcLUT", "I");
-    s_JsrcLUTtransIndexID = (*env)->GetFieldID(env, cls, "srcLUTtransIndex",
-                                               "I");
+    CHECK_NULL(s_JnumSrcLUTID = (*env)->GetFieldID(env, cls, "numSrcLUT", "I"));
+    CHECK_NULL(s_JsrcLUTtransIndexID = (*env)->GetFieldID(env, cls,
+                                                          "srcLUTtransIndex", "I"));
 }
 
 /*
@@ -166,6 +166,7 @@
 
     cOffs = (int *) (*env)->GetPrimitiveArrayCritical(env, joffs, NULL);
     if (cOffs == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null channel offset array");
         return JNI_FALSE;
     }
@@ -190,6 +191,7 @@
 
     srcLUT = (int *) (*env)->GetPrimitiveArrayCritical(env, jlut, NULL);
     if (srcLUT == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null IndexColorModel LUT");
         return JNI_FALSE;
     }
@@ -198,6 +200,7 @@
                                                                   NULL);
     if (srcData == NULL) {
         (*env)->ReleasePrimitiveArrayCritical(env, jlut, srcLUT, JNI_ABORT);
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null data array");
         return JNI_FALSE;
     }
@@ -206,6 +209,7 @@
     if (dstData == NULL) {
         (*env)->ReleasePrimitiveArrayCritical(env, jlut, srcLUT, JNI_ABORT);
         (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT);
+        (*env)->ExceptionClear(env);
         JNU_ThrowNullPointerException(env, "Null tile data array");
         return JNI_FALSE;
     }
--- a/src/share/native/sun/awt/image/awt_parseImage.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/awt_parseImage.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -182,6 +182,11 @@
 int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
     jobject joffs = NULL;
     /* int status;*/
+    jclass singlePixelPackedSampleModelClass = NULL;
+    jclass integerComponentRasterClass = NULL;
+    jclass byteComponentRasterClass = NULL;
+    jclass shortComponentRasterClass = NULL;
+    jclass bytePackedRasterClass = NULL;
 
     if (JNU_IsNull(env, jraster)) {
         JNU_ThrowNullPointerException(env, "null Raster object");
@@ -226,8 +231,11 @@
 
     rasterP->sppsm.isUsed = 0;
 
+    singlePixelPackedSampleModelClass = (*env)->FindClass(env,
+                            "java/awt/image/SinglePixelPackedSampleModel");
+    CHECK_NULL_RETURN(singlePixelPackedSampleModelClass, -1);
     if ((*env)->IsInstanceOf(env, rasterP->jsampleModel,
-       (*env)->FindClass(env,"java/awt/image/SinglePixelPackedSampleModel"))) {
+                             singlePixelPackedSampleModelClass)) {
         jobject jmask, joffs, jnbits;
 
         rasterP->sppsm.isUsed = 1;
@@ -261,8 +269,15 @@
                                                     rasterP->jsampleModel,
                                                     g_SMHeightID);
 
-    if ((*env)->IsInstanceOf(env, jraster,
-         (*env)->FindClass(env, "sun/awt/image/IntegerComponentRaster"))){
+    integerComponentRasterClass = (*env)->FindClass(env, "sun/awt/image/IntegerComponentRaster");
+    CHECK_NULL_RETURN(integerComponentRasterClass, -1);
+    byteComponentRasterClass = (*env)->FindClass(env, "sun/awt/image/ByteComponentRaster");
+    CHECK_NULL_RETURN(byteComponentRasterClass, -1);
+    shortComponentRasterClass = (*env)->FindClass(env,"sun/awt/image/ShortComponentRaster");
+    CHECK_NULL_RETURN(shortComponentRasterClass, -1);
+    bytePackedRasterClass = (*env)->FindClass(env, "sun/awt/image/BytePackedRaster");
+    CHECK_NULL_RETURN(bytePackedRasterClass, -1);
+    if ((*env)->IsInstanceOf(env, jraster, integerComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_ICRdataID);
         rasterP->dataType = INT_DATA_TYPE;
         rasterP->dataSize = 4;
@@ -273,8 +288,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_ICRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_ICRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/ByteComponentRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, byteComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_BCRdataID);
         rasterP->dataType = BYTE_DATA_TYPE;
         rasterP->dataSize = 1;
@@ -285,8 +299,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_BCRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_BCRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/ShortComponentRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, shortComponentRasterClass)){
         rasterP->jdata = (*env)->GetObjectField(env, jraster, g_SCRdataID);
         rasterP->dataType = SHORT_DATA_TYPE;
         rasterP->dataSize = 2;
@@ -297,8 +310,7 @@
         rasterP->pixelStride = (*env)->GetIntField(env, jraster, g_SCRpixstrID);
         joffs = (*env)->GetObjectField(env, jraster, g_SCRdataOffsetsID);
     }
-    else if ((*env)->IsInstanceOf(env, jraster,
-            (*env)->FindClass(env, "sun/awt/image/BytePackedRaster"))){
+    else if ((*env)->IsInstanceOf(env, jraster, bytePackedRasterClass)){
         rasterP->rasterType = PACKED_RASTER_TYPE;
         rasterP->dataType = BYTE_DATA_TYPE;
         rasterP->dataSize = 1;
@@ -397,30 +409,41 @@
 }
 
 static int getColorModelType(JNIEnv *env, jobject jcmodel) {
-    int type = UNKNOWN_CM_TYPE;
+    jclass colorModelClass;
 
-    if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/IndexColorModel")))
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/IndexColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        type = INDEX_CM_TYPE;
-    } else if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/PackedColorModel")))
+        return INDEX_CM_TYPE;
+    }
+
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/PackedColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        if  ((*env)->IsInstanceOf(env, jcmodel,
-                (*env)->FindClass(env, "java/awt/image/DirectColorModel"))) {
-            type = DIRECT_CM_TYPE;
+        colorModelClass = (*env)->FindClass(env,
+                                            "java/awt/image/DirectColorModel");
+        CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+        if  ((*env)->IsInstanceOf(env, jcmodel, colorModelClass)) {
+            return DIRECT_CM_TYPE;
         }
         else {
-            type = PACKED_CM_TYPE;
+            return PACKED_CM_TYPE;
         }
     }
-    else if ((*env)->IsInstanceOf(env, jcmodel,
-                 (*env)->FindClass(env, "java/awt/image/ComponentColorModel")))
+    colorModelClass = (*env)->FindClass(env,
+                                        "java/awt/image/ComponentColorModel");
+    CHECK_NULL_RETURN(colorModelClass, UNKNOWN_CM_TYPE);
+    if ((*env)->IsInstanceOf(env, jcmodel, colorModelClass))
     {
-        type = COMPONENT_CM_TYPE;
+        return COMPONENT_CM_TYPE;
     }
 
-    return type;
+    return UNKNOWN_CM_TYPE;
 }
 
 int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,
@@ -506,12 +529,13 @@
         if (s_jdefCM == NULL) {
             jobject defCM;
             jclass jcm = (*env)->FindClass(env, "java/awt/image/ColorModel");
+            CHECK_NULL_RETURN(jcm, -1);
             defCM = (*env)->CallStaticObjectMethod(env, jcm,
                                                    g_CMgetRGBdefaultMID, NULL);
             s_jdefCM = (*env)->NewGlobalRef(env, defCM);
             if (defCM == NULL || s_jdefCM == NULL) {
-                JNU_ThrowNullPointerException(env,
-                                              "Unable to find default CM");
+                (*env)->ExceptionClear(env);
+                JNU_ThrowNullPointerException(env, "Unable to find default CM");
                 return -1;
             }
         }
@@ -866,6 +890,7 @@
 
     jdata = (*env)->NewIntArray(env, maxSamples);
     if (JNU_IsNull(env, jdata)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -963,6 +988,7 @@
 
     jdata = (*env)->NewIntArray(env, maxSamples);
     if (JNU_IsNull(env, jdata)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
--- a/src/share/native/sun/awt/image/gif/gifdecoder.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/gif/gifdecoder.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,12 +104,12 @@
 JNIEXPORT void JNICALL
 Java_sun_awt_image_GifImageDecoder_initIDs(JNIEnv *env, jclass this)
 {
-    readID = (*env)->GetMethodID(env, this, "readBytes", "([BII)I");
-    sendID = (*env)->GetMethodID(env, this, "sendPixels",
-                                 "(IIII[BLjava/awt/image/ColorModel;)I");
-    prefixID = (*env)->GetFieldID(env, this, "prefix", "[S");
-    suffixID = (*env)->GetFieldID(env, this, "suffix", "[B");
-    outCodeID = (*env)->GetFieldID(env, this, "outCode", "[B");
+    CHECK_NULL(readID = (*env)->GetMethodID(env, this, "readBytes", "([BII)I"));
+    CHECK_NULL(sendID = (*env)->GetMethodID(env, this, "sendPixels",
+                                 "(IIII[BLjava/awt/image/ColorModel;)I"));
+    CHECK_NULL(prefixID = (*env)->GetFieldID(env, this, "prefix", "[S"));
+    CHECK_NULL(suffixID = (*env)->GetFieldID(env, this, "suffix", "[B"));
+    CHECK_NULL(outCodeID = (*env)->GetFieldID(env, this, "outCode", "[B"));
 }
 
 JNIEXPORT jboolean JNICALL
@@ -292,8 +292,10 @@
              * reads the immediately subsequent code as uncompressed data.
              */
             if (verbose) {
+                RELEASE_ARRAYS();
                 fprintf(stdout, ".");
                 fflush(stdout);
+                GET_ARRAYS();
             }
 
             /* Note that freeCode is one less than it is supposed to be,
@@ -319,10 +321,10 @@
             /* make sure we read the whole block of pixels. */
         flushit:
             while (!blockEnd) {
+                RELEASE_ARRAYS();
                 if (verbose) {
                     fprintf(stdout, "flushing %d bytes\n", blockLength);
                 }
-                RELEASE_ARRAYS();
                 if ((*env)->CallIntMethod(env, this, readID,
                                           blockh, 0, blockLength + 1) != 0
                     || (*env)->ExceptionOccurred(env))
--- a/src/share/native/sun/awt/image/imageInitIDs.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/imageInitIDs.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,211 +29,139 @@
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_BufferedImage_initIDs(JNIEnv *env, jclass cls) {
-    g_BImgRasterID     = (*env)->GetFieldID(env, cls, "raster",
-                                            "Ljava/awt/image/WritableRaster;");
-    g_BImgTypeID = (*env)->GetFieldID(env, cls, "imageType", "I");
-    g_BImgCMID = (*env)->GetFieldID(env, cls, "colorModel",
-                                    "Ljava/awt/image/ColorModel;");
-    g_BImgGetRGBMID = (*env)->GetMethodID(env, cls, "getRGB",
-                                          "(IIII[III)[I");
-    g_BImgSetRGBMID = (*env)->GetMethodID(env, cls, "setRGB",
-                                          "(IIII[III)V");
-    if (g_BImgRasterID == NULL || g_BImgTypeID == NULL || g_BImgCMID == NULL
-        || g_BImgGetRGBMID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BImgRasterID = (*env)->GetFieldID(env, cls, "raster",
+                                        "Ljava/awt/image/WritableRaster;"));
+    CHECK_NULL(g_BImgTypeID = (*env)->GetFieldID(env, cls, "imageType", "I"));
+    CHECK_NULL(g_BImgCMID = (*env)->GetFieldID(env, cls, "colorModel",
+                                        "Ljava/awt/image/ColorModel;"));
+    CHECK_NULL(g_BImgGetRGBMID = (*env)->GetMethodID(env, cls, "getRGB",
+                                        "(IIII[III)[I"));
+    CHECK_NULL(g_BImgSetRGBMID = (*env)->GetMethodID(env, cls, "setRGB",
+                                        "(IIII[III)V"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_Raster_initIDs(JNIEnv *env, jclass cls) {
-    g_RasterWidthID    = (*env)->GetFieldID(env, cls, "width", "I");
-    g_RasterHeightID   = (*env)->GetFieldID(env, cls, "height", "I");
-    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
-    g_RasterGetDataMID = (*env)->GetMethodID(env, cls, "getDataElements",
-                              "(IIIILjava/lang/Object;)Ljava/lang/Object;");
-    g_RasterMinXID  = (*env)->GetFieldID(env, cls, "minX", "I");
-    g_RasterMinYID  = (*env)->GetFieldID(env, cls, "minY", "I");
-    g_RasterBaseOriginXID  = (*env)->GetFieldID(env, cls,
-                                 "sampleModelTranslateX", "I");
-    g_RasterBaseOriginYID  = (*env)->GetFieldID(env, cls,
-                                 "sampleModelTranslateY", "I");
-    g_RasterSampleModelID = (*env)->GetFieldID(env, cls,
-                                 "sampleModel","Ljava/awt/image/SampleModel;");
-    g_RasterNumDataElementsID = (*env)->GetFieldID(env, cls, "numDataElements",
-                                                   "I");
-    g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I");
-    g_RasterDataBufferID = (*env)->GetFieldID(env, cls, "dataBuffer",
-                                              "Ljava/awt/image/DataBuffer;");
-    if (g_RasterWidthID == NULL || g_RasterHeightID == NULL
-        || g_RasterNumBandsID == NULL || g_RasterGetDataMID == NULL
-        || g_RasterMinXID == NULL || g_RasterMinYID == NULL
-        || g_RasterBaseOriginXID == NULL || g_RasterBaseOriginYID == NULL
-        || g_RasterSampleModelID == NULL || g_RasterNumDataElementsID == NULL
-        || g_RasterNumBandsID == NULL || g_RasterDataBufferID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_RasterWidthID    = (*env)->GetFieldID(env, cls, "width", "I"));
+    CHECK_NULL(g_RasterHeightID   = (*env)->GetFieldID(env, cls, "height", "I"));
+    CHECK_NULL(g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I"));
+    CHECK_NULL(g_RasterGetDataMID = (*env)->GetMethodID(env, cls, "getDataElements",
+                                        "(IIIILjava/lang/Object;)Ljava/lang/Object;"));
+    CHECK_NULL(g_RasterMinXID  = (*env)->GetFieldID(env, cls, "minX", "I"));
+    CHECK_NULL(g_RasterMinYID  = (*env)->GetFieldID(env, cls, "minY", "I"));
+    CHECK_NULL(g_RasterBaseOriginXID  = (*env)->GetFieldID(env, cls,
+                                        "sampleModelTranslateX", "I"));
+    CHECK_NULL(g_RasterBaseOriginYID  = (*env)->GetFieldID(env, cls,
+                                        "sampleModelTranslateY", "I"));
+    CHECK_NULL(g_RasterSampleModelID = (*env)->GetFieldID(env, cls,
+                                        "sampleModel","Ljava/awt/image/SampleModel;"));
+    CHECK_NULL(g_RasterNumDataElementsID = (*env)->GetFieldID(env, cls,
+                                        "numDataElements", "I"));
+    CHECK_NULL(g_RasterNumBandsID = (*env)->GetFieldID(env, cls, "numBands", "I"));
+    CHECK_NULL(g_RasterDataBufferID = (*env)->GetFieldID(env, cls, "dataBuffer",
+                                        "Ljava/awt/image/DataBuffer;"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ByteComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_BCRdataID = (*env)->GetFieldID(env, cls, "data", "[B");
-    g_BCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_BCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_BCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_BCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_BCRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_BCRdataID == NULL || g_BCRscanstrID == NULL ||
-        g_BCRpixstrID == NULL || g_BCRbandoffsID == NULL ||
-        g_BCRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BCRdataID = (*env)->GetFieldID(env, cls, "data", "[B"));
+    CHECK_NULL(g_BCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_BCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_BCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_BCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_BCRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_BytePackedRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_BPRdataID = (*env)->GetFieldID(env, cls, "data", "[B");
-    g_BPRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_BPRpixstrID = (*env)->GetFieldID(env, cls, "pixelBitStride", "I");
-    g_BPRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    g_BPRdataBitOffsetID = (*env)->GetFieldID(env, cls, "dataBitOffset", "I");
-    if (g_BPRdataID == NULL || g_BPRscanstrID == NULL ||
-        g_BPRpixstrID == NULL ||  g_BPRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_BPRdataID = (*env)->GetFieldID(env, cls, "data", "[B"));
+    CHECK_NULL(g_BPRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_BPRpixstrID = (*env)->GetFieldID(env, cls, "pixelBitStride", "I"));
+    CHECK_NULL(g_BPRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
+    CHECK_NULL(g_BPRdataBitOffsetID = (*env)->GetFieldID(env, cls, "dataBitOffset", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_sun_awt_image_ShortComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_SCRdataID = (*env)->GetFieldID(env, cls, "data", "[S");
-    g_SCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_SCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_SCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_SCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_SCRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_SCRdataID == NULL || g_SCRscanstrID == NULL ||
-        g_SCRpixstrID == NULL || g_SCRbandoffsID == NULL ||
-        g_SCRdataOffsetsID == NULL || g_SCRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_SCRdataID = (*env)->GetFieldID(env, cls, "data", "[S"));
+    CHECK_NULL(g_SCRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_SCRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_SCRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_SCRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_SCRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 JNIEXPORT void JNICALL
 Java_sun_awt_image_IntegerComponentRaster_initIDs(JNIEnv *env, jclass cls) {
-    g_ICRdataID = (*env)->GetFieldID(env, cls, "data", "[I");
-    g_ICRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_ICRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_ICRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I");
-    g_ICRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I");
-    g_ICRputDataMID  = (*env)->GetMethodID(env, cls, "setDataElements",
-                                     "(IIIILjava/lang/Object;)V");
-    g_ICRtypeID = (*env)->GetFieldID(env, cls, "type", "I");
-    if (g_ICRdataID == NULL || g_ICRscanstrID == NULL
-        || g_ICRpixstrID == NULL || g_ICRbandoffsID == NULL
-        || g_ICRputDataMID == NULL || g_ICRdataOffsetsID == NULL || g_ICRtypeID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_ICRdataID = (*env)->GetFieldID(env, cls, "data", "[I"));
+    CHECK_NULL(g_ICRscanstrID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_ICRpixstrID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_ICRdataOffsetsID = (*env)->GetFieldID(env, cls, "dataOffsets", "[I"));
+    CHECK_NULL(g_ICRbandoffsID = (*env)->GetFieldID(env, cls, "bandOffset", "I"));
+    CHECK_NULL(g_ICRputDataMID  = (*env)->GetMethodID(env, cls, "setDataElements",
+                                     "(IIIILjava/lang/Object;)V"));
+    CHECK_NULL(g_ICRtypeID = (*env)->GetFieldID(env, cls, "type", "I"));
 }
 
 JNIEXPORT void JNICALL
-Java_java_awt_image_SinglePixelPackedSampleModel_initIDs(JNIEnv *env,
-                                                         jclass cls) {
-    g_SPPSMmaskArrID = (*env)->GetFieldID(env, cls, "bitMasks", "[I");
-    g_SPPSMmaskOffID = (*env)->GetFieldID(env, cls, "bitOffsets", "[I");
-    g_SPPSMnBitsID   = (*env)->GetFieldID(env, cls, "bitSizes", "[I");
-    g_SPPSMmaxBitID  = (*env)->GetFieldID(env, cls, "maxBitSize", "I");
-
-    if (g_SPPSMmaskArrID == NULL || g_SPPSMmaskOffID == NULL ||
-        g_SPPSMnBitsID == NULL || g_SPPSMmaxBitID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+Java_java_awt_image_SinglePixelPackedSampleModel_initIDs(JNIEnv *env, jclass cls) {
+    CHECK_NULL(g_SPPSMmaskArrID = (*env)->GetFieldID(env, cls, "bitMasks", "[I"));
+    CHECK_NULL(g_SPPSMmaskOffID = (*env)->GetFieldID(env, cls, "bitOffsets", "[I"));
+    CHECK_NULL(g_SPPSMnBitsID   = (*env)->GetFieldID(env, cls, "bitSizes", "[I"));
+    CHECK_NULL(g_SPPSMmaxBitID  = (*env)->GetFieldID(env, cls, "maxBitSize", "I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_ColorModel_initIDs(JNIEnv *env, jclass cls) {
-    g_CMpDataID = (*env)->GetFieldID (env, cls, "pData", "J");
-    g_CMnBitsID  = (*env)->GetFieldID(env, cls, "nBits", "[I");
-    g_CMcspaceID = (*env)->GetFieldID(env, cls, "colorSpace",
-                                    "Ljava/awt/color/ColorSpace;");
-    g_CMnumComponentsID = (*env)->GetFieldID(env, cls, "numComponents", "I");
-    g_CMsuppAlphaID  = (*env)->GetFieldID(env, cls, "supportsAlpha", "Z");
-    g_CMisAlphaPreID = (*env)->GetFieldID(env, cls, "isAlphaPremultiplied",
-                                          "Z");
-    g_CMtransparencyID = (*env)->GetFieldID(env, cls, "transparency", "I");
-    g_CMgetRGBMID      = (*env)->GetMethodID(env, cls, "getRGB",
-                                             "(Ljava/lang/Object;)I");
-    g_CMcsTypeID       = (*env)->GetFieldID(env, cls, "colorSpaceType", "I");
-    g_CMis_sRGBID      = (*env)->GetFieldID(env, cls, "is_sRGB", "Z");
-    g_CMgetRGBdefaultMID   = (*env)->GetStaticMethodID(env, cls,
+    CHECK_NULL(g_CMpDataID = (*env)->GetFieldID (env, cls, "pData", "J"));
+    CHECK_NULL(g_CMnBitsID  = (*env)->GetFieldID(env, cls, "nBits", "[I"));
+    CHECK_NULL(g_CMcspaceID = (*env)->GetFieldID(env, cls, "colorSpace",
+                                    "Ljava/awt/color/ColorSpace;"));
+    CHECK_NULL(g_CMnumComponentsID = (*env)->GetFieldID(env, cls, "numComponents", "I"));
+    CHECK_NULL(g_CMsuppAlphaID  = (*env)->GetFieldID(env, cls, "supportsAlpha", "Z"));
+    CHECK_NULL(g_CMisAlphaPreID = (*env)->GetFieldID(env, cls, "isAlphaPremultiplied",
+                                          "Z"));
+    CHECK_NULL(g_CMtransparencyID = (*env)->GetFieldID(env, cls, "transparency", "I"));
+    CHECK_NULL(g_CMgetRGBMID      = (*env)->GetMethodID(env, cls, "getRGB",
+                                             "(Ljava/lang/Object;)I"));
+    CHECK_NULL(g_CMcsTypeID       = (*env)->GetFieldID(env, cls, "colorSpaceType", "I"));
+    CHECK_NULL(g_CMis_sRGBID      = (*env)->GetFieldID(env, cls, "is_sRGB", "Z"));
+    CHECK_NULL(g_CMgetRGBdefaultMID   = (*env)->GetStaticMethodID(env, cls,
                                                        "getRGBdefault",
-                                             "()Ljava/awt/image/ColorModel;");
-    if (g_CMnBitsID == NULL || g_CMcspaceID == NULL
-        || g_CMnumComponentsID == NULL || g_CMsuppAlphaID == NULL
-        || g_CMisAlphaPreID == NULL || g_CMtransparencyID == NULL
-        || g_CMgetRGBMID == NULL || g_CMgetRGBMID == NULL
-        || g_CMis_sRGBID == NULL || g_CMgetRGBdefaultMID == NULL
-        || g_CMpDataID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+                                             "()Ljava/awt/image/ColorModel;"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_IndexColorModel_initIDs(JNIEnv *env, jclass cls) {
-    g_ICMtransIdxID = (*env)->GetFieldID(env, cls, "transparent_index", "I");
-    g_ICMmapSizeID  = (*env)->GetFieldID(env, cls, "map_size", "I");
-    g_ICMrgbID      = (*env)->GetFieldID(env, cls, "rgb", "[I");
-    if (g_ICMtransIdxID == NULL || g_ICMmapSizeID == NULL
-        || g_ICMrgbID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_ICMtransIdxID = (*env)->GetFieldID(env, cls, "transparent_index", "I"));
+    CHECK_NULL(g_ICMmapSizeID  = (*env)->GetFieldID(env, cls, "map_size", "I"));
+    CHECK_NULL(g_ICMrgbID      = (*env)->GetFieldID(env, cls, "rgb", "[I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_SampleModel_initIDs(JNIEnv *env, jclass cls) {
-    g_SMWidthID = (*env)->GetFieldID(env, cls, "width","I");
-    g_SMHeightID = (*env)->GetFieldID(env, cls, "height","I");
-    g_SMGetPixelsMID = (*env)->GetMethodID(env, cls, "getPixels",
-                                      "(IIII[ILjava/awt/image/DataBuffer;)[I");
-    g_SMSetPixelsMID = (*env)->GetMethodID(env, cls, "setPixels",
-                                      "(IIII[ILjava/awt/image/DataBuffer;)V");
-    if (g_SMWidthID == NULL || g_SMHeightID == NULL || g_SMGetPixelsMID == NULL
-        || g_SMSetPixelsMID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_SMWidthID = (*env)->GetFieldID(env, cls, "width","I"));
+    CHECK_NULL(g_SMHeightID = (*env)->GetFieldID(env, cls, "height","I"));
+    CHECK_NULL(g_SMGetPixelsMID = (*env)->GetMethodID(env, cls, "getPixels",
+                                      "(IIII[ILjava/awt/image/DataBuffer;)[I"));
+    CHECK_NULL(g_SMSetPixelsMID = (*env)->GetMethodID(env, cls, "setPixels",
+                                      "(IIII[ILjava/awt/image/DataBuffer;)V"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_ComponentSampleModel_initIDs(JNIEnv *env, jclass cls) {
-    g_CSMPixStrideID = (*env)->GetFieldID(env, cls, "pixelStride", "I");
-    g_CSMScanStrideID = (*env)->GetFieldID(env, cls, "scanlineStride", "I");
-    g_CSMBandOffsetsID = (*env)->GetFieldID(env, cls, "bandOffsets", "[I");
-    if (g_CSMPixStrideID == NULL || g_CSMScanStrideID == NULL ||
-        g_CSMBandOffsetsID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_CSMPixStrideID = (*env)->GetFieldID(env, cls, "pixelStride", "I"));
+    CHECK_NULL(g_CSMScanStrideID = (*env)->GetFieldID(env, cls, "scanlineStride", "I"));
+    CHECK_NULL(g_CSMBandOffsetsID = (*env)->GetFieldID(env, cls, "bandOffsets", "[I"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_Kernel_initIDs(JNIEnv *env, jclass cls) {
-    g_KernelWidthID   = (*env)->GetFieldID(env, cls, "width", "I");
-    g_KernelHeightID  = (*env)->GetFieldID(env, cls, "height", "I");
-    g_KernelDataID    = (*env)->GetFieldID(env, cls, "data", "[F");
-    if (g_KernelWidthID == NULL || g_KernelHeightID == NULL
-        || g_KernelDataID == NULL)
-    {
-        JNU_ThrowNullPointerException(env, "Unable to grab field ids");
-    }
+    CHECK_NULL(g_KernelWidthID   = (*env)->GetFieldID(env, cls, "width", "I"));
+    CHECK_NULL(g_KernelHeightID  = (*env)->GetFieldID(env, cls, "height", "I"));
+    CHECK_NULL(g_KernelDataID    = (*env)->GetFieldID(env, cls, "data", "[F"));
 }
 
 JNIEXPORT void JNICALL
 Java_java_awt_image_DataBufferInt_initIDs(JNIEnv *env, jclass cls) {
-    g_DataBufferIntPdataID = (*env)->GetFieldID(env, cls, "pData", "J");
-    if (g_DataBufferIntPdataID == NULL) {
-        JNU_ThrowNullPointerException(env, "Unable to grab DataBufferInt.pData");
-        return;
-    }
+    CHECK_NULL(g_DataBufferIntPdataID = (*env)->GetFieldID(env, cls, "pData", "J"));
 }
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,7 @@
 static jmethodID JPEGImageReader_pushBackID;
 static jmethodID JPEGImageReader_passStartedID;
 static jmethodID JPEGImageReader_passCompleteID;
+static jmethodID JPEGImageReader_skipPastImageID;
 static jmethodID JPEGImageWriter_writeOutputDataID;
 static jmethodID JPEGImageWriter_warningOccurredID;
 static jmethodID JPEGImageWriter_warningWithMessageID;
@@ -153,6 +154,7 @@
     /* Initialize a new buffer */
     jbyteArray hInputBuffer = (*env)->NewByteArray(env, STREAMBUF_SIZE);
     if (hInputBuffer == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Reader");
@@ -546,29 +548,43 @@
 METHODDEF(void)
 sun_jpeg_output_message (j_common_ptr cinfo)
 {
-  char buffer[JMSG_LENGTH_MAX];
-  jstring string;
-  imageIODataPtr data = (imageIODataPtr) cinfo->client_data;
-  JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-  jobject theObject;
-
-  /* Create the message */
-  (*cinfo->err->format_message) (cinfo, buffer);
-
-  // Create a new java string from the message
-  string = (*env)->NewStringUTF(env, buffer);
-
-  theObject = data->imageIOobj;
-
-  if (cinfo->is_decompressor) {
-      (*env)->CallVoidMethod(env, theObject,
-                             JPEGImageReader_warningWithMessageID,
-                             string);
-  } else {
-      (*env)->CallVoidMethod(env, theObject,
-                             JPEGImageWriter_warningWithMessageID,
-                             string);
-  }
+    char buffer[JMSG_LENGTH_MAX];
+    jstring string;
+    imageIODataPtr data = (imageIODataPtr) cinfo->client_data;
+    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+    jobject theObject;
+
+    /* Create the message */
+    (*cinfo->err->format_message) (cinfo, buffer);
+
+    // Create a new java string from the message
+    string = (*env)->NewStringUTF(env, buffer);
+    CHECK_NULL(string);
+
+    theObject = data->imageIOobj;
+
+    if (cinfo->is_decompressor) {
+        struct jpeg_source_mgr *src = ((j_decompress_ptr)cinfo)->src;
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
+        (*env)->CallVoidMethod(env, theObject,
+            JPEGImageReader_warningWithMessageID,
+            string);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+            cinfo->err->error_exit(cinfo);
+        }
+    } else {
+        struct jpeg_destination_mgr *dest = ((j_compress_ptr)cinfo)->dest;
+        RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
+        (*env)->CallVoidMethod(env, theObject,
+            JPEGImageWriter_warningWithMessageID,
+            string);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data,
+            (const JOCTET **)(&dest->next_output_byte))) {
+            cinfo->err->error_exit(cinfo);
+        }
+    }
 }
 
 /* End of verbatim copy from jpegdecoder.c */
@@ -591,12 +607,7 @@
     /* Now we need a new weak global reference for the I/O provider */
     if (io != NULL) { // Fix for 4411955
         sb->ioRef = (*env)->NewWeakGlobalRef(env, io);
-        if (sb->ioRef == NULL) {
-            JNU_ThrowByName(env,
-                            "java/lang/OutOfMemoryError",
-                            "Setting I/O provider");
-            return;
-        }
+        CHECK_NULL(sb->ioRef);
     }
 
     /* And finally reset state */
@@ -693,6 +704,7 @@
     }
     for (i = 0; i < qlen; i++) {
         table = (*env)->GetObjectArrayElement(env, qtables, i);
+        CHECK_NULL_RETURN(table, 0);
         qdata = (*env)->GetObjectField(env, table, JPEGQTable_tableID);
         qdataBody = (*env)->GetPrimitiveArrayCritical(env, qdata, NULL);
 
@@ -724,7 +736,7 @@
     return qlen;
 }
 
-static void setHuffTable(JNIEnv *env,
+static boolean setHuffTable(JNIEnv *env,
                          JHUFF_TBL *huff_ptr,
                          jobject table) {
 
@@ -742,6 +754,8 @@
     hlensBody = (*env)->GetShortArrayElements(env,
                                               huffLens,
                                               NULL);
+    CHECK_NULL_RETURN(hlensBody, FALSE);
+
     if (hlensLen > 16) {
         /* Ignore extra elements of bits array. Only 16 elements can be
            stored. 0-th element is not used. (see jpeglib.h, line 107)  */
@@ -762,6 +776,7 @@
     hvalsBody = (*env)->GetShortArrayElements(env,
                                               huffValues,
                                               NULL);
+    CHECK_NULL_RETURN(hvalsBody, FALSE);
 
     if (hvalsLen > 256) {
         /* Ignore extra elements of hufval array. Only 256 elements
@@ -775,6 +790,7 @@
                                       huffValues,
                                       hvalsBody,
                                       JNI_ABORT);
+    return TRUE;
 }
 
 static int setHTables(JNIEnv *env,
@@ -810,7 +826,9 @@
             huff_ptr = comp->dc_huff_tbl_ptrs[i];
         }
         table = (*env)->GetObjectArrayElement(env, DCHuffmanTables, i);
-        setHuffTable(env, huff_ptr, table);
+        if (table == NULL || !setHuffTable(env, huff_ptr, table)) {
+            return 0;
+        }
         huff_ptr->sent_table = !write;
     }
     hlen = (*env)->GetArrayLength(env, ACHuffmanTables);
@@ -835,7 +853,9 @@
             huff_ptr = comp->ac_huff_tbl_ptrs[i];
         }
         table = (*env)->GetObjectArrayElement(env, ACHuffmanTables, i);
-        setHuffTable(env, huff_ptr, table);
+        if(table == NULL || !setHuffTable(env, huff_ptr, table)) {
+            return 0;
+        }
         huff_ptr->sent_table = !write;
     }
     return hlen;
@@ -1031,6 +1051,7 @@
         if (!GET_ARRAYS(env, data, &(src->next_input_byte))) {
             cinfo->err->error_exit((j_common_ptr) cinfo);
         }
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         return;
     }
 
@@ -1409,57 +1430,61 @@
      jclass qTableClass,
      jclass huffClass) {
 
-    JPEGImageReader_readInputDataID = (*env)->GetMethodID(env,
+    CHECK_NULL(JPEGImageReader_readInputDataID = (*env)->GetMethodID(env,
                                                   cls,
                                                   "readInputData",
-                                                  "([BII)I");
-    JPEGImageReader_skipInputBytesID = (*env)->GetMethodID(env,
+                                                  "([BII)I"));
+    CHECK_NULL(JPEGImageReader_skipInputBytesID = (*env)->GetMethodID(env,
                                                        cls,
                                                        "skipInputBytes",
-                                                       "(J)J");
-    JPEGImageReader_warningOccurredID = (*env)->GetMethodID(env,
+                                                       "(J)J"));
+    CHECK_NULL(JPEGImageReader_warningOccurredID = (*env)->GetMethodID(env,
                                                             cls,
                                                             "warningOccurred",
-                                                            "(I)V");
-    JPEGImageReader_warningWithMessageID =
+                                                            "(I)V"));
+    CHECK_NULL(JPEGImageReader_warningWithMessageID =
         (*env)->GetMethodID(env,
                             cls,
                             "warningWithMessage",
-                            "(Ljava/lang/String;)V");
-    JPEGImageReader_setImageDataID = (*env)->GetMethodID(env,
+                            "(Ljava/lang/String;)V"));
+    CHECK_NULL(JPEGImageReader_setImageDataID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "setImageData",
-                                                         "(IIIII[B)V");
-    JPEGImageReader_acceptPixelsID = (*env)->GetMethodID(env,
+                                                         "(IIIII[B)V"));
+    CHECK_NULL(JPEGImageReader_acceptPixelsID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "acceptPixels",
-                                                         "(IZ)V");
-    JPEGImageReader_passStartedID = (*env)->GetMethodID(env,
+                                                         "(IZ)V"));
+    CHECK_NULL(JPEGImageReader_passStartedID = (*env)->GetMethodID(env,
                                                         cls,
                                                         "passStarted",
-                                                        "(I)V");
-    JPEGImageReader_passCompleteID = (*env)->GetMethodID(env,
+                                                        "(I)V"));
+    CHECK_NULL(JPEGImageReader_passCompleteID = (*env)->GetMethodID(env,
                                                          cls,
                                                          "passComplete",
-                                                         "()V");
-    JPEGImageReader_pushBackID = (*env)->GetMethodID(env,
+                                                         "()V"));
+    CHECK_NULL(JPEGImageReader_pushBackID = (*env)->GetMethodID(env,
                                                      cls,
                                                      "pushBack",
-                                                     "(I)V");
-    JPEGQTable_tableID = (*env)->GetFieldID(env,
+                                                     "(I)V"));
+    CHECK_NULL(JPEGImageReader_skipPastImageID = (*env)->GetMethodID(env,
+                                                     cls,
+                                                     "skipPastImage",
+                                                     "(I)V"));
+    CHECK_NULL(JPEGQTable_tableID = (*env)->GetFieldID(env,
                                             qTableClass,
                                             "qTable",
-                                            "[I");
-
-    JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
+                                            "[I"));
+
+    CHECK_NULL(JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "lengths",
-                                                    "[S");
-
-    JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
+                                                    "[S"));
+
+    CHECK_NULL(JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "values",
-                                                    "[S");
+                                                    "[S"));
 }
 
 JNIEXPORT jlong JNICALL
@@ -1540,9 +1565,9 @@
     /* set up the association to persist for future calls */
     ret = initImageioData(env, (j_common_ptr) cinfo, this);
     if (ret == NULL) {
-        JNU_ThrowByName( env,
-                         "java/lang/OutOfMemoryError",
-                         "Initializing Reader");
+        (*env)->ExceptionClear(env);
+        JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
+                        "Initializing Reader");
         imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
@@ -1637,6 +1662,7 @@
 #endif
 
     if (GET_ARRAYS(env, data, &src->next_input_byte) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -1781,9 +1807,14 @@
                                cinfo->out_color_space,
                                cinfo->num_components,
                                profileData);
+        if ((*env)->ExceptionOccurred(env)
+            || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+            cinfo->err->error_exit((j_common_ptr) cinfo);
+        }
         if (reset) {
             jpeg_abort_decompress(cinfo);
         }
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
     }
 
     return retval;
@@ -1817,6 +1848,7 @@
 Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
     (JNIEnv *env,
      jobject this,
+     jint imageIndex,
      jlong ptr,
      jbyteArray buffer,
      jint numBands,
@@ -1900,6 +1932,7 @@
 
     body = (*env)->GetIntArrayElements(env, srcBands, NULL);
     if (body == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Read");
@@ -1958,6 +1991,7 @@
     }
 
     if (GET_ARRAYS(env, data, &src->next_input_byte) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -1992,6 +2026,7 @@
     jpeg_start_decompress(cinfo);
 
     if (numBands !=  cinfo->output_components) {
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         JNU_ThrowByName(env, "javax/imageio/IIOException",
                         "Invalid argument to native readImage");
         return data->abortFlag;
@@ -2000,6 +2035,7 @@
     if (cinfo->output_components <= 0 ||
         cinfo->image_width > (0xffffffffu / (unsigned int)cinfo->output_components))
     {
+        RELEASE_ARRAYS(env, data, src->next_input_byte);
         JNU_ThrowByName(env, "javax/imageio/IIOException",
                         "Invalid number of output components");
         return data->abortFlag;
@@ -2023,15 +2059,24 @@
             // the first interesting pass.
             jpeg_start_output(cinfo, cinfo->input_scan_number);
             if (wantUpdates) {
+                RELEASE_ARRAYS(env, data, src->next_input_byte);
                 (*env)->CallVoidMethod(env, this,
                                        JPEGImageReader_passStartedID,
                                        cinfo->input_scan_number-1);
+                if ((*env)->ExceptionOccurred(env)
+                    || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                    cinfo->err->error_exit((j_common_ptr) cinfo);
+                }
             }
         } else if (wantUpdates) {
+            RELEASE_ARRAYS(env, data, src->next_input_byte);
             (*env)->CallVoidMethod(env, this,
                                    JPEGImageReader_passStartedID,
                                    0);
-
+            if ((*env)->ExceptionOccurred(env)
+                || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                cinfo->err->error_exit((j_common_ptr) cinfo);
+            }
         }
 
         // Skip until the first interesting line
@@ -2119,8 +2164,13 @@
             done = TRUE;
         }
         if (wantUpdates) {
+            RELEASE_ARRAYS(env, data, src->next_input_byte);
             (*env)->CallVoidMethod(env, this,
                                    JPEGImageReader_passCompleteID);
+            if ((*env)->ExceptionOccurred(env)
+                || !GET_ARRAYS(env, data, &(src->next_input_byte))) {
+                cinfo->err->error_exit((j_common_ptr) cinfo);
+            }
         }
 
     }
@@ -2128,12 +2178,23 @@
      * We are done, but we might not have read all the lines, or all
      * the passes, so use jpeg_abort instead of jpeg_finish_decompress.
      */
-    if (cinfo->output_scanline == cinfo->output_height) {
-        //    if ((cinfo->output_scanline == cinfo->output_height) &&
-        //(jpeg_input_complete(cinfo))) {  // We read the whole file
+    if ((cinfo->output_scanline != cinfo->output_height) ||
+        data->abortFlag == JNI_TRUE)
+     {
+        jpeg_abort_decompress(cinfo);
+     } else if ((!jpeg_input_complete(cinfo)) &&
+                (progressive &&
+                 (cinfo->input_scan_number > maxProgressivePass))) {
+        /* We haven't reached EOI, but we need to skip to there */
+        (*cinfo->src->term_source) (cinfo);
+        /* We can use jpeg_abort to release memory and reset global_state */
+        jpeg_abort((j_common_ptr) cinfo);
+        (*env)->CallVoidMethod(env,
+                               this,
+                               JPEGImageReader_skipPastImageID,
+                               imageIndex);
+    } else {
         jpeg_finish_decompress(cinfo);
-    } else {
-        jpeg_abort_decompress(cinfo);
     }
 
     free(scanLinePtr);
@@ -2403,44 +2464,39 @@
      jclass qTableClass,
      jclass huffClass) {
 
-    JPEGImageWriter_writeOutputDataID = (*env)->GetMethodID(env,
+    CHECK_NULL(JPEGImageWriter_writeOutputDataID = (*env)->GetMethodID(env,
                                                     cls,
                                                     "writeOutputData",
-                                                    "([BII)V");
-
-    JPEGImageWriter_warningOccurredID = (*env)->GetMethodID(env,
+                                                    "([BII)V"));
+    CHECK_NULL(JPEGImageWriter_warningOccurredID = (*env)->GetMethodID(env,
                                                             cls,
                                                             "warningOccurred",
-                                                            "(I)V");
-    JPEGImageWriter_warningWithMessageID =
-        (*env)->GetMethodID(env,
-                            cls,
-                            "warningWithMessage",
-                            "(Ljava/lang/String;)V");
-
-    JPEGImageWriter_writeMetadataID = (*env)->GetMethodID(env,
+                                                            "(I)V"));
+    CHECK_NULL(JPEGImageWriter_warningWithMessageID =
+                                        (*env)->GetMethodID(env,
+                                                            cls,
+                                                            "warningWithMessage",
+                                                            "(Ljava/lang/String;)V"));
+    CHECK_NULL(JPEGImageWriter_writeMetadataID = (*env)->GetMethodID(env,
                                                           cls,
                                                           "writeMetadata",
-                                                          "()V");
-    JPEGImageWriter_grabPixelsID = (*env)->GetMethodID(env,
+                                                          "()V"));
+    CHECK_NULL(JPEGImageWriter_grabPixelsID = (*env)->GetMethodID(env,
                                                        cls,
                                                        "grabPixels",
-                                                       "(I)V");
-
-    JPEGQTable_tableID = (*env)->GetFieldID(env,
+                                                       "(I)V"));
+    CHECK_NULL(JPEGQTable_tableID = (*env)->GetFieldID(env,
                                             qTableClass,
                                             "qTable",
-                                            "[I");
-
-    JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
+                                            "[I"));
+    CHECK_NULL(JPEGHuffmanTable_lengthsID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "lengths",
-                                                    "[S");
-
-    JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
+                                                    "[S"));
+    CHECK_NULL(JPEGHuffmanTable_valuesID = (*env)->GetFieldID(env,
                                                     huffClass,
                                                     "values",
-                                                    "[S");
+                                                    "[S"));
 }
 
 JNIEXPORT jlong JNICALL
@@ -2516,6 +2572,7 @@
     /* set up the association to persist for future calls */
     ret = initImageioData(env, (j_common_ptr) cinfo, this);
     if (ret == NULL) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Writer");
@@ -2593,6 +2650,7 @@
 
     if (GET_ARRAYS(env, data,
                    (const JOCTET **)(&dest->next_output_byte)) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -2664,6 +2722,7 @@
     imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
     UINT8** scale = NULL;
+    boolean success = TRUE;
 
 
     /* verify the inputs */
@@ -2708,13 +2767,14 @@
     }
 
     bandSize = (*env)->GetIntArrayElements(env, bandSizes, NULL);
+    CHECK_NULL_RETURN(bandSize, JNI_FALSE);
 
     for (i = 0; i < numBands; i++) {
         if (bandSize[i] <= 0 || bandSize[i] > JPEG_BAND_SIZE) {
             (*env)->ReleaseIntArrayElements(env, bandSizes,
                                             bandSize, JNI_ABORT);
             JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid Image");
-            return JNI_FALSE;;
+            return JNI_FALSE;
         }
     }
 
@@ -2820,30 +2880,30 @@
     vfactors = (*env)->GetIntArrayElements(env, VsamplingFactors, NULL);
     qsels = (*env)->GetIntArrayElements(env, QtableSelectors, NULL);
 
-    if ((ids == NULL) ||
-        (hfactors == NULL) || (vfactors == NULL) ||
-        (qsels == NULL)) {
-        JNU_ThrowByName( env,
-                         "java/lang/OutOfMemoryError",
-                         "Writing JPEG");
-        return JNI_FALSE;
+    if (ids && hfactors && vfactors && qsels) {
+        for (i = 0; i < numBands; i++) {
+            cinfo->comp_info[i].component_id = ids[i];
+            cinfo->comp_info[i].h_samp_factor = hfactors[i];
+            cinfo->comp_info[i].v_samp_factor = vfactors[i];
+            cinfo->comp_info[i].quant_tbl_no = qsels[i];
+        }
+    } else {
+        success = FALSE;
     }
 
-    for (i = 0; i < numBands; i++) {
-        cinfo->comp_info[i].component_id = ids[i];
-        cinfo->comp_info[i].h_samp_factor = hfactors[i];
-        cinfo->comp_info[i].v_samp_factor = vfactors[i];
-        cinfo->comp_info[i].quant_tbl_no = qsels[i];
+    if (ids) {
+        (*env)->ReleaseIntArrayElements(env, componentIds, ids, JNI_ABORT);
     }
-
-    (*env)->ReleaseIntArrayElements(env, componentIds,
-                                    ids, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, HsamplingFactors,
-                                    hfactors, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, VsamplingFactors,
-                                    vfactors, JNI_ABORT);
-    (*env)->ReleaseIntArrayElements(env, QtableSelectors,
-                                    qsels, JNI_ABORT);
+    if (hfactors) {
+        (*env)->ReleaseIntArrayElements(env, HsamplingFactors, hfactors, JNI_ABORT);
+    }
+    if (vfactors) {
+        (*env)->ReleaseIntArrayElements(env, VsamplingFactors, vfactors, JNI_ABORT);
+    }
+    if (qsels) {
+        (*env)->ReleaseIntArrayElements(env, QtableSelectors, qsels, JNI_ABORT);
+    }
+    if (!success) return data->abortFlag;
 
     jpeg_suppress_tables(cinfo, TRUE);  // Disable writing any current
 
@@ -2860,6 +2920,7 @@
 
     if (GET_ARRAYS(env, data,
                    (const JOCTET **)(&dest->next_output_byte)) == NOT_OK) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowByName(env,
                         "javax/imageio/IIOException",
                         "Array pin failed");
@@ -2894,6 +2955,7 @@
             cinfo->scan_info = cinfo->script_space;
             scanptr = (int *) cinfo->script_space;
             scanData = (*env)->GetIntArrayElements(env, scanInfo, NULL);
+            CHECK_NULL_RETURN(scanData, data->abortFlag);
             // number of jints per scan is 9
             // We avoid a memcpy to handle different size ints
             for (i = 0; i < numScans*9; i++) {
--- a/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Thu Sep 07 23:37:21 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -467,14 +467,14 @@
 Java_sun_awt_image_JPEGImageDecoder_initIDs(JNIEnv *env, jclass cls,
                                             jclass InputStreamClass)
 {
-    sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo",
-                                           "(IIZZZ)Z");
-    sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z");
-    sendPixelsIntID = (*env)->GetMethodID(env, cls, "sendPixels", "([II)Z");
-    InputStream_readID = (*env)->GetMethodID(env, InputStreamClass,
-                                             "read", "([BII)I");
-    InputStream_availableID = (*env)->GetMethodID(env, InputStreamClass,
-                                                  "available", "()I");
+    CHECK_NULL(sendHeaderInfoID = (*env)->GetMethodID(env, cls, "sendHeaderInfo",
+                                           "(IIZZZ)Z"));
+    CHECK_NULL(sendPixelsByteID = (*env)->GetMethodID(env, cls, "sendPixels", "([BI)Z"));
+    CHECK_NULL(sendPixelsIntID = (*env)->GetMethodID(env, cls, "sendPixels", "([II)Z"));
+    CHECK_NULL(InputStream_readID = (*env)->GetMethodID(env, InputStreamClass,
+                                             "read", "([BII)I"));
+    CHECK_NULL(InputStream_availableID = (*env)->GetMethodID(env, InputStreamClass,
+                                                  "available", "()I"));
 }
 
 
--- a/src/share/native/sun/awt/libpng/CHANGES	Sun May 28 23:44:03 2017 -0700
+++ b/src/share/native/sun/awt/libpng/CHANGES	Thu Sep 07 23:37:21 2017 -0700
@@ -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
@@ -5088,7 +5063,8 @@
 Version 1.6.15beta05 [November 5, 2014]
   Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
     example.c, pngtest.c, and applications in the contrib directory.
-  Avoid out-of-bounds memory access in png_user_version_check().
+  Fixed an out-of-range read in png_user_version_check() (Bug report from
+    Qixue Xiao, CVE-2015-8540).
   Simplified and future-proofed png_user_version_check().
   Fixed GCC unsigned int->float warnings. Various versions of GCC
     seem to generate warnings when an unsigned value is implicitly
@@ -5446,7 +5422,7 @@
 Version 1.6.20beta02 [November 23, 2015]
   Fixed incorrect implementation of png_set_PLTE() that uses png_ptr
     not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126
-    vulnerability.
+    vulnerability.  Fixes CVE-2015-8472.
 
 Version 1.6.20beta03 [November 24, 2015]
   Backported tests from libpng-1.7.0beta69.
@@ -5471,6 +5447,353 @@
 Version 1.6.20 [December 3, 2015]
   No changes.
 
+Version 1.6.21beta01 [December 11, 2015]
+  Fixed syntax "$(command)" in tests/pngstest that some shells other than
+    bash could not parse (Bug report by Nelson Beebe). Use `command` instead.
+
+Version 1.6.21beta02 [December 14, 2015]
+  Moved png_check_keyword() from pngwutil.c to pngset.c
+  Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
+    in the BigEndian tests by not testing it, making the BE code the same 
+    as the LE version.
+  Fixes to pngvalid for various reduced build configurations (eliminate unused
+    statics) and a fix for the case in rgb_to_gray when the digitize option
+    reduces graylo to 0, producing a large error.
+
+Version 1.6.21beta03 [December 18, 2015]
+  Widened the 'limit' check on the internally calculated error limits in
+    the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error
+    checks) and changed the check to only operate in non-release builds
+    (base build type not RC or RELEASE.)
+  Fixed undefined behavior in pngvalid.c, undefined because
+    (png_byte) << shift is undefined if it changes the signed bit
+    (because png_byte is promoted to int). The libpng exported functions
+    png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by
+    David Drysdale as a result of reports from UBSAN in clang 3.8).
+  This changes pngvalid to use BE random numbers; this used to produce
+    errors but these should not be fixed as a result of the previous changes.
+
+Version 1.6.21rc01 [January 4, 2016]
+  In projects/vstudio, combined readme.txt and WARNING into README.txt
+
+Version 1.6.21rc02 [January 7, 2016]
+  Relocated assert() in contrib/tools/pngfix.c, bug found by American
+    Fuzzy Lop, reported by Brian Carpenter.
+  Marked 'limit' UNUSED in transform_range_check().  This only affects
+    release builds.
+
+Version 1.6.21 [January 15, 2016]
+  Worked around a false-positive Coverity issue in pngvalid.c.
+
+Version 1.6.22beta01 [January 23, 2016]
+  Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
+    "tmpfile()" implementation in contrib/libtests/pngstest.c
+  Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
+    if there is no stdio.h support.
+  Added a png_image_write_to_memory() API and a number of assist macros
+    to allow an application that uses the simplified API write to bypass
+    stdio and write directly to memory.
+  Added some warnings (png.h) and some check code to detect *possible*
+    overflow in the ROW_STRIDE and simplified image SIZE macros.  This
+    disallows image width/height/format that *might* overflow.  This is
+    a quiet API change that limits in-memory image size (uncompressed) to
+    less than 4GByte and image row size (stride) to less than 2GByte.
+  Revised workaround for false-positive Coverity issue in pngvalid.c.
+
+Version 1.6.22beta02 [February 8, 2016]
+  Only use exit(77) in configure builds.
+  Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported
+    the palette size because it failed to take into account that the memory
+    palette has to be expanded to full RGB when it is written to PNG.
+  Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
+    and test.cmake.in (Roger Leigh).
+  Relaxed limit checks on gamma values in pngrtran.c. As suggested in
+    the comments gamma values outside the range currently permitted
+    by png_set_alpha_mode are useful for HDR data encoding.  These values
+    are already permitted by png_set_gamma so it is reasonable caution to
+    extend the png_set_alpha_mode range as HDR imaging systems are starting
+    to emerge.
+
+Version 1.6.22beta03 [March 9, 2016]
+  Added a common-law trademark notice and export control information
+    to the LICENSE file, png.h, and the man page.
+  Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
+    were accidentally removed from libpng-1.6.17. 
+  Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
+    (Robert C. Seacord).
+  Removed dubious "#if INT_MAX" test from png.h that was added to
+    libpng-1.6.19beta02 (John Bowler).
+  Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok).
+  Updated LICENSE to say files in the contrib directory are not
+    necessarily under the libpng license, and that some makefiles have
+    other copyright owners.
+  Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.).
+  Made contrib/libtests/timepng more robust.  The code no longer gives
+    up/fails on invalid PNG data, it just skips it (with error messages).
+    The code no longer fails on PNG files with data beyond IEND.  Options
+    exist to use png_read_png (reading the whole image, not by row) and, in
+    that case, to apply any of the supported transforms.  This makes for
+    more realistic testing; the decoded data actually gets used in a
+    meaningful fashion (John Bowler).
+  Fixed some misleading indentation (Krishnaraj Bhat).
+
+Version 1.6.22beta04 [April 5, 2016]
+  Force GCC compilation to C89 if needed (Dagobert Michelsen).
+  SSE filter speed improvements for bpp=3:
+    memcpy-free implementations of load3() / store3().
+    call load3() only when needed at the end of a scanline.
+
+Version 1.6.22beta05 [April 27, 2016]
+  Added PNG_FAST_FILTERS macro (defined as
+    PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
+  Various fixes for contrib/libtests/timepng.c
+  Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch.
+  Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
+    (Bug report by Y.Ohashik).
+
+Version 1.6.22beta06 [May 5, 2016]
+  Rebased contrib/intel_sse.patch.
+  Quieted two Coverity issues in contrib/libtests/timepng.c.
+  Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok):
+    Added support to use multiple directories in ZLIBINCDIR variable,
+    Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC,
+    Fixed pnglibconf.c compilation on OS X including the sysroot path.
+
+Version 1.6.22rc01 [May 14, 2016]
+  No changes.
+
+Version 1.6.22rc02 [May 16, 2016]
+  Removed contrib/timepng from default build; it does not build on platforms
+    that don't supply clock_gettime().
+
+Version 1.6.22rc03 [May 17, 2016]
+  Restored contrib/timepng to default build but check for the presence
+    of clock_gettime() in configure.ac and Makefile.am.
+
+Version 1.6.22 [May 26, 2016]
+  No changes.
+
+Version 1.6.23beta01 [May 29, 2016]