changeset 12287:f7a7f85c9513

Merge
author asaha
date Tue, 04 Apr 2017 11:57:35 -0700
parents 80280d8b40e9 0807dc9e47d6
children 824988d089dd
files .hgtags src/macosx/classes/sun/lwawt/LWWindowPeer.java src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java src/macosx/native/sun/awt/AWTWindow.m src/share/classes/sun/awt/AWTAccessor.java src/share/classes/sun/net/ftp/impl/FtpClient.java src/share/lib/security/java.security-aix src/share/lib/security/java.security-linux src/share/lib/security/java.security-macosx src/share/lib/security/java.security-solaris src/share/lib/security/java.security-windows src/windows/native/java/lang/java_props_md.c src/windows/native/sun/windows/awt_Component.cpp test/sun/security/tools/jarsigner/TimestampCheck.java
diffstat 66 files changed, 2537 insertions(+), 500 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Mar 27 08:22:23 2017 -0700
+++ b/.hgtags	Tue Apr 04 11:57:35 2017 -0700
@@ -678,6 +678,18 @@
 ec72a941be0a50ab77f5375cf710bc06e4f118d3 jdk8u121-b11
 9561afc12df843ef21ecd9d7b3633371e7a2bfc4 jdk8u121-b12
 2974746e56192cdd14fc2dd43179bcf28e4faf4a jdk8u121-b13
+032874d46bf95478cb86690b3c91d335c0764b0b jdk8u131-b00
+bea5b22daf5ddd941f3bcbf7a4e5fc5244ceb788 jdk8u131-b01
+a01d217a232906e82f80e5bc3db4d60c4c74716e jdk8u131-b02
+3d2dfed2b420a59c68e5deedd257eb630f88b3da jdk8u131-b03
+0f7d02f565658a89b073ee77c296f33148c50da3 jdk8u131-b04
+af0e709d28f9124dd2c37069e0bf4c0751248c61 jdk8u131-b05
+3c7f99282d1b5e29f7466bf25fb6878bfebfc58a jdk8u131-b06
+f5d0aadb4d1ca74eda4e98cc0030f1618ef4c870 jdk8u131-b07
+6e362e6002abc39c63fc8ab4bcebf08e273f5a94 jdk8u131-b08
+40d00399869d8a28cfecf360234f340e9e0ad3b1 jdk8u131-b09
+c0091a673d766ce2e76a945bab6de325fe78dd88 jdk8u131-b10
+3ab471c4760a808e39406303ff33a25a542b9c75 jdk8u131-b11
 1442bc728814af451e2dd1a6719a64485d27e3a0 jdk8u122-b00
 f6030acfa5aec0e64d45adfac69b9e7e5c12bc74 jdk8u122-b01
 6b072c3a6db7ab06804c91aab77431799dfb5d47 jdk8u122-b02
--- a/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/com/apple/eawt/_AppDockIconHandler.java	Tue Apr 04 11:57:35 2017 -0700
@@ -72,8 +72,7 @@
     public void setDockIconImage(final Image image) {
         try {
             final CImage cImage = getCImageCreator().createFromImage(image);
-            final long nsImagePtr = getNSImagePtrFrom(cImage);
-            nativeSetDockIconImage(nsImagePtr);
+            cImage.execute(_AppDockIconHandler::nativeSetDockIconImage);
         } catch (final Throwable e) {
             throw new RuntimeException(e);
         }
@@ -102,16 +101,4 @@
             throw new RuntimeException(e);
         }
     }
-
-    static long getNSImagePtrFrom(final CImage cImage) {
-        if (cImage == null) return 0;
-
-        try {
-            final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
-            cImagePtrField.setAccessible(true);
-            return cImagePtrField.getLong(cImage);
-        } catch (final Throwable e) {
-            throw new RuntimeException(e);
-        }
-    }
 }
--- a/src/macosx/classes/com/apple/laf/resources/aqua_de.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/com/apple/laf/resources/aqua_de.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 FileChooser.openButton.textAndMnemonic=\u00D6ffnen
 FileChooser.saveDialogTitle.textAndMnemonic=Speichern
 FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen
-FileChooser.updateButton.textAndMnemonic=Updaten
+FileChooser.updateButton.textAndMnemonic=Aktualisieren
 FileChooser.helpButton.textAndMnemonic=Hilfe
 FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen
 
--- a/src/macosx/classes/sun/java2d/opengl/CGLLayer.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/java2d/opengl/CGLLayer.java	Tue Apr 04 11:57:35 2017 -0700
@@ -108,7 +108,7 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            validate(getPointer(), cglsd);
+            execute(ptr -> validate(ptr, cglsd));
         } finally {
             rq.unlock();
         }
@@ -124,7 +124,7 @@
     private void setScale(final int _scale) {
         if (scale != _scale) {
             scale = _scale;
-            nativeSetScale(getPointer(), scale);
+            execute(ptr -> nativeSetScale(ptr, scale));
         }
     }
 
@@ -138,7 +138,7 @@
         OGLRenderQueue rq = OGLRenderQueue.getInstance();
         rq.lock();
         try {
-            blitTexture(getPointer());
+            execute(ptr -> blitTexture(ptr));
         } finally {
             rq.unlock();
         }
--- a/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
 
 package sun.lwawt.macosx;
 
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
 /**
  * Safely holds and disposes of native AppKit resources, using the
  * correct AppKit threading and Objective-C GC semantics.
@@ -36,6 +40,10 @@
     // TODO this pointer should be private and accessed via CFNativeAction class
     protected volatile long ptr;
 
+    private final ReadWriteLock lock = new ReentrantReadWriteLock();
+    private final Lock writeLock = lock.writeLock();
+    private final Lock readLock = lock.readLock();
+
     /**
      * @param ptr CFRetained native object pointer
      * @param disposeOnAppKitThread is the object needs to be CFReleased on the main thread
@@ -50,21 +58,31 @@
      * @param ptr CFRetained native object pointer
      */
     protected void setPtr(final long ptr) {
-        synchronized (this) {
-            if (this.ptr != 0) dispose();
+        writeLock.lock();
+        try {
+            if (this.ptr != 0) {
+                dispose();
+            }
             this.ptr = ptr;
+        } finally {
+            writeLock.unlock();
         }
     }
 
     /**
-     * Manually CFReleases the native resource
+     * Manually CFReleases the native resource.
      */
     protected void dispose() {
         long oldPtr = 0L;
-        synchronized (this) {
-            if (ptr == 0) return;
+        writeLock.lock();
+        try {
+            if (ptr == 0) {
+                return;
+            }
             oldPtr = ptr;
             ptr = 0;
+        } finally {
+            writeLock.unlock();
         }
 
         nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block
@@ -109,9 +127,14 @@
      *
      * @param  action The native operation
      */
-    public final synchronized void execute(final CFNativeAction action) {
-        if (ptr != 0) {
-            action.run(ptr);
+    public final void execute(final CFNativeAction action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
     }
 
@@ -127,9 +150,14 @@
      * @return result of the native operation, usually the native pointer to
      *         some other data
      */
-    final synchronized long executeGet(final CFNativeActionGet action) {
-        if (ptr != 0) {
-            return action.run(ptr);
+    final long executeGet(final CFNativeActionGet action) {
+        readLock.lock();
+        try {
+            if (ptr != 0) {
+                return action.run(ptr);
+            }
+        } finally {
+            readLock.unlock();
         }
         return 0;
     }
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import java.util.List;
 import sun.awt.image.MultiResolutionImage;
 import sun.awt.image.MultiResolutionCachedImage;
+import java.util.concurrent.atomic.AtomicReference;
 
 import sun.awt.image.SunWritableRaster;
 
@@ -235,15 +236,26 @@
 
     /** @return A MultiResolution image created from nsImagePtr, or null. */
     private Image toImage() {
-        if (ptr == 0) return null;
+        if (ptr == 0) {
+            return null;
+        }
 
-        final Dimension2D size = nativeGetNSImageSize(ptr);
+        AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
+        execute(ptr -> {
+            sizeRef.set(nativeGetNSImageSize(ptr));
+        });
+        final Dimension2D size = sizeRef.get();
+        if (size == null) {
+            return null;
+        }
         final int w = (int)size.getWidth();
         final int h = (int)size.getHeight();
-
-        Dimension2D[] sizes
-                = nativeGetNSImageRepresentationSizes(ptr,
-                        size.getWidth(), size.getHeight());
+        AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
+        execute(ptr -> {
+            repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
+                                                           size.getHeight()));
+        });
+        Dimension2D[] sizes = repRef.get();
 
         return sizes == null || sizes.length < 2 ?
                 new MultiResolutionCachedImage(w, h, (width, height)
@@ -256,18 +268,18 @@
         final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
         final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
         final int[] buffer = SunWritableRaster.stealData(dbi, 0);
-        nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
+        execute(ptr->nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight));
         SunWritableRaster.markDirty(dbi);
         return bimg;
     }
 
     /** If nsImagePtr != 0 then scale this NSImage. @return *this* */
     CImage resize(final double w, final double h) {
-        if (ptr != 0) nativeSetNSImageSize(ptr, w, h);
+        execute(ptr -> nativeSetNSImageSize(ptr, w, h));
         return this;
     }
 
     void resizeRepresentations(double w, double h) {
-        if (ptr != 0) nativeResizeNSImageRepresentations(ptr, w, h);
+        execute(ptr -> nativeResizeNSImageRepresentations(ptr, w, h));
     }
 }
--- a/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CMenuItem.java	Tue Apr 04 11:57:35 2017 -0700
@@ -113,7 +113,13 @@
      */
     public final void setImage(final java.awt.Image img) {
         CImage cimg = CImage.getCreator().createFromImage(img);
-        execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr));
+        execute(ptr -> {
+            if (cimg == null) {
+                nativeSetImage(ptr, 0L);
+            } else {
+                cimg.execute(imgPtr -> nativeSetImage(ptr, imgPtr));
+            }
+        });
     }
 
     /**
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,9 @@
         super(0, true);
     }
 
+    /**
+     * Used by JAWT.
+     */
     public long getPointer() {
         return ptr;
     }
@@ -61,7 +64,7 @@
         // translates values from the coordinate system of the top-level window
         // to the coordinate system of the content view
         final Insets insets = platformWindow.getPeer().getInsets();
-        nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
+        execute(ptr->nativeSetBounds(ptr, x - insets.left, y - insets.top, w, h));
     }
 
     @Override
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java	Tue Apr 04 11:57:35 2017 -0700
@@ -108,11 +108,6 @@
     }
 
     @Override
-    public long getNSWindowPtr() {
-        return 0;
-    }
-
-    @Override
     public SurfaceData getSurfaceData() {
         return null;
     }
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,9 @@
 
 import java.awt.*;
 import java.awt.geom.Rectangle2D;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsEnvironment;
@@ -83,7 +86,7 @@
      * Cocoa coordinates).
      */
     public void setBounds(int x, int y, int width, int height) {
-        CWrapper.NSView.setFrame(ptr, x, y, width, height);
+        execute(ptr->CWrapper.NSView.setFrame(ptr, x, y, width, height));
     }
 
     // REMIND: CGLSurfaceData expects top-level's size
@@ -96,7 +99,7 @@
     }
 
     public void setToolTip(String msg) {
-        CWrapper.NSView.setToolTip(ptr, msg);
+        execute(ptr -> CWrapper.NSView.setToolTip(ptr, msg));
     }
 
     // ----------------------------------------------------------------------
@@ -147,18 +150,25 @@
     }
 
     public void setAutoResizable(boolean toResize) {
-        nativeSetAutoResizable(this.getAWTView(), toResize);
+        execute(ptr -> nativeSetAutoResizable(ptr, toResize));
     }
 
     public boolean isUnderMouse() {
-        return nativeIsViewUnderMouse(getAWTView());
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(nativeIsViewUnderMouse(ptr));
+        });
+        return ref.get();
     }
 
     public GraphicsDevice getGraphicsDevice() {
         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
         CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
-        int displayID = nativeGetNSViewDisplayID(getAWTView());
-        GraphicsDevice gd = cge.getScreenDevice(displayID);
+        AtomicInteger ref = new AtomicInteger();
+        execute(ptr -> {
+            ref.set(nativeGetNSViewDisplayID(ptr));
+        });
+        GraphicsDevice gd = cge.getScreenDevice(ref.get());
         if (gd == null) {
             // this could possibly happen during device removal
             // use the default screen device in this case
@@ -168,8 +178,15 @@
     }
 
     public Point getLocationOnScreen() {
-        Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
-        return new Point(r.x, r.y);
+        AtomicReference<Rectangle> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetLocationOnScreen(ptr).getBounds());
+        });
+        Rectangle r = ref.get();
+        if (r != null) {
+            return new Point(r.x, r.y);
+        }
+        return new Point(0, 0);
     }
 
     // ----------------------------------------------------------------------
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,9 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.List;
 import java.util.Objects;
 
@@ -183,16 +186,16 @@
             c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
         }},
         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
+            c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
         }},
         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
             if (value == null || !(value instanceof java.io.File)) {
-                nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
+                c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null));
                 return;
             }
 
             final String filename = ((java.io.File)value).getAbsolutePath();
-            nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
+            c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
         }}
     }) {
         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
@@ -239,7 +242,6 @@
         contentView = createContentView();
         contentView.initialize(peer, responder);
 
-        final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
         Rectangle bounds;
         if (!IS(DECORATED, styleBits)) {
             // For undecorated frames the move/resize event does not come if the frame is centered on the screen
@@ -248,9 +250,21 @@
         } else {
             bounds = _peer.constrainBounds(_target.getBounds());
         }
-        final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(),
-                ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height);
-        setPtr(nativeWindowPtr);
+        AtomicLong ref = new AtomicLong();
+        contentView.execute(viewPtr -> {
+            if (owner != null) {
+                owner.execute(ownerPtr -> {
+                    ref.set(nativeCreateNSWindow(viewPtr, ownerPtr, styleBits,
+                                                 bounds.x, bounds.y,
+                                                 bounds.width, bounds.height));
+                });
+            } else {
+                ref.set(nativeCreateNSWindow(viewPtr, 0,
+                                             styleBits, bounds.x, bounds.y,
+                                             bounds.width, bounds.height));
+            }
+        });
+        setPtr(ref.get());
 
         if (target instanceof javax.swing.RootPaneContainer) {
             final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
@@ -412,30 +426,31 @@
 
     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
     private void setStyleBits(final int mask, final boolean value) {
-        nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
+        execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
     }
 
     private native void _toggleFullScreenMode(final long model);
 
     public void toggleFullScreen() {
-        _toggleFullScreenMode(getNSWindowPtr());
+        execute(this::_toggleFullScreenMode);
     }
 
     @Override // PlatformWindow
     public void setMenuBar(MenuBar mb) {
-        final long nsWindowPtr = getNSWindowPtr();
         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
-        if (mbPeer != null) {
-            mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr));
-        } else {
-            nativeSetNSWindowMenuBar(nsWindowPtr, 0);
-        }
+        execute(nsWindowPtr->{
+            if (mbPeer != null) {
+                mbPeer.execute(ptr -> nativeSetNSWindowMenuBar(nsWindowPtr, ptr));
+            } else {
+                nativeSetNSWindowMenuBar(nsWindowPtr, 0);
+            }
+        });
     }
 
     @Override // PlatformWindow
     public void dispose() {
         contentView.dispose();
-        nativeDispose(getNSWindowPtr());
+        execute(CPlatformWindow::nativeDispose);
         CPlatformWindow.super.dispose();
     }
 
@@ -448,7 +463,11 @@
 
     @Override // PlatformWindow
     public Insets getInsets() {
-        return nativeGetNSWindowInsets(getNSWindowPtr());
+        AtomicReference<Insets> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetNSWindowInsets(ptr));
+        });
+        return ref.get() != null ? ref.get() : new Insets(0, 0, 0, 0);
     }
 
     @Override // PlatformWindow
@@ -475,12 +494,18 @@
     @Override // PlatformWindow
     public void setBounds(int x, int y, int w, int h) {
 //        assert CThreading.assertEventQueue();
-        nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h);
+        execute(ptr -> nativeSetNSWindowBounds(ptr, x, y, w, h));
     }
 
     private boolean isMaximized() {
-        return undecorated ? this.normalBounds != null
-                : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
+        if (undecorated) {
+            return this.normalBounds != null;
+        }
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(CWrapper.NSWindow.isZoomed(ptr));
+        });
+        return ref.get();
     }
 
     private void maximize() {
@@ -488,7 +513,7 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(CWrapper.NSWindow::zoom);
         } else {
             deliverZoom(true);
 
@@ -512,7 +537,7 @@
             return;
         }
         if (!undecorated) {
-            CWrapper.NSWindow.zoom(getNSWindowPtr());
+            execute(CWrapper.NSWindow::zoom);
         } else {
             deliverZoom(false);
 
@@ -528,8 +553,6 @@
 
     @Override // PlatformWindow
     public void setVisible(boolean visible) {
-        final long nsWindowPtr = getNSWindowPtr();
-
         // Configure stuff
         updateIconImages();
         updateFocusabilityForAutoRequestFocus(false);
@@ -541,30 +564,44 @@
         if (blocker == null || !visible) {
             // If it ain't blocked, or is being hidden, go regular way
             if (visible) {
-                CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());
+                contentView.execute(viewPtr -> {
+                    execute(ptr -> CWrapper.NSWindow.makeFirstResponder(ptr,
+                                                                        viewPtr));
+                });
 
                 boolean isPopup = (target.getType() == Window.Type.POPUP);
-                if (isPopup) {
-                    // Popups in applets don't activate applet's process
-                    CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-                } else {
-                    CWrapper.NSWindow.orderFront(nsWindowPtr);
-                }
+                execute(ptr -> {
+                    if (isPopup) {
+                        // Popups in applets don't activate applet's process
+                        CWrapper.NSWindow.orderFrontRegardless(ptr);
+                    } else {
+                        CWrapper.NSWindow.orderFront(ptr);
+                    }
 
-                boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
-                if (!isKeyWindow) {
-                    CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
-                }
+                    boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(ptr);
+                    if (!isKeyWindow) {
+                        CWrapper.NSWindow.makeKeyWindow(ptr);
+                    }
+                });
             } else {
-                // immediately hide the window
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
-                // process the close
-                CWrapper.NSWindow.close(nsWindowPtr);
+                execute(ptr->{
+                    // immediately hide the window
+                    CWrapper.NSWindow.orderOut(ptr);
+                    // process the close
+                    CWrapper.NSWindow.close(ptr);
+                });
             }
         } else {
             // otherwise, put it in a proper z-order
-            CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
-                    ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
+            CPlatformWindow bw
+                    = (CPlatformWindow) blocker.getPlatformWindow();
+            bw.execute(blockerPtr -> {
+                execute(ptr -> {
+                    CWrapper.NSWindow.orderWindow(ptr,
+                                                  CWrapper.NSWindow.NSWindowBelow,
+                                                  blockerPtr);
+                });
+            });
         }
         this.visible = visible;
 
@@ -583,7 +620,7 @@
                     }
                     switch (frameState) {
                         case Frame.ICONIFIED:
-                            CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                            execute(CWrapper.NSWindow::miniaturize);
                             break;
                         case Frame.MAXIMIZED_BOTH:
                             maximize();
@@ -605,7 +642,11 @@
         if (visible) {
             // Order myself above my parent
             if (owner != null && owner.isVisible()) {
-                CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
+                owner.execute(ownerPtr -> {
+                    execute(ptr -> {
+                        CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                    });
+                });
                 applyWindowLevel(target);
             }
 
@@ -615,7 +656,11 @@
                 if (p instanceof LWWindowPeer) {
                     CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
                     if (pw != null && pw.isVisible()) {
-                        CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr);
+                        pw.execute(childPtr -> {
+                            execute(ptr -> {
+                                CWrapper.NSWindow.orderWindow(childPtr, CWrapper.NSWindow.NSWindowAbove, ptr);
+                            });
+                        });
                         pw.applyWindowLevel(w);
                     }
                 }
@@ -631,25 +676,22 @@
 
     @Override // PlatformWindow
     public void setTitle(String title) {
-        nativeSetNSWindowTitle(getNSWindowPtr(), title);
+        execute(ptr -> nativeSetNSWindowTitle(ptr, title));
     }
 
     // Should be called on every window key property change.
     @Override // PlatformWindow
     public void updateIconImages() {
-        final long nsWindowPtr = getNSWindowPtr();
         final CImage cImage = getImageForTarget();
-        nativeSetNSWindowMinimizedIcon(nsWindowPtr, cImage == null ? 0L : cImage.ptr);
-    }
-
-    public long getNSWindowPtr() {
-        final long nsWindowPtr = ptr;
-        if (nsWindowPtr == 0L) {
-            if(logger.isLoggable(PlatformLogger.Level.FINE)) {
-                logger.fine("NSWindow already disposed?", new Exception("Pointer to native NSWindow is invalid."));
+        execute(ptr -> {
+            if (cImage == null) {
+                nativeSetNSWindowMinimizedIcon(ptr, 0L);
+            } else {
+                cImage.execute(imagePtr -> {
+                    nativeSetNSWindowMinimizedIcon(ptr, imagePtr);
+                });
             }
-        }
-        return nsWindowPtr;
+        });
     }
 
     public SurfaceData getSurfaceData() {
@@ -658,13 +700,11 @@
 
     @Override  // PlatformWindow
     public void toBack() {
-        final long nsWindowPtr = getNSWindowPtr();
-        nativePushNSWindowToBack(nsWindowPtr);
+        execute(CPlatformWindow::nativePushNSWindowToBack);
     }
 
     @Override  // PlatformWindow
     public void toFront() {
-        final long nsWindowPtr = getNSWindowPtr();
         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
         if( w != null && w.getPeer() != null
@@ -673,7 +713,7 @@
             lwcToolkit.activateApplicationIgnoringOtherApps();
         }
         updateFocusabilityForAutoRequestFocus(false);
-        nativePushNSWindowToFront(nsWindowPtr);
+        execute(CPlatformWindow::nativePushNSWindowToFront);
         updateFocusabilityForAutoRequestFocus(true);
     }
 
@@ -684,7 +724,7 @@
 
     @Override
     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
-        nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
+        execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
     }
 
     @Override
@@ -701,19 +741,22 @@
 
     @Override
     public boolean requestWindowFocus() {
-
-        long ptr = getNSWindowPtr();
-        if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
-            CWrapper.NSWindow.makeMainWindow(ptr);
-        }
-        CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+        execute(ptr -> {
+            if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
+                CWrapper.NSWindow.makeMainWindow(ptr);
+            }
+            CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+        });
         return true;
     }
 
     @Override
     public boolean isActive() {
-        long ptr = getNSWindowPtr();
-        return CWrapper.NSWindow.isKeyWindow(ptr);
+        AtomicBoolean ref = new AtomicBoolean();
+        execute(ptr -> {
+            ref.set(CWrapper.NSWindow.isKeyWindow(ptr));
+        });
+        return ref.get();
     }
 
     @Override
@@ -735,21 +778,21 @@
 
     @Override
     public void setOpacity(float opacity) {
-        CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
+        execute(ptr -> CWrapper.NSWindow.setAlphaValue(ptr, opacity));
     }
 
     @Override
     public void setOpaque(boolean isOpaque) {
-        CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
+        execute(ptr -> CWrapper.NSWindow.setOpaque(ptr, isOpaque));
         boolean isTextured = (peer == null) ? false : peer.isTextured();
         if (!isTextured) {
             if (!isOpaque) {
-                CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0);
+                execute(ptr -> CWrapper.NSWindow.setBackgroundColor(ptr, 0));
             } else if (peer != null) {
                 Color color = peer.getBackground();
                 if (color != null) {
                     int rgb = color.getRGB();
-                    CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb);
+                    execute(ptr->CWrapper.NSWindow.setBackgroundColor(ptr, rgb));
                 }
             }
         }
@@ -762,12 +805,12 @@
     @Override
     public void enterFullScreenMode() {
         isFullScreenMode = true;
-        nativeEnterFullScreenMode(getNSWindowPtr());
+        execute(CPlatformWindow::nativeEnterFullScreenMode);
     }
 
     @Override
     public void exitFullScreenMode() {
-        nativeExitFullScreenMode(getNSWindowPtr());
+        execute(CPlatformWindow::nativeExitFullScreenMode);
         isFullScreenMode = false;
     }
 
@@ -786,7 +829,6 @@
         int prevWindowState = peer.getState();
         if (prevWindowState == windowState) return;
 
-        final long nsWindowPtr = getNSWindowPtr();
         if ((windowState & Frame.ICONIFIED) != 0) {
             // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
             windowState = Frame.ICONIFIED;
@@ -798,18 +840,18 @@
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
                 }
-                CWrapper.NSWindow.miniaturize(nsWindowPtr);
+                execute(CWrapper.NSWindow::miniaturize);
                 break;
             case Frame.MAXIMIZED_BOTH:
                 if (prevWindowState == Frame.ICONIFIED) {
                     // let's return into the normal states first
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(CWrapper.NSWindow::deminiaturize);
                 }
                 maximize();
                 break;
             case Frame.NORMAL:
                 if (prevWindowState == Frame.ICONIFIED) {
-                    CWrapper.NSWindow.deminiaturize(nsWindowPtr);
+                    execute(CWrapper.NSWindow::deminiaturize);
                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
                     // the zoom call toggles between the normal and the max states
                     unmaximize();
@@ -833,15 +875,15 @@
             // We are going to show a modal window. Previously displayed window will be
             // blocked/disabled. So we have to send mouse exited event to it now, since
             // all mouse events are discarded for blocked/disabled windows.
-            nativeSynthesizeMouseEnteredExitedEvents(getNSWindowPtr(), CocoaConstants.NSMouseExited);
+            execute(ptr -> nativeSynthesizeMouseEnteredExitedEvents(ptr, CocoaConstants.NSMouseExited));
         }
 
-        nativeSetEnabled(getNSWindowPtr(), !blocked);
+        execute(ptr -> nativeSetEnabled(ptr, !blocked));
         checkBlockingAndOrder();
     }
 
     public final void invalidateShadow(){
-        nativeRevalidateNSWindowShadow(getNSWindowPtr());
+        execute(ptr -> nativeRevalidateNSWindowShadow(ptr));
     }
 
     // ----------------------------------------------------------------------
@@ -1029,11 +1071,11 @@
 
         pWindow.orderAboveSiblings();
 
-        final long nsWindowPtr = pWindow.getNSWindowPtr();
-        CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
-        CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
-        CWrapper.NSWindow.makeMainWindow(nsWindowPtr);
-
+        pWindow.execute(ptr -> {
+            CWrapper.NSWindow.orderFrontRegardless(ptr);
+            CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
+            CWrapper.NSWindow.makeMainWindow(ptr);
+        });
         return true;
     }
 
@@ -1072,7 +1114,7 @@
         // which is going to become 'main window', are placed above their siblings.
         CPlatformWindow rootOwner = getRootOwner();
         if (rootOwner.isVisible() && !rootOwner.isIconified()) {
-            CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr());
+            rootOwner.execute(CWrapper.NSWindow::orderFront);
         }
         // Do not order child windows of iconified owner.
         if (!rootOwner.isIconified()) {
@@ -1099,10 +1141,13 @@
                     // the window should be ordered above its siblings; otherwise the window is just ordered
                     // above its nearest parent.
                     if (pw.isOneOfOwnersOrSelf(this)) {
-                        CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
+                        pw.execute(CWrapper.NSWindow::orderFront);
                     } else {
-                        CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
-                                pw.owner.getNSWindowPtr());
+                        pw.owner.execute(ownerPtr -> {
+                            pw.execute(ptr -> {
+                                CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
+                            });
+                        });
                     }
                     pw.applyWindowLevel(w);
                 }
@@ -1124,9 +1169,9 @@
 
     protected void applyWindowLevel(Window target) {
         if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
-            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
+            execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSFloatingWindowLevel));
         } else if (target.getType() == Window.Type.POPUP) {
-            CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
+            execute(ptr->CWrapper.NSWindow.setLevel(ptr, CWrapper.NSWindow.NSPopUpMenuWindowLevel));
         }
     }
 
--- a/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CTrayIcon.java	Tue Apr 04 11:57:35 2017 -0700
@@ -36,6 +36,7 @@
 import java.awt.peer.TrayIconPeer;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
     private TrayIcon target;
@@ -88,10 +89,6 @@
         return nativeCreate();
     }
 
-    private long getModel() {
-        return ptr;
-    }
-
     private native long nativeCreate();
 
     //invocation from the AWTTrayIcon.m
@@ -154,7 +151,7 @@
 
     @Override
     public void setToolTip(String tooltip) {
-        nativeSetToolTip(getModel(), tooltip);
+        execute(ptr -> nativeSetToolTip(ptr, tooltip));
     }
 
     //adds tooltip to the NSStatusBar's NSButton.
@@ -183,7 +180,12 @@
         }
 
         CImage cimage = CImage.getCreator().createFromImage(image);
-        setNativeImage(getModel(), cimage.ptr, target.isImageAutoSize());
+        boolean imageAutoSize = target.isImageAutoSize();
+        cimage.execute(imagePtr -> {
+            execute(ptr -> {
+                setNativeImage(ptr, imagePtr, imageAutoSize);
+            });
+        });
     }
 
     private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
@@ -363,7 +365,14 @@
     private void showMessageDialog() {
 
         Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
-        Point2D iconLoc = nativeGetIconLocation(getModel());
+        AtomicReference<Point2D> ref = new AtomicReference<>();
+        execute(ptr -> {
+            ref.set(nativeGetIconLocation(ptr));
+        });
+        Point2D iconLoc = ref.get();
+        if (iconLoc == null) {
+            return;
+        }
 
         int dialogY = (int)iconLoc.getY();
         int dialogX = (int)iconLoc.getX();
--- a/src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java	Tue Apr 04 11:57:35 2017 -0700
@@ -74,13 +74,13 @@
 
     @Override
     public void dispose() {
-        CWrapper.NSView.removeFromSuperview(view.getAWTView());
+        view.execute(CWrapper.NSView::removeFromSuperview);
         view.dispose();
     }
 
     @Override
     public void setVisible(boolean visible) {
-        CWrapper.NSView.setHidden(view.getAWTView(), !visible);
+        view.execute(ptr -> CWrapper.NSView.setHidden(ptr, !visible));
     }
 
     @Override
--- a/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CWarningWindow.java	Tue Apr 04 11:57:35 2017 -0700
@@ -219,14 +219,14 @@
     @Override
     public void setVisible(boolean visible) {
         synchronized (lock) {
-            final long nsWindowPtr = getNSWindowPtr();
-
-            // Actually show or hide the window
-            if (visible) {
-                CWrapper.NSWindow.orderFront(nsWindowPtr);
-            } else {
-                CWrapper.NSWindow.orderOut(nsWindowPtr);
-            }
+            execute(ptr -> {
+                // Actually show or hide the window
+                if (visible) {
+                    CWrapper.NSWindow.orderFront(ptr);
+                } else {
+                    CWrapper.NSWindow.orderOut(ptr);
+                }
+            });
 
             this.visible = visible;
 
@@ -234,8 +234,13 @@
             if (visible) {
                 // Order myself above my parent
                 if (owner != null && owner.isVisible()) {
-                    CWrapper.NSWindow.orderWindow(nsWindowPtr,
-                            CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
+                    owner.execute(ownerPtr -> {
+                        execute(ptr -> {
+                            CWrapper.NSWindow.orderWindow(ptr,
+                                                          CWrapper.NSWindow.NSWindowAbove,
+                                                          ownerPtr);
+                        });
+                    });
 
                     // do not allow security warning to be obscured by other windows
                     applyWindowLevel(ownerWindow);
--- a/src/macosx/native/sun/awt/AWTSurfaceLayers.h	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.h	Tue Apr 04 11:57:35 2017 -0700
@@ -41,6 +41,8 @@
     CALayer *windowLayer;
 }
 
+@property (retain) CALayer *windowLayer;
+
 - (id) initWithWindowLayer: (CALayer *)windowLayer;
 - (void) setBounds: (CGRect)rect;
 
--- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Tue Apr 04 11:57:35 2017 -0700
@@ -38,11 +38,15 @@
     self = [super init];
     if (self == nil) return self;
 
-    windowLayer = aWindowLayer;
+    self.windowLayer = aWindowLayer;
 
     return self;
 }
 
+- (void) dealloc {
+    self.windowLayer = nil;
+    [super dealloc];
+}
 
 - (CALayer *) layer {
     return layer;
--- a/src/macosx/native/sun/awt/AWTWindow.m	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.m	Tue Apr 04 11:57:35 2017 -0700
@@ -345,7 +345,6 @@
     return windowLayers;
 }
 
-
 // returns id for the topmost window under mouse
 + (NSInteger) getTopmostWindowUnderMouseID {
     NSInteger result = -1;
--- a/src/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/resources/windows_ko.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -38,7 +38,7 @@
 FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274
 FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/com/sun/rowset/RowSetResourceBundle_sv.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
 cachedrowsetimpl.longfail = getLong utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
 cachedrowsetimpl.floatfail = getFloat utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
 cachedrowsetimpl.doublefail = getDouble utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
-cachedrowsetimpl.dtypemismt = Inkompatibel datatyp 
+cachedrowsetimpl.dtypemismt = Felmatchad datatyp 
 cachedrowsetimpl.datefail = getDate utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
 cachedrowsetimpl.timefail = getTime utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
 cachedrowsetimpl.posupdate = Det finns inte st\u00F6d f\u00F6r positionerad uppdatering
--- a/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal_ko.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -36,7 +36,7 @@
 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -36,7 +36,7 @@
 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
-FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68
+FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
--- a/src/share/classes/java/awt/Menu.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/java/awt/Menu.java	Tue Apr 04 11:57:35 2017 -0700
@@ -411,9 +411,9 @@
             items.removeElementAt(index);
             MenuPeer peer = (MenuPeer)this.peer;
             if (peer != null) {
+                peer.delItem(index);
                 mi.removeNotify();
                 mi.parent = null;
-                peer.delItem(index);
             }
         }
     }
--- a/src/share/classes/java/awt/MenuBar.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/java/awt/MenuBar.java	Tue Apr 04 11:57:35 2017 -0700
@@ -222,7 +222,6 @@
             if (m.parent != null) {
                 m.parent.remove(m);
             }
-            menus.addElement(m);
             m.parent = this;
 
             MenuBarPeer peer = (MenuBarPeer)this.peer;
@@ -230,7 +229,10 @@
                 if (m.peer == null) {
                     m.addNotify();
                 }
+                menus.addElement(m);
                 peer.addMenu(m);
+            } else {
+                menus.addElement(m);
             }
             return m;
         }
@@ -248,9 +250,9 @@
             menus.removeElementAt(index);
             MenuBarPeer peer = (MenuBarPeer)this.peer;
             if (peer != null) {
+                peer.delMenu(index);
                 m.removeNotify();
                 m.parent = null;
-                peer.delMenu(index);
             }
             if (helpMenu == m) {
                 helpMenu = null;
--- a/src/share/classes/java/awt/MenuComponent.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/java/awt/MenuComponent.java	Tue Apr 04 11:57:35 2017 -0700
@@ -75,7 +75,7 @@
      * @see #setFont(Font)
      * @see #getFont()
      */
-    Font font;
+    volatile Font font;
 
     /**
      * The menu component's name, which defaults to <code>null</code>.
@@ -292,11 +292,13 @@
      * @see       java.awt.font.TextAttribute
      */
     public void setFont(Font f) {
-        font = f;
-        //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
-        MenuComponentPeer peer = this.peer;
-        if (peer != null) {
-            peer.setFont(f);
+        synchronized (getTreeLock()) {
+            font = f;
+            //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
+            MenuComponentPeer peer = this.peer;
+            if (peer != null) {
+                peer.setFont(f);
+            }
         }
     }
 
--- a/src/share/classes/java/io/ObjectInputStream.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/java/io/ObjectInputStream.java	Tue Apr 04 11:57:35 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
@@ -1774,12 +1774,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initProxy(cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initProxy(cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
@@ -1824,12 +1831,19 @@
         } catch (ClassNotFoundException ex) {
             resolveEx = ex;
         }
+
+        // Call filterCheck on the class before reading anything else
+        filterCheck(cl, -1);
+
         skipCustomData();
 
-        desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
-
-        // Call filterCheck on the definition
-        filterCheck(desc.forClass(), -1);
+        try {
+            totalObjectRefs++;
+            depth++;
+            desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
+        } finally {
+            depth--;
+        }
 
         handles.finish(descHandle);
         passHandle = descHandle;
--- a/src/share/classes/java/lang/Thread.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/java/lang/Thread.java	Tue Apr 04 11:57:35 2017 -0700
@@ -342,11 +342,11 @@
 
     /**
      * Initializes a Thread with the current AccessControlContext.
-     * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext)
+     * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
      */
     private void init(ThreadGroup g, Runnable target, String name,
                       long stackSize) {
-        init(g, target, name, stackSize, null);
+        init(g, target, name, stackSize, null, true);
     }
 
     /**
@@ -359,9 +359,12 @@
      *        zero to indicate that this parameter is to be ignored.
      * @param acc the AccessControlContext to inherit, or
      *            AccessController.getContext() if null
+     * @param inheritThreadLocals if {@code true}, inherit initial values for
+     *            inheritable thread-locals from the constructing thread
      */
     private void init(ThreadGroup g, Runnable target, String name,
-                      long stackSize, AccessControlContext acc) {
+                      long stackSize, AccessControlContext acc,
+                      boolean inheritThreadLocals) {
         if (name == null) {
             throw new NullPointerException("name cannot be null");
         }
@@ -412,7 +415,7 @@
                 acc != null ? acc : AccessController.getContext();
         this.target = target;
         setPriority(priority);
-        if (parent.inheritableThreadLocals != null)
+        if (inheritThreadLocals && parent.inheritableThreadLocals != null)
             this.inheritableThreadLocals =
                 ThreadLocal.createInheritedMap(parent.inheritableThreadLocals);
         /* Stash the specified stack size in case the VM cares */
@@ -466,7 +469,7 @@
      * This is not a public constructor.
      */
     Thread(Runnable target, AccessControlContext acc) {
-        init(null, target, "Thread-" + nextThreadNum(), 0, acc);
+        init(null, target, "Thread-" + nextThreadNum(), 0, acc, false);
     }
 
     /**
--- a/src/share/classes/sun/misc/Launcher.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/misc/Launcher.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -28,11 +28,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.FilePermission;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.MalformedURLException;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
+import java.net.*;
 import java.util.HashSet;
 import java.util.StringTokenizer;
 import java.util.Set;
@@ -213,8 +209,16 @@
             URL[] urls = super.getURLs();
             File prevDir = null;
             for (int i = 0; i < urls.length; i++) {
-                // Get the ext directory from the URL
-                File dir = new File(urls[i].getPath()).getParentFile();
+                // Get the ext directory from the URL; convert to
+                // URI first, so the URL will be decoded.
+                URI uri;
+                try {
+                    uri = urls[i].toURI();
+                } catch (URISyntaxException ue) {
+                    // skip this URL if cannot convert it to URI
+                    continue;
+                }
+                File dir = new File(uri).getParentFile();
                 if (dir != null && !dir.equals(prevDir)) {
                     // Look in architecture-specific subdirectory first
                     // Read from the saved system properties to avoid deadlock
--- a/src/share/classes/sun/net/ftp/impl/FtpClient.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/ftp/impl/FtpClient.java	Tue Apr 04 11:57:35 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
@@ -517,7 +517,8 @@
      * @return <code>true</code> if the command was successful
      * @throws IOException
      */
-    private boolean issueCommand(String cmd) throws IOException {
+    private boolean issueCommand(String cmd) throws IOException,
+            sun.net.ftp.FtpProtocolException {
         if (!isConnected()) {
             throw new IllegalStateException("Not connected");
         }
@@ -528,6 +529,12 @@
                 // ignore...
             }
         }
+        if (cmd.indexOf('\n') != -1) {
+            sun.net.ftp.FtpProtocolException ex
+                    = new sun.net.ftp.FtpProtocolException("Illegal FTP command");
+            ex.initCause(new IllegalArgumentException("Illegal carriage return"));
+            throw ex;
+        }
         sendServer(cmd + "\r\n");
         return readReply();
     }
@@ -1120,7 +1127,10 @@
      */
     public void close() throws IOException {
         if (isConnected()) {
-            issueCommand("QUIT");
+            try {
+                issueCommand("QUIT");
+            } catch (FtpProtocolException e) {
+            }
             loggedIn = false;
         }
         disconnect();
@@ -1898,7 +1908,8 @@
         return null;
     }
 
-    private boolean sendSecurityData(byte[] buf) throws IOException {
+    private boolean sendSecurityData(byte[] buf) throws IOException,
+            sun.net.ftp.FtpProtocolException {
         BASE64Encoder encoder = new BASE64Encoder();
         String s = encoder.encode(buf);
         return issueCommand("ADAT " + s);
--- a/src/share/classes/sun/net/smtp/SmtpClient.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/smtp/SmtpClient.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
 
 public class SmtpClient extends TransferProtocolClient {
 
+    private static int DEFAULT_SMTP_PORT = 25;
     String mailhost;
     SmtpPrintStream message;
 
@@ -74,6 +75,10 @@
     }
 
     public void to(String s) throws IOException {
+        if (s.indexOf('\n') != -1) {
+            throw new IOException("Illegal SMTP command",
+                    new IllegalArgumentException("Illegal carriage return"));
+        }
         int st = 0;
         int limit = s.length();
         int pos = 0;
@@ -116,16 +121,21 @@
     }
 
     public void from(String s) throws IOException {
-        if (s.startsWith("<"))
+        if (s.indexOf('\n') != -1) {
+            throw new IOException("Illegal SMTP command",
+                    new IllegalArgumentException("Illegal carriage return"));
+        }
+        if (s.startsWith("<")) {
             issueCommand("mail from: " + s + "\r\n", 250);
-        else
+        } else {
             issueCommand("mail from: <" + s + ">\r\n", 250);
+        }
     }
 
     /** open a SMTP connection to host <i>host</i>. */
     private void openServer(String host) throws IOException {
         mailhost = host;
-        openServer(mailhost, 25);
+        openServer(mailhost, DEFAULT_SMTP_PORT);
         issueCommand("helo "+InetAddress.getLocalHost().getHostName()+"\r\n", 250);
     }
 
--- a/src/share/classes/sun/net/www/http/HttpClient.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/www/http/HttpClient.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,20 @@
     // from previous releases.
     private static boolean retryPostProp = true;
 
+    /* Value of the system property jdk.ntlm.cache;
+       if false, then NTLM connections will not be cached.
+       The default value is 'true'. */
+    private static final boolean cacheNTLMProp;
+    /* Value of the system property jdk.spnego.cache;
+       if false, then connections authentified using the Negotiate/Kerberos
+       scheme will not be cached.
+       The default value is 'true'. */
+    private static final boolean cacheSPNEGOProp;
+
     volatile boolean keepingAlive = false;     /* this is a keep-alive connection */
+    volatile boolean disableKeepAlive;/* keep-alive has been disabled for this
+                                         connection - this will be used when
+                                         recomputing the value of keepingAlive */
     int keepAliveConnections = -1;    /* number of keep-alives left */
 
     /**Idle timeout value, in milliseconds. Zero means infinity,
@@ -149,6 +162,12 @@
         String retryPost = java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("sun.net.http.retryPost"));
 
+        String cacheNTLM = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("jdk.ntlm.cache"));
+
+        String cacheSPNEGO = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("jdk.spnego.cache"));
+
         if (keepAlive != null) {
             keepAliveProp = Boolean.valueOf(keepAlive).booleanValue();
         } else {
@@ -157,9 +176,21 @@
 
         if (retryPost != null) {
             retryPostProp = Boolean.valueOf(retryPost).booleanValue();
-        } else
-            retryPostProp = true;
+        } else {
+             retryPostProp = true;
+        }
 
+        if (cacheNTLM != null) {
+            cacheNTLMProp = Boolean.parseBoolean(cacheNTLM);
+        } else {
+            cacheNTLMProp = true;
+        }
+
+        if (cacheSPNEGO != null) {
+            cacheSPNEGOProp = Boolean.parseBoolean(cacheSPNEGO);
+        } else {
+            cacheSPNEGOProp = true;
+        }
     }
 
     /**
@@ -708,6 +739,7 @@
                 nread += r;
             }
             String keep=null;
+            String authenticate=null;
             ret = b[0] == 'H' && b[1] == 'T'
                     && b[2] == 'T' && b[3] == 'P' && b[4] == '/' &&
                 b[5] == '1' && b[6] == '.';
@@ -736,17 +768,44 @@
                  */
                 if (usingProxy) { // not likely a proxy will return this
                     keep = responses.findValue("Proxy-Connection");
+                    authenticate = responses.findValue("Proxy-Authenticate");
                 }
                 if (keep == null) {
                     keep = responses.findValue("Connection");
+                    authenticate = responses.findValue("WWW-Authenticate");
                 }
+
+                // 'disableKeepAlive' starts with the value false.
+                // It can transition from false to true, but once true
+                // it stays true.
+                // If cacheNTLMProp is false, and disableKeepAlive is false,
+                // then we need to examine the response headers to figure out
+                // whether we are doing NTLM authentication. If we do NTLM,
+                // and cacheNTLMProp is false, than we can't keep this connection
+                // alive: we will switch disableKeepAlive to true.
+                boolean canKeepAlive = !disableKeepAlive;
+                if (canKeepAlive && (cacheNTLMProp == false || cacheSPNEGOProp == false)
+                        && authenticate != null) {
+                    authenticate = authenticate.toLowerCase(Locale.US);
+                    if (cacheNTLMProp == false) {
+                        canKeepAlive &= !authenticate.startsWith("ntlm ");
+                    }
+                    if (cacheSPNEGOProp == false) {
+                        canKeepAlive &= !authenticate.startsWith("negotiate ");
+                        canKeepAlive &= !authenticate.startsWith("kerberos ");
+                    }
+                }
+                disableKeepAlive |= !canKeepAlive;
+
                 if (keep != null && keep.toLowerCase(Locale.US).equals("keep-alive")) {
                     /* some servers, notably Apache1.1, send something like:
                      * "Keep-Alive: timeout=15, max=1" which we should respect.
                      */
-                    HeaderParser p = new HeaderParser(
+                    if (disableKeepAlive) {
+                        keepAliveConnections = 1;
+                    } else {
+                        HeaderParser p = new HeaderParser(
                             responses.findValue("Keep-Alive"));
-                    if (p != null) {
                         /* default should be larger in case of proxy */
                         keepAliveConnections = p.findInt("max", usingProxy?50:5);
                         keepAliveTimeout = p.findInt("timeout", usingProxy?60:5);
@@ -756,7 +815,7 @@
                      * We're talking 1.1 or later. Keep persistent until
                      * the server says to close.
                      */
-                    if (keep != null) {
+                    if (keep != null || disableKeepAlive) {
                         /*
                          * The only Connection token we understand is close.
                          * Paranoia: if there is any Connection header then
@@ -838,7 +897,7 @@
                 keepAliveConnections = 1;
                 keepingAlive = false;
             } else {
-                keepingAlive = true;
+                keepingAlive = !disableKeepAlive;
             }
             failedOnce = false;
         } else {
@@ -871,7 +930,7 @@
                 (cl >= 0 ||
                  code == HttpURLConnection.HTTP_NOT_MODIFIED ||
                  code == HttpURLConnection.HTTP_NO_CONTENT)) {
-                keepingAlive = true;
+                keepingAlive = !disableKeepAlive;
                 failedOnce = false;
             } else if (keepingAlive) {
                 /* Previously we were keeping alive, and now we're not.  Remove
@@ -893,7 +952,11 @@
                 pi.setContentType(responses.findValue("content-type"));
             }
 
-            if (isKeepingAlive())   {
+            // If disableKeepAlive == true, the client will not be returned
+            // to the cache. But we still need to use a keepalive stream to
+            // allow the multi-message authentication exchange on the connection
+            boolean useKeepAliveStream = isKeepingAlive() || disableKeepAlive;
+            if (useKeepAliveStream)   {
                 // Wrap KeepAliveStream if keep alive is enabled.
                 logFinest("KeepAlive stream used: " + url);
                 serverInput = new KeepAliveStream(serverInput, pi, cl, this);
--- a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -298,6 +298,13 @@
             // Just keep throwing for now.
             throw e;
         } catch (FtpProtocolException fe) {
+            if (ftp != null) {
+                try {
+                    ftp.close();
+                } catch (IOException ioe) {
+                    fe.addSuppressed(ioe);
+                }
+            }
             throw new IOException(fe);
         }
         try {
@@ -480,11 +487,34 @@
                 msgh.add("content-type", "text/plain");
                 msgh.add("access-type", "directory");
             } catch (IOException ex) {
-                throw new FileNotFoundException(fullpath);
+                FileNotFoundException fnfe = new FileNotFoundException(fullpath);
+                if (ftp != null) {
+                    try {
+                        ftp.close();
+                    } catch (IOException ioe) {
+                        fnfe.addSuppressed(ioe);
+                    }
+                }
+                throw fnfe;
             } catch (FtpProtocolException ex2) {
-                throw new FileNotFoundException(fullpath);
+                FileNotFoundException fnfe = new FileNotFoundException(fullpath);
+                if (ftp != null) {
+                    try {
+                        ftp.close();
+                    } catch (IOException ioe) {
+                        fnfe.addSuppressed(ioe);
+                    }
+                }
+                throw fnfe;
             }
         } catch (FtpProtocolException ftpe) {
+            if (ftp != null) {
+                try {
+                    ftp.close();
+                } catch (IOException ioe) {
+                    ftpe.addSuppressed(ioe);
+                }
+            }
             throw new IOException(ftpe);
         }
         setProperties(msgh);
--- a/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,8 +64,7 @@
      * repeatedly, via the Authenticator. Default is false, which means that this
      * behavior is switched off.
      */
-    static boolean serializeAuth;
-
+    static final boolean serializeAuth;
     static {
         serializeAuth = java.security.AccessController.doPrivileged(
             new sun.security.action.GetBooleanAction(
@@ -105,6 +104,16 @@
     public String getProtocolScheme() {
         return protocol;
     }
+    /**
+     * Whether we should cache this instance in the AuthCache.
+     * This method returns {@code true} by default.
+     * Subclasses may override this method to add
+     * additional restrictions.
+     * @return {@code true} by default.
+     */
+    protected boolean useAuthCache() {
+        return true;
+    }
 
     /**
      * requests is used to ensure that interaction with the
@@ -341,9 +350,11 @@
      */
     void addToCache() {
         String key = cacheKey(true);
-        cache.put(key, this);
-        if (supportsPreemptiveAuthorization()) {
-            cache.put(cacheKey(false), this);
+        if (useAuthCache()) {
+            cache.put(key, this);
+            if (supportsPreemptiveAuthorization()) {
+                cache.put(cacheKey(false), this);
+            }
         }
         endAuthRequest(key);
     }
--- a/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
 import sun.util.logging.PlatformLogger;
 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
 import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
+import sun.security.action.GetPropertyAction;
 
 /**
  * NegotiateAuthentication:
@@ -52,10 +53,18 @@
     // These maps are used to manage the GSS availability for diffrent
     // hosts. The key for both maps is the host name.
     // <code>supported</code> is set when isSupported is checked,
+
     // if it's true, a cached Negotiator is put into <code>cache</code>.
     // the cache can be used only once, so after the first use, it's cleaned.
     static HashMap <String, Boolean> supported = null;
-    static HashMap <String, Negotiator> cache = null;
+    static ThreadLocal <HashMap <String, Negotiator>> cache = null;
+    /* Whether cache is enabled for Negotiate/Kerberos */
+    private static final boolean cacheSPNEGO;
+    static {
+        String spnegoCacheProp = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("jdk.spnego.cache", "true"));
+        cacheSPNEGO = Boolean.parseBoolean(spnegoCacheProp);
+    }
 
     // The HTTP Negotiate Helper
     private Negotiator negotiator = null;
@@ -118,8 +127,7 @@
      */
     private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) {
         if (supported == null) {
-            supported = new HashMap <String, Boolean>();
-            cache = new HashMap <String, Negotiator>();
+            supported = new HashMap<>();
         }
         String hostname = hci.host;
         hostname = hostname.toLowerCase();
@@ -132,7 +140,15 @@
             supported.put(hostname, true);
             // the only place cache.put is called. here we can make sure
             // the object is valid and the oneToken inside is not null
-            cache.put(hostname, neg);
+            if (cache == null) {
+                cache = new ThreadLocal<HashMap<String, Negotiator>>() {
+                    @Override
+                    protected HashMap<String, Negotiator> initialValue() {
+                        return new HashMap<>();
+                    }
+                };
+            }
+            cache.get().put(hostname, neg);
             return true;
         } else {
             supported.put(hostname, false);
@@ -140,6 +156,16 @@
         }
     }
 
+    private static synchronized HashMap<String, Negotiator> getCache() {
+        if (cache == null) return null;
+        return cache.get();
+    }
+
+    @Override
+    protected boolean useAuthCache() {
+        return super.useAuthCache() && cacheSPNEGO;
+    }
+
     /**
      * Not supported. Must use the setHeaders() method
      */
@@ -197,12 +223,11 @@
      */
     private byte[] firstToken() throws IOException {
         negotiator = null;
-        if (cache != null) {
-            synchronized(cache) {
-                negotiator = cache.get(getHost());
-                if (negotiator != null) {
-                    cache.remove(getHost()); // so that it is only used once
-                }
+        HashMap <String, Negotiator> cachedMap = getCache();
+        if (cachedMap != null) {
+            negotiator = cachedMap.get(getHost());
+            if (negotiator != null) {
+                cachedMap.remove(getHost()); // so that it is only used once
             }
         }
         if (negotiator == null) {
--- a/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,15 +134,15 @@
                 "  X =\u6307\u5B9A\u3057\u305F\u5225\u540D\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093"},
         {"no.manifest.", "\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002"},
         {".Signature.related.entries.","(\u30B7\u30B0\u30CD\u30C1\u30E3\u95A2\u9023\u30A8\u30F3\u30C8\u30EA)"},
-        {".Unsigned.entries.", "(\u672A\u7F72\u540D\u306E\u30A8\u30F3\u30C8\u30EA)"},
+        {".Unsigned.entries.", "(\u7F72\u540D\u306A\u3057\u306E\u30A8\u30F3\u30C8\u30EA)"},
         {"jar.is.unsigned",
                 "jar\u306F\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"},
         {"jar.treated.unsigned",
-                "\u8B66\u544A: \u7F72\u540D\u304C\u69CB\u6587\u89E3\u6790\u3067\u304D\u306A\u3044\u304B\u691C\u8A3C\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u3053\u306Ejar\u306F\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\u8A73\u7D30\u306F\u3001\u30C7\u30D0\u30C3\u30B0\u3092\u6709\u52B9\u306B\u3057\u3066(-J-Djava.security.debug=jar) jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
+                "\u8B66\u544A: \u7F72\u540D\u304C\u69CB\u6587\u89E3\u6790\u3067\u304D\u306A\u3044\u304B\u691C\u8A3C\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u3053\u306Ejar\u306F\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\u8A73\u7D30\u306F\u3001\u30C7\u30D0\u30C3\u30B0\u3092\u6709\u52B9\u306B\u3057\u3066(-J-Djava.security.debug=jar) jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
         {"jar.treated.unsigned.see.weak",
-                "\u3053\u306Ejar\u306F\u3001\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\n\n\u8A73\u7D30\u306F\u3001-verbose\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
+                "\u3053\u306Ejar\u306F\u3001\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\n\n\u8A73\u7D30\u306F\u3001-verbose\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
         {"jar.treated.unsigned.see.weak.verbose",
-                "\u8B66\u544A: \u3053\u306Ejar\u306F\u3001\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u3088\u3063\u3066\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059:"},
+                "\u8B66\u544A: \u3053\u306Ejar\u306F\u3001\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u3088\u3063\u3066\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059:"},
         {"jar.signed.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F\u3002"},
         {"jar.signed.with.signer.errors.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F - \u7F72\u540D\u8005\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\u3002"},
         {"jar.verified.", "jar\u304C\u691C\u8A3C\u3055\u308C\u307E\u3057\u305F\u3002"},
@@ -215,7 +215,7 @@
         {"Warning.", "\u8B66\u544A: "},
         {"Error.", "\u30A8\u30E9\u30FC: "},
         {"This.jar.contains.unsigned.entries.which.have.not.been.integrity.checked.",
-                "\u3053\u306Ejar\u306B\u306F\u3001\u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u3057\u3066\u3044\u306A\u3044\u672A\u7F72\u540D\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "},
+                "\u3053\u306Ejar\u306B\u306F\u3001\u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u3057\u3066\u3044\u306A\u3044\u7F72\u540D\u306A\u3057\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "},
         {"This.jar.contains.entries.whose.signer.certificate.has.expired.",
                 "\u3053\u306Ejar\u306B\u306F\u3001\u7F72\u540D\u8005\u306E\u8A3C\u660E\u66F8\u304C\u671F\u9650\u5207\u308C\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "},
         {"This.jar.contains.entries.whose.signer.certificate.will.expire.within.six.months.",
--- a/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,7 +142,7 @@
         {"jar.treated.unsigned.see.weak",
                 "\u7531\u4E8E\u8BE5 jar \u662F\u4F7F\u7528\u76EE\u524D\u5DF2\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684, \u56E0\u6B64\u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D\u3002\n\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -verbose \u9009\u9879\u91CD\u65B0\u8FD0\u884C jarsigner\u3002"},
         {"jar.treated.unsigned.see.weak.verbose",
-                "\u8B66\u544A: \u7531\u4E8E\u8BE5 jar \u662F\u4F7F\u7528\u76EE\u524D\u5DF2\u7531\u5B89\u5168\u5C5E\u6027\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684, \u56E0\u6B64\u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D:"},
+                "\u8B66\u544A: \u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D, \u56E0\u4E3A\u5B83\u662F\u7531\u76EE\u524D\u5B89\u5168\u5C5E\u6027\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684:"},
         {"jar.signed.", "jar \u5DF2\u7B7E\u540D\u3002"},
         {"jar.signed.with.signer.errors.", "jar \u5DF2\u7B7E\u540D, \u4F46\u51FA\u73B0\u7B7E\u540D\u8005\u9519\u8BEF\u3002"},
         {"jar.verified.", "jar \u5DF2\u9A8C\u8BC1\u3002"},
--- a/src/share/classes/sun/security/tools/policytool/Resources_sv.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/security/tools/policytool/Resources_sv.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
                 "Kan inte \u00F6ppna policyfilen: {0}: {1}"},
         {"Policy.Tool", "Policyverktyg"},
         {"Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.",
-                "Det uppstod ett fel n\u00E4r policykonfigurationen skulle \u00F6ppnas. Se varningsloggen f\u00F6r mer information."},
+                "Ett fel intr\u00E4ffade n\u00E4r policykonfigurationen skulle \u00F6ppnas. Se varningsloggen f\u00F6r mer information."},
         {"Error", "Fel"},
         {"OK", "OK"},
         {"Status", "Status"},
@@ -80,7 +80,7 @@
         {"Target.Name.",
                 "M\u00E5l:                                                    "},
         {"Actions.",
-                "Funktioner:                                                             "},
+                "\u00C5tg\u00E4rder:                                                             "},
         {"OK.to.overwrite.existing.file.filename.",
                 "Ska den befintliga filen {0} skrivas \u00F6ver?"},
         {"Cancel", "Avbryt"},
@@ -94,10 +94,10 @@
         {".Edit.Permission", "  Re&digera beh\u00F6righet"},
         {"Remove.Permission", "Ta &bort beh\u00F6righet"},
         {"Done", "Utf\u00F6rd"},
-        {"KeyStore.URL.", "KeyStore-&URL:"},
-        {"KeyStore.Type.", "KeyStore-&typ:"},
-        {"KeyStore.Provider.", "KeyStore-&leverant\u00F6r:"},
-        {"KeyStore.Password.URL.", "KeyStore-l\u00F6sen&ords-URL:"},
+        {"KeyStore.URL.", "Nyckellager-&URL:"},
+        {"KeyStore.Type.", "Nyckellager&typ:"},
+        {"KeyStore.Provider.", "Nyckellager&leverant\u00F6r:"},
+        {"KeyStore.Password.URL.", "L\u00F6sen&ords-URL till nyckellager:"},
         {"Principals", "Identitetshavare"},
         {".Edit.Principal.", "  Redigera identitetshavare:"},
         {".Add.New.Principal.", "  L\u00E4gg till ny identitetshavare:"},
--- a/src/share/classes/sun/security/util/AbstractAlgorithmConstraints.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/security/util/AbstractAlgorithmConstraints.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/src/share/classes/sun/tools/jar/resources/jar_sv.properties	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/classes/sun/tools/jar/resources/jar_sv.properties	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 error.bad.uflag=f\u00F6r u-flaggan m\u00E5ste manifest-, e-flagg- eller indatafiler anges.
 error.bad.eflag=e-flaggan och manifest med attributet Main-Class kan inte anges \ntillsammans.
 error.nosuch.fileordir={0} : det finns ingen s\u00E5dan fil eller katalog
-error.write.file=Det uppstod ett fel vid skrivning till befintlig jar-fil.
+error.write.file=Ett fel intr\u00E4ffade vid skrivning till befintlig jar-fil.
 error.create.dir={0} : kunde inte skapa n\u00E5gon katalog
 error.incorrect.length=ogiltig l\u00E4ngd vid bearbetning: {0}
 error.create.tempfile=Kunde inte skapa en tillf\u00E4llig fil
--- a/src/share/lib/security/java.security-aix	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/lib/security/java.security-aix	Tue Apr 04 11:57:35 2017 -0700
@@ -484,21 +484,21 @@
 #     jdkCA
 #       This constraint prohibits the specified algorithm only if the
 #       algorithm is used in a certificate chain that terminates at a marked
-#       trust anchor in the lib/security/cacerts keystore.  If the jdkCA
-#       constraint is not set, then all chains using the specified algorithm
+#       trust anchor in the??lib/security/cacerts keystore.  If the jdkCA
+#       constraint is not set, then all chains using the??specified algorithm
 #       are restricted.  jdkCA may only be used once in a DisabledAlgorithm
 #       expression.
-#       Example:  To apply this constraint to SHA-1 certificates, include
-#       the following:  "SHA1 jdkCA"
+#       Example: ??To apply this constraint to SHA-1 certificates, include
+#       the following: ??"SHA1 jdkCA"
 #
 #   DenyAfterConstraint:
 #     denyAfter YYYY-MM-DD
 #       This constraint prohibits a certificate with the specified algorithm
 #       from being used after the date regardless of the certificate's
-#       validity.  JAR files that are signed and timestamped before the
+#       validity. ??JAR files that are signed and timestamped before the
 #       constraint date with certificates containing the disabled algorithm
-#       will not be restricted.  The date is processed in the UTC timezone.
-#       This constraint can only be used once in a DisabledAlgorithm
+#       will not be restricted. ??The date is processed in the UTC timezone.
+#       This??constraint can only be used once in a DisabledAlgorithm
 #       expression.
 #       Example:  To deny usage of RSA 2048 bit certificates after Feb 3 2020,
 #       use the following:  "RSA keySize == 2048 & denyAfter 2020-02-03"
--- a/src/share/lib/security/java.security-linux	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/lib/security/java.security-linux	Tue Apr 04 11:57:35 2017 -0700
@@ -484,21 +484,21 @@
 #     jdkCA
 #       This constraint prohibits the specified algorithm only if the
 #       algorithm is used in a certificate chain that terminates at a marked
-#       trust anchor in the lib/security/cacerts keystore.  If the jdkCA
-#       constraint is not set, then all chains using the specified algorithm
+#       trust anchor in the??lib/security/cacerts keystore.  If the jdkCA
+#       constraint is not set, then all chains using the??specified algorithm
 #       are restricted.  jdkCA may only be used once in a DisabledAlgorithm
 #       expression.
-#       Example:  To apply this constraint to SHA-1 certificates, include
-#       the following:  "SHA1 jdkCA"
+#       Example: ??To apply this constraint to SHA-1 certificates, include
+#       the following: ??"SHA1 jdkCA"
 #
 #   DenyAfterConstraint:
 #     denyAfter YYYY-MM-DD
 #       This constraint prohibits a certificate with the specified algorithm
 #       from being used after the date regardless of the certificate's
-#       validity.  JAR files that are signed and timestamped before the
+#       validity. ??JAR files that are signed and timestamped before the
 #       constraint date with certificates containing the disabled algorithm
-#       will not be restricted.  The date is processed in the UTC timezone.
-#       This constraint can only be used once in a DisabledAlgorithm
+#       will not be restricted. ??The date is processed in the UTC timezone.
+#       This??constraint can only be used once in a DisabledAlgorithm
 #       expression.
 #       Example:  To deny usage of RSA 2048 bit certificates after Feb 3 2020,
 #       use the following:  "RSA keySize == 2048 & denyAfter 2020-02-03"
--- a/src/share/lib/security/java.security-macosx	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/lib/security/java.security-macosx	Tue Apr 04 11:57:35 2017 -0700
@@ -487,21 +487,21 @@
 #     jdkCA
 #       This constraint prohibits the specified algorithm only if the
 #       algorithm is used in a certificate chain that terminates at a marked
-#       trust anchor in the lib/security/cacerts keystore.  If the jdkCA
-#       constraint is not set, then all chains using the specified algorithm
+#       trust anchor in the??lib/security/cacerts keystore.  If the jdkCA
+#       constraint is not set, then all chains using the??specified algorithm
 #       are restricted.  jdkCA may only be used once in a DisabledAlgorithm
 #       expression.
-#       Example:  To apply this constraint to SHA-1 certificates, include
-#       the following:  "SHA1 jdkCA"
+#       Example: ??To apply this constraint to SHA-1 certificates, include
+#       the following: ??"SHA1 jdkCA"
 #
 #   DenyAfterConstraint:
 #     denyAfter YYYY-MM-DD
 #       This constraint prohibits a certificate with the specified algorithm
 #       from being used after the date regardless of the certificate's
-#       validity.  JAR files that are signed and timestamped before the
+#       validity. ??JAR files that are signed and timestamped before the
 #       constraint date with certificates containing the disabled algorithm
-#       will not be restricted.  The date is processed in the UTC timezone.
-#       This constraint can only be used once in a DisabledAlgorithm
+#       will not be restricted. ??The date is processed in the UTC timezone.
+#       This??constraint can only be used once in a DisabledAlgorithm
 #       expression.
 #       Example:  To deny usage of RSA 2048 bit certificates after Feb 3 2020,
 #       use the following:  "RSA keySize == 2048 & denyAfter 2020-02-03"
--- a/src/share/lib/security/java.security-solaris	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/lib/security/java.security-solaris	Tue Apr 04 11:57:35 2017 -0700
@@ -486,21 +486,21 @@
 #     jdkCA
 #       This constraint prohibits the specified algorithm only if the
 #       algorithm is used in a certificate chain that terminates at a marked
-#       trust anchor in the lib/security/cacerts keystore.  If the jdkCA
-#       constraint is not set, then all chains using the specified algorithm
+#       trust anchor in the??lib/security/cacerts keystore.  If the jdkCA
+#       constraint is not set, then all chains using the??specified algorithm
 #       are restricted.  jdkCA may only be used once in a DisabledAlgorithm
 #       expression.
-#       Example:  To apply this constraint to SHA-1 certificates, include
-#       the following:  "SHA1 jdkCA"
+#       Example: ??To apply this constraint to SHA-1 certificates, include
+#       the following: ??"SHA1 jdkCA"
 #
 #   DenyAfterConstraint:
 #     denyAfter YYYY-MM-DD
 #       This constraint prohibits a certificate with the specified algorithm
 #       from being used after the date regardless of the certificate's
-#       validity.  JAR files that are signed and timestamped before the
+#       validity. ??JAR files that are signed and timestamped before the
 #       constraint date with certificates containing the disabled algorithm
-#       will not be restricted.  The date is processed in the UTC timezone.
-#       This constraint can only be used once in a DisabledAlgorithm
+#       will not be restricted. ??The date is processed in the UTC timezone.
+#       This??constraint can only be used once in a DisabledAlgorithm
 #       expression.
 #       Example:  To deny usage of RSA 2048 bit certificates after Feb 3 2020,
 #       use the following:  "RSA keySize == 2048 & denyAfter 2020-02-03"
--- a/src/share/lib/security/java.security-windows	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/share/lib/security/java.security-windows	Tue Apr 04 11:57:35 2017 -0700
@@ -487,21 +487,21 @@
 #     jdkCA
 #       This constraint prohibits the specified algorithm only if the
 #       algorithm is used in a certificate chain that terminates at a marked
-#       trust anchor in the lib/security/cacerts keystore.  If the jdkCA
-#       constraint is not set, then all chains using the specified algorithm
+#       trust anchor in the??lib/security/cacerts keystore.  If the jdkCA
+#       constraint is not set, then all chains using the??specified algorithm
 #       are restricted.  jdkCA may only be used once in a DisabledAlgorithm
 #       expression.
-#       Example:  To apply this constraint to SHA-1 certificates, include
-#       the following:  "SHA1 jdkCA"
+#       Example: ??To apply this constraint to SHA-1 certificates, include
+#       the following: ??"SHA1 jdkCA"
 #
 #   DenyAfterConstraint:
 #     denyAfter YYYY-MM-DD
 #       This constraint prohibits a certificate with the specified algorithm
 #       from being used after the date regardless of the certificate's
-#       validity.  JAR files that are signed and timestamped before the
+#       validity. ??JAR files that are signed and timestamped before the
 #       constraint date with certificates containing the disabled algorithm
-#       will not be restricted.  The date is processed in the UTC timezone.
-#       This constraint can only be used once in a DisabledAlgorithm
+#       will not be restricted. ??The date is processed in the UTC timezone.
+#       This??constraint can only be used once in a DisabledAlgorithm
 #       expression.
 #       Example:  To deny usage of RSA 2048 bit certificates after Feb 3 2020,
 #       use the following:  "RSA keySize == 2048 & denyAfter 2020-02-03"
--- a/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,11 +74,15 @@
 
     private String hostname;
     private static String defaultDomain; /* Domain to use if not specified by user */
+    private static final boolean ntlmCache;  /* Whether cache is enabled for NTLM */
 
     static {
         defaultDomain = java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", ""));
-    };
+        String ntlmCacheProp = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("jdk.ntlm.cache", "true"));
+        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
+    }
 
     public static boolean supportsTransparentAuth () {
         return false;
@@ -167,6 +171,11 @@
         init (pw);
     }
 
+    @Override
+    protected boolean useAuthCache() {
+        return ntlmCache && super.useAuthCache();
+    }
+
     /**
      * @return true if this authentication supports preemptive authorization
      */
@@ -243,4 +252,3 @@
         return result;
     }
 }
-
--- a/src/windows/classes/sun/awt/windows/WMenuItemPeer.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/classes/sun/awt/windows/WMenuItemPeer.java	Tue Apr 04 11:57:35 2017 -0700
@@ -71,7 +71,7 @@
         enable(false);
     }
 
-    public void readShortcutLabel() {
+    private void readShortcutLabel() {
         //Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
         WMenuPeer ancestor = parent;
         while (ancestor != null && !(ancestor instanceof WMenuBarPeer)) {
@@ -115,7 +115,7 @@
         readShortcutLabel();
     }
 
-    protected void checkMenuCreation()
+    void checkMenuCreation()
     {
         // fix for 5088782: check if menu peer is created successfully
         if (pData == 0)
--- a/src/windows/classes/sun/awt/windows/WObjectPeer.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/classes/sun/awt/windows/WObjectPeer.java	Tue Apr 04 11:57:35 2017 -0700
@@ -34,16 +34,16 @@
     }
 
     // The Windows handle for the native widget.
-    long pData;
+    volatile long pData;
     // if the native peer has been destroyed
-    boolean destroyed = false;
+    private volatile boolean destroyed;
     // The associated AWT object.
-    Object target;
+    volatile Object target;
 
     private volatile boolean disposed;
 
     // set from JNI if any errors in creating the peer occur
-    protected Error createError = null;
+    volatile Error createError = null;
 
     // used to synchronize the state of this peer
     private final Object stateLock = new Object();
--- a/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,11 +50,15 @@
 
     private String hostname;
     private static String defaultDomain; /* Domain to use if not specified by user */
+    private static final boolean ntlmCache; /* Whether cache is enabled for NTLM */
 
     static {
         defaultDomain = java.security.AccessController.doPrivileged(
             new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
                                                       "domain"));
+        String ntlmCacheProp = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("jdk.ntlm.cache", "true"));
+        ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
     };
 
     private void init0() {
@@ -130,6 +134,11 @@
         init (pw);
     }
 
+    @Override
+    protected boolean useAuthCache() {
+        return ntlmCache && super.useAuthCache();
+    }
+
     /**
      * @return true if this authentication supports preemptive authorization
      */
--- a/src/windows/native/sun/windows/awt_Component.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3772,7 +3772,10 @@
     HWND hWnd = GetHWnd();
     HWND hTop = GetTopLevelParentForWindow(hWnd);
     ::ClientToScreen(hTop, &p);
-
+    if (!m_bitsCandType) {
+        SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
+        return;
+    }
     for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
         if ( m_bitsCandType & bits )
             SetCandidateWindow(iCandType, x - p.x, y - p.y);
@@ -3790,7 +3793,7 @@
     HIMC hIMC = ImmGetContext(hwnd);
     CANDIDATEFORM cf;
     cf.dwIndex = iCandType;
-    cf.dwStyle = CFS_CANDIDATEPOS;
+    cf.dwStyle = CFS_POINT;
     cf.ptCurrentPos.x = x;
     cf.ptCurrentPos.y = y;
 
@@ -3822,9 +3825,15 @@
 
 MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType)
 {
-    if (!m_useNativeCompWindow && subMsg == IMN_OPENCANDIDATE) {
-        m_bitsCandType = bitsCandType;
-        InquireCandidatePosition();
+    if (!m_useNativeCompWindow) {
+        if (subMsg == IMN_OPENCANDIDATE) {
+            m_bitsCandType = subMsg;
+            InquireCandidatePosition();
+        } else if (subMsg == IMN_OPENSTATUSWINDOW ||
+                   subMsg == WM_IME_STARTCOMPOSITION) {
+            m_bitsCandType = 0;
+            InquireCandidatePosition();
+        }
         return mrConsume;
     }
     return mrDoDefault;
@@ -4084,14 +4093,14 @@
     return (HWND)NULL;
 }
 
-/* Call DefWindowProc for the focus proxy, if any */
+/* Redirects message to the focus proxy, if any */
 void AwtComponent::CallProxyDefWindowProc(UINT message, WPARAM wParam,
     LPARAM lParam, LRESULT &retVal, MsgRouting &mr)
 {
     if (mr != mrConsume)  {
         HWND proxy = GetProxyFocusOwner();
         if (proxy != NULL && ::IsWindowEnabled(proxy)) {
-            retVal = ComCtl32Util::GetInstance().DefWindowProc(NULL, proxy, message, wParam, lParam);
+            retVal = ::DefWindowProc(proxy, message, wParam, lParam);
             mr = mrConsume;
         }
     }
@@ -4170,7 +4179,7 @@
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     if (drawInfo.CtlType == ODT_MENU) {
-        if (drawInfo.itemData != 0) {
+        if (IsMenu((HMENU)drawInfo.hwndItem) && drawInfo.itemData != 0) {
             AwtMenu* menu = (AwtMenu*)(drawInfo.itemData);
             menu->DrawItem(drawInfo);
         }
--- a/src/windows/native/sun/windows/awt_Menu.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_Menu.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -34,6 +34,13 @@
 /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
  */
 
+/***********************************************************************/
+// struct for _DelItem() method
+struct DelItemStruct {
+    jobject menuitem;
+    jint index;
+};
+
 /************************************************************************
  * AwtMenuItem fields
  */
@@ -64,7 +71,6 @@
         ::DestroyMenu(m_hMenu);
         m_hMenu = NULL;
     }
-
     AwtMenuItem::Dispose();
 }
 
@@ -73,7 +79,7 @@
 }
 
 /* Create a new AwtMenu object and menu.   */
-AwtMenu* AwtMenu::Create(jobject self, AwtMenu* parentMenu)
+AwtMenu* AwtMenu::Create(jobject self, jobject parent)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
@@ -85,6 +91,9 @@
             return NULL;
         }
 
+        JNI_CHECK_NULL_GOTO(parent, "peer", done);
+        AwtMenu* parentMenu = (AwtMenu*) JNI_GET_PDATA(parent);
+
         target = env->GetObjectField(self, AwtObject::targetID);
         JNI_CHECK_NULL_GOTO(target, "null target", done);
 
@@ -119,6 +128,46 @@
     return menu;
 }
 
+void AwtMenu::_AddSeparator(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        jobject self = (jobject)param;
+        AwtMenu *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenu *)pData;
+        m->AddSeparator();
+ret:
+        env->DeleteGlobalRef(self);
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_AddSeparator, param);
+    }
+}
+
+void AwtMenu::_DelItem(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        DelItemStruct *dis = (DelItemStruct*) param;
+        jobject self = dis->menuitem;
+        jint index = dis->index;
+
+        AwtMenu *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenu *)pData;
+        m->DeleteItem(static_cast<UINT>(index));
+ret:
+        env->DeleteGlobalRef(self);
+        delete dis;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_DelItem, param);
+    }
+}
+
 void AwtMenu::UpdateLayout()
 {
     UpdateLayout(GetHMenu());
@@ -239,6 +288,7 @@
     }
     jobject menuItem = env->CallObjectMethod(target, AwtMenu::getItemMID,
                                              index);
+    if (!menuItem) return NULL; // menu item was removed concurrently
     DASSERT(!safe_ExceptionOccurred(env));
 
     jobject wMenuItemPeer = GetPeerForTarget(env, menuItem);
@@ -264,9 +314,9 @@
     }
     /* target is a java.awt.Menu */
     jobject target = GetTarget(env);
-
+    if(!target || env->ExceptionCheck()) return;
     int nCount = CountItem(target);
-    for (int i = 0; i < nCount; i++) {
+    for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
         AwtMenuItem* awtMenuItem = GetItem(target, i);
         if (awtMenuItem != NULL) {
             SendDrawItem(awtMenuItem, drawInfo);
@@ -294,8 +344,9 @@
     }
    /* target is a java.awt.Menu */
     jobject target = GetTarget(env);
+    if(!target || env->ExceptionCheck()) return;
     int nCount = CountItem(target);
-    for (int i = 0; i < nCount; i++) {
+    for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
         AwtMenuItem* awtMenuItem = GetItem(target, i);
         if (awtMenuItem != NULL) {
             SendMeasureItem(awtMenuItem, hDC, measureInfo);
@@ -321,24 +372,6 @@
     return (GetMenuBar() == GetMenuContainer());
 }
 
-LRESULT AwtMenu::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENU_ADDSEPARATOR:
-            this->AddSeparator();
-            break;
-
-        case MENU_DELITEM:
-            this->DeleteItem(static_cast<UINT>(args->param1));
-            break;
-
-        default:
-            AwtMenuItem::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 /************************************************************************
  * WMenuPeer native methods
  */
@@ -380,15 +413,14 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
+    jobject selfGlobalRef = env->NewGlobalRef(self);
 
-    AwtObject::WinThreadExec(self, AwtMenu::MENU_ADDSEPARATOR);
+    AwtToolkit::GetInstance().SyncCall(AwtMenu::_AddSeparator, selfGlobalRef);
+    // selfGlobalRef is deleted in _AddSeparator
 
     CATCH_BAD_ALLOC;
 }
 
-
 /*
  * Class:     sun_awt_windows_WMenuPeer
  * Method:    delItem
@@ -400,10 +432,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
+    DelItemStruct *dis = new DelItemStruct;
+    dis->menuitem = env->NewGlobalRef(self);
+    dis->index = index;
 
-    AwtObject::WinThreadExec(self, AwtMenu::MENU_DELITEM, index);
+    AwtToolkit::GetInstance().SyncCall(AwtMenu::_DelItem, dis);
+    // global refs and dis are deleted in _DelItem
 
     CATCH_BAD_ALLOC;
 }
@@ -419,13 +453,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(menuBar);
-
-    AwtMenuBar* awtMenuBar = (AwtMenuBar *)pData;
-    AwtToolkit::CreateComponent(self, awtMenuBar,
-                                (AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+    AwtToolkit::CreateComponent(self, menuBar,
+                                (AwtToolkit::ComponentFactory)AwtMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
@@ -441,13 +470,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(menu);
-
-    AwtMenu* awtMenu = (AwtMenu *)pData;
-    AwtToolkit::CreateComponent(self, awtMenu,
-                                (AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+    AwtToolkit::CreateComponent(self, menu,
+                                (AwtToolkit::ComponentFactory)AwtMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
--- a/src/windows/native/sun/windows/awt_Menu.h	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_Menu.h	Tue Apr 04 11:57:35 2017 -0700
@@ -42,13 +42,6 @@
 
 class AwtMenu : public AwtMenuItem {
 public:
-    // id's for methods executed on toolkit thread
-    enum {
-        MENU_ADDSEPARATOR = MENUITEM_LAST+1,
-        MENU_DELITEM,
-        MENU_LAST
-    };
-
     /* method ids for java.awt.Menu */
     static jmethodID countItemsMID;
     static jmethodID getItemMID;
@@ -61,7 +54,7 @@
     virtual LPCTSTR GetClassName();
 
     /* Create a new AwtMenu.  This must be run on the main thread. */
-    static AwtMenu* Create(jobject self, AwtMenu* parentMenu);
+    static AwtMenu* Create(jobject self, jobject parent);
 
     INLINE HMENU GetHMenu() { return m_hMenu; }
     INLINE void SetHMenu(HMENU hMenu) {
@@ -94,9 +87,9 @@
     void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
     void MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
-
     // invoked on Toolkit thread
+    static void _AddSeparator(void *param);
+    static void _DelItem(void *param);
     static void _CreateMenu(void *param);
     static void _CreateSubMenu(void *param);
     virtual BOOL IsSeparator() { return FALSE; }
--- a/src/windows/native/sun/windows/awt_MenuBar.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_MenuBar.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -30,6 +30,12 @@
  */
 
 /***********************************************************************/
+// struct for _DelItem() method
+struct DelItemStruct {
+    jobject menuitem;
+    jint index;
+};
+/***********************************************************************/
 // struct for _AddMenu() method
 struct AddMenuStruct {
     jobject menubar;
@@ -130,18 +136,6 @@
         return myFrame->GetHWnd();
 }
 
-void AwtMenuBar::SendDrawItem(AwtMenuItem* awtMenuItem,
-                              DRAWITEMSTRUCT& drawInfo)
-{
-    awtMenuItem->DrawItem(drawInfo);
-}
-
-void AwtMenuBar::SendMeasureItem(AwtMenuItem* awtMenuItem,
-                                 HDC hDC, MEASUREITEMSTRUCT& measureInfo)
-{
-    awtMenuItem->MeasureItem(hDC, measureInfo);
-}
-
 int AwtMenuBar::CountItem(jobject menuBar)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -159,13 +153,16 @@
     }
 
     jobject menu = env->CallObjectMethod(target, AwtMenuBar::getMenuMID,index);
+    if (!menu) return NULL; // menu item was removed concurrently
     DASSERT(!safe_ExceptionOccurred(env));
 
     jobject menuItemPeer = GetPeerForTarget(env, menu);
     PDATA pData;
-    JNI_CHECK_PEER_RETURN_NULL(menuItemPeer);
-    AwtMenuItem* awtMenuItem = (AwtMenuItem*)pData;
+    AwtMenuItem* awtMenuItem = NULL;
+    JNI_CHECK_PEER_GOTO(menuItemPeer, done);
+    awtMenuItem = (AwtMenuItem*)pData;
 
+done:
     env->DeleteLocalRef(menu);
     env->DeleteLocalRef(menuItemPeer);
 
@@ -212,20 +209,6 @@
     VERIFY(::DrawMenuBar(GetOwnerHWnd()));
 }
 
-LRESULT AwtMenuBar::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENUBAR_DELITEM:
-            this->DeleteItem(static_cast<UINT>(args->param1));
-            break;
-
-        default:
-            AwtMenu::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 void AwtMenuBar::_AddMenu(void *param)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -254,6 +237,28 @@
     delete ams;
 }
 
+void AwtMenuBar::_DelItem(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        DelItemStruct *dis = (DelItemStruct*) param;
+        jobject self = dis->menuitem;
+        jint index = dis->index;
+
+        AwtMenuBar *m = NULL;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenuBar *)pData;
+        m->DeleteItem(static_cast<UINT>(index));
+ret:
+        env->DeleteGlobalRef(self);
+        delete dis;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuBar::_DelItem, param);
+    }
+}
+
 /************************************************************************
  * MenuBar native methods
  */
@@ -322,9 +327,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuBar::MENUBAR_DELITEM, (LPARAM)index);
+    DelItemStruct *dis = new DelItemStruct;
+    dis->menuitem = env->NewGlobalRef(self);
+    dis->index = index;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuBar::_DelItem, dis);
+    // global refs and dis are deleted in _DelItem
 
     CATCH_BAD_ALLOC;
 }
@@ -343,9 +351,6 @@
     AwtToolkit::CreateComponent(self, frame,
                                 (AwtToolkit::ComponentFactory)
                                 AwtMenuBar::Create);
-    PDATA pData;
-    JNI_CHECK_PEER_CREATION_RETURN(self);
-
     CATCH_BAD_ALLOC;
 }
 
--- a/src/windows/native/sun/windows/awt_MenuBar.h	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_MenuBar.h	Tue Apr 04 11:57:35 2017 -0700
@@ -42,10 +42,6 @@
 
 class AwtMenuBar : public AwtMenu {
 public:
-    // id's for methods executed on toolkit thread
-    enum MenuExecIds {
-        MENUBAR_DELITEM = MENU_LAST+1
-    };
 
     /* java.awt.MenuBar method ids */
     static jmethodID getMenuCountMID;
@@ -73,20 +69,15 @@
     AwtMenuItem* GetItem(jobject target, long index);
     int CountItem(jobject menuBar);
 
-    void SendDrawItem(AwtMenuItem* awtMenuItem,
-                      DRAWITEMSTRUCT& drawInfo);
-    void SendMeasureItem(AwtMenuItem* awtMenuItem,
-                         HDC hDC, MEASUREITEMSTRUCT& measureInfo);
     void DrawItem(DRAWITEMSTRUCT& drawInfo);
     void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
 
     void AddItem(AwtMenuItem* item);
     void DeleteItem(UINT index);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
-
     // called on Toolkit thread
     static void _AddMenu(void *param);
+    static void _DelItem(void *param);
 protected:
     AwtFrame* m_frame;
 };
--- a/src/windows/native/sun/windows/awt_MenuItem.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_MenuItem.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -50,6 +50,16 @@
     jobject menuitem;
     jstring label;
 };
+// struct for _SetEnable() method
+struct SetEnableStruct {
+    jobject menuitem;
+    jboolean isEnabled;
+};
+// struct for _setState() method
+struct SetStateStruct {
+    jobject menuitem;
+    jboolean isChecked;
+};
 /************************************************************************
  * AwtMenuItem fields
  */
@@ -104,6 +114,7 @@
 {
     if (m_freeId) {
         AwtToolkit::GetInstance().RemoveCmdID( GetID() );
+        m_freeId = FALSE;
     }
 }
 void AwtMenuItem::Dispose()
@@ -112,6 +123,7 @@
 
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     if (m_peerObject != NULL) {
+        JNI_SET_DESTROYED(m_peerObject);
         JNI_SET_PDATA(m_peerObject, NULL);
         env->DeleteGlobalRef(m_peerObject);
         m_peerObject = NULL;
@@ -205,13 +217,12 @@
         if (env->EnsureLocalCapacity(1) < 0) {
             return NULL;
         }
-        PDATA pData;
-        JNI_CHECK_PEER_RETURN_NULL(menuPeer);
+        JNI_CHECK_NULL_RETURN_NULL(menuPeer, "peer");
 
         /* target is a java.awt.MenuItem  */
         target = env->GetObjectField(peer, AwtObject::targetID);
 
-        AwtMenu* menu = (AwtMenu *)pData;
+        AwtMenu* menu = (AwtMenu *)JNI_GET_PDATA(menuPeer);
         item = new AwtMenuItem();
         jboolean isCheckbox =
             (jboolean)env->GetBooleanField(peer, AwtMenuItem::isCheckboxID);
@@ -222,7 +233,9 @@
         item->LinkObjects(env, peer);
         item->SetMenuContainer(menu);
         item->SetNewID();
-        menu->AddItem(item);
+        if (menu != NULL) {
+            menu->AddItem(item);
+        }
     } catch (...) {
         env->DeleteLocalRef(target);
         throw;
@@ -763,30 +776,6 @@
     }
 }
 
-LRESULT AwtMenuItem::WinThreadExecProc(ExecuteArgs * args)
-{
-    switch( args->cmdId ) {
-        case MENUITEM_ENABLE:
-        {
-            BOOL        isEnabled = (BOOL)args->param1;
-            this->Enable(isEnabled);
-        }
-        break;
-
-        case MENUITEM_SETSTATE:
-        {
-            BOOL        isChecked = (BOOL)args->param1;
-            this->SetState(isChecked);
-        }
-        break;
-
-        default:
-            AwtObject::WinThreadExecProc(args);
-            break;
-    }
-    return 0L;
-}
-
 void AwtMenuItem::_SetLabel(void *param) {
     if (AwtToolkit::IsMainThread()) {
         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -886,6 +875,53 @@
     }
 }
 
+void AwtMenuItem::_SetEnable(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        SetEnableStruct *ses = (SetEnableStruct*) param;
+        jobject self = ses->menuitem;
+        jboolean isEnabled = ses->isEnabled;
+
+        AwtMenuItem *m = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+
+        m = (AwtMenuItem *)pData;
+
+        m->Enable(isEnabled);
+ret:
+        env->DeleteGlobalRef(self);
+        delete ses;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetEnable, param);
+    }
+}
+
+void AwtMenuItem::_SetState(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+        SetStateStruct *sts = (SetStateStruct*) param;
+        jobject self = sts->menuitem;
+        jboolean isChecked = sts->isChecked;
+
+        AwtMenuItem *m = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenuItem *)pData;
+        m->SetState(isChecked);
+ret:
+        env->DeleteGlobalRef(self);
+        delete sts;
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetState, param);
+    }
+}
 BOOL AwtMenuItem::IsSeparator() {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     if (env->EnsureLocalCapacity(2) < 0) {
@@ -1049,13 +1085,9 @@
 {
     TRY;
 
-    JNI_CHECK_NULL_RETURN(menu, "null Menu");
     AwtToolkit::CreateComponent(self, menu,
                                 (AwtToolkit::ComponentFactory)
                                 AwtMenuItem::Create);
-    PDATA pData;
-    JNI_CHECK_PEER_CREATION_RETURN(self);
-
     CATCH_BAD_ALLOC;
 }
 
@@ -1070,9 +1102,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_ENABLE, (LPARAM)on );
+    SetEnableStruct *ses = new SetEnableStruct;
+    ses->menuitem = env->NewGlobalRef(self);
+    ses->isEnabled = on;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetEnable, ses);
+    // global refs and ses are deleted in _SetEnable
 
     CATCH_BAD_ALLOC;
 }
@@ -1111,9 +1146,12 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(self);
-    AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_SETSTATE, (LPARAM)on);
+    SetStateStruct *sts = new SetStateStruct;
+    sts->menuitem = env->NewGlobalRef(self);
+    sts->isChecked = on;
+
+    AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetState, sts);
+    // global refs and sts are deleted in _SetState
 
     CATCH_BAD_ALLOC;
 }
--- a/src/windows/native/sun/windows/awt_MenuItem.h	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_MenuItem.h	Tue Apr 04 11:57:35 2017 -0700
@@ -45,13 +45,6 @@
 
 class AwtMenuItem : public AwtObject {
 public:
-    // id's for methods executed on toolkit thread
-    enum {
-        MENUITEM_ENABLE,
-        MENUITEM_SETSTATE,
-        MENUITEM_LAST
-    };
-
     /* java.awt.MenuComponent fields */
     static jfieldID fontID;
     static jfieldID appContextID;
@@ -154,13 +147,14 @@
      */
     MsgRouting WmNotify(UINT notifyCode);
 
-    virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
     virtual BOOL IsDisabledAndPopup() {
         return FALSE;
     }
     virtual BOOL IsSeparator();
 
     // invoked on Toolkit thread
+    static void _SetState(void *param);
+    static void _SetEnable(void *param);
     static void _SetLabel(void *param);
     static void _UpdateLayout(void *param);
 
--- a/src/windows/native/sun/windows/awt_PopupMenu.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_PopupMenu.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@
 }
 
 /* Create a new AwtPopupMenu object and menu.   */
-AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent)
+AwtPopupMenu* AwtPopupMenu::Create(jobject self, jobject parent)
 {
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
@@ -77,6 +77,9 @@
             return NULL;
         }
 
+        JNI_CHECK_NULL_GOTO(parent, "peer", done);
+        AwtComponent* awtParent = (AwtComponent*) JNI_GET_PDATA(parent);
+
         target = env->GetObjectField(self, AwtObject::targetID);
         JNI_CHECK_NULL_GOTO(target, "null target", done);
 
@@ -94,7 +97,7 @@
         popupMenu->SetHMenu(hMenu);
 
         popupMenu->LinkObjects(env, self);
-        popupMenu->SetParent(parent);
+        popupMenu->SetParent(awtParent);
     } catch (...) {
         env->DeleteLocalRef(target);
         throw;
@@ -274,12 +277,8 @@
 {
     TRY;
 
-    PDATA pData;
-    JNI_CHECK_PEER_RETURN(parent);
-    AwtComponent* awtParent = (AwtComponent *)pData;
     AwtToolkit::CreateComponent(
-        self, awtParent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create, FALSE);
-    JNI_CHECK_PEER_CREATION_RETURN(self);
+        self, parent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create);
 
     CATCH_BAD_ALLOC;
 }
--- a/src/windows/native/sun/windows/awt_PopupMenu.h	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_PopupMenu.h	Tue Apr 04 11:57:35 2017 -0700
@@ -47,7 +47,7 @@
     virtual LPCTSTR GetClassName();
 
     /* Create a new AwtPopupMenu.  This must be run on the main thread. */
-    static AwtPopupMenu* Create(jobject self, AwtComponent* parent);
+    static AwtPopupMenu* Create(jobject self, jobject parent);
 
     /* Display the popup modally. */
     void Show(JNIEnv *env, jobject event, BOOL isTrayIconPopup);
--- a/src/windows/native/sun/windows/awt_new.cpp	Mon Mar 27 08:22:23 2017 -0700
+++ b/src/windows/native/sun/windows/awt_new.cpp	Tue Apr 04 11:57:35 2017 -0700
@@ -172,6 +172,9 @@
             env->ExceptionClear();
             // rethrow exception
             env->Throw(xcp);
+            // temp solution to reveal all concurrency issues in jtreg and JCK
+            // we will switch it back to silent mode before the release
+            env->ExceptionDescribe();
             return xcp;
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 8079595
+   @summary Resizing dialog which is JWindow parent makes JVM crash
+   @author Semyon Sadetsky
+  */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+
+public class ShowChildWhileResizingTest {
+
+    private static Window dialog;
+    private static Timer timer;
+    private static Point point;
+
+    public static void main(String[] args) throws Exception {
+        dialog = new Frame();
+        dialog.add(new JPanel());
+        dialog.setVisible(true);
+        dialog.setBounds(100, 100, 200, 200);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                final Window dependentWindow = new JWindow(dialog);
+                JPanel panel = new JPanel();
+                panel.add(new JButton("button"));
+                dependentWindow.add(panel);
+                dependentWindow.setVisible(true);
+                dependentWindow.setBounds(0, 0, 50, 50);
+                timer = new Timer(100, new ActionListener() {
+                    @Override
+                    public void actionPerformed(ActionEvent e) {
+                        dependentWindow
+                                .setVisible(!dependentWindow.isVisible());
+                    }
+                });
+                timer.start();
+            }
+
+        });
+
+        Robot robot = new Robot();
+        robot.setAutoDelay(5);
+        robot.delay(300);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                point = dialog.getLocationOnScreen();
+            }
+        });
+        robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,
+                point.y + 200 - dialog.getInsets().bottom/2);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        for(int i = 0; i < 100; i++) {
+            robot.mouseMove(point.x + 200 + i, point.y + 200 + i);
+        }
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        timer.stop();
+        dialog.dispose();
+        System.out.println("ok");
+    }
+}
--- a/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Tue Apr 04 11:57:35 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,11 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Set;
+import java.util.List;
 import java.util.concurrent.atomic.LongAdder;
 
 import sun.misc.ObjectInputFilter;
@@ -155,26 +156,33 @@
         Runnable runnable = (Runnable & Serializable) SerialFilterTest::noop;
         Object[][] objects = {
                 { null, 0, -1, 0, 0, 0,
-                        new HashSet<>()},        // no callback, no values
-                { objArray, 3, 7, 8, 2, 55,
-                        new HashSet<>(Arrays.asList(objArray.getClass()))},
-                { Object[].class, 1, -1, 1, 1, 40,
-                        new HashSet<>(Arrays.asList(Object[].class))},
-                { new SerialFilterTest(), 1, -1, 1, 1, 37,
-                        new HashSet<>(Arrays.asList(SerialFilterTest.class))},
-                { new LongAdder(), 2, -1, 1, 1, 93,
-                        new HashSet<>(Arrays.asList(LongAdder.class, serClass))},
-                { new byte[14], 2, 14, 1, 1, 27,
-                        new HashSet<>(Arrays.asList(byteArray.getClass()))},
-                { runnable, 13, 0, 10, 2, 514,
-                        new HashSet<>(Arrays.asList(java.lang.invoke.SerializedLambda.class,
+                        Arrays.asList()},        // no callback, no values
+                { objArray, 3, 7, 9, 2, 55,
+                        Arrays.asList(objArray.getClass(), objArray.getClass())},
+                { Object[].class, 1, -1, 1, 1, 38,
+                        Arrays.asList(Object[].class)},
+                { new SerialFilterTest(), 1, -1, 1, 1, 35,
+                        Arrays.asList(SerialFilterTest.class)},
+                { new LongAdder(), 2, -1, 2, 1, 93,
+                        Arrays.asList(serClass, LongAdder.class)},
+                { new byte[14], 2, 14, 2, 1, 27,
+                        Arrays.asList(byteArray.getClass(), byteArray.getClass())},
+                { runnable, 13, 0, 13, 2, 514,
+                        Arrays.asList(java.lang.invoke.SerializedLambda.class,
+                                objArray.getClass(),
+                                objArray.getClass(),
                                 SerialFilterTest.class,
-                                objArray.getClass()))},
-                { deepHashSet(10), 48, -1, 49, 11, 619,
-                        new HashSet<>(Arrays.asList(HashSet.class))},
-                { proxy.getClass(), 3, -1, 1, 1, 114,
-                        new HashSet<>(Arrays.asList(Runnable.class,
-                                java.lang.reflect.Proxy.class))},
+                                java.lang.invoke.SerializedLambda.class)},
+                { deepHashSet(10), 48, -1, 50, 11, 619,
+                        Arrays.asList(HashSet.class)},
+                { proxy.getClass(), 3, -1, 2, 2, 112,
+                        Arrays.asList(Runnable.class,
+                                java.lang.reflect.Proxy.class,
+                                java.lang.reflect.Proxy.class)},
+                { new F(), 6, -1, 6, 6, 202,
+                        Arrays.asList(F.class, E.class, D.class,
+                                C.class, B.class, A.class)},
+
         };
         return objects;
     }
@@ -213,11 +221,12 @@
     @Test(dataProvider="Objects")
     public static void t1(Object object,
                           long count, long maxArray, long maxRefs, long maxDepth, long maxBytes,
-                          Set<Class<?>> classes) throws IOException {
+                          List<Class<?>> classes) throws IOException {
         byte[] bytes = writeObjects(object);
         Validator validator = new Validator();
         validate(bytes, validator);
         System.out.printf("v: %s%n", validator);
+
         Assert.assertEquals(validator.count, count, "callback count wrong");
         Assert.assertEquals(validator.classes, classes, "classes mismatch");
         Assert.assertEquals(validator.maxArray, maxArray, "maxArray mismatch");
@@ -411,7 +420,7 @@
      */
     static class Validator implements ObjectInputFilter {
         long count;          // Count of calls to checkInput
-        HashSet<Class<?>> classes = new HashSet<>();
+        List<Class<?>> classes = new ArrayList<>();
         long maxArray = -1;
         long maxRefs;
         long maxDepth;
@@ -422,16 +431,20 @@
 
         @Override
         public ObjectInputFilter.Status checkInput(FilterInfo filter) {
+            Class<?> serialClass = filter.serialClass();
+            System.out.printf("     checkInput: class: %s, arrayLen: %d, refs: %d, depth: %d, bytes; %d%n",
+                    serialClass, filter.arrayLength(), filter.references(),
+                    filter.depth(), filter.streamBytes());
             count++;
-            if (filter.serialClass() != null) {
-                if (filter.serialClass().getName().contains("$$Lambda$")) {
+            if (serialClass != null) {
+                if (serialClass.getName().contains("$$Lambda$")) {
                     // TBD: proper identification of serialized Lambdas?
                     // Fold the serialized Lambda into the SerializedLambda type
                     classes.add(SerializedLambda.class);
-                } else if (Proxy.isProxyClass(filter.serialClass())) {
+                } else if (Proxy.isProxyClass(serialClass)) {
                     classes.add(Proxy.class);
                 } else {
-                    classes.add(filter.serialClass());
+                    classes.add(serialClass);
                 }
 
             }
@@ -591,7 +604,8 @@
             // a stream of exactly the size requested.
             return genMaxBytesObject(allowed, value);
         } else if (pattern.startsWith("maxrefs=")) {
-            Object[] array = new Object[allowed ? (int)value - 1 : (int)value];
+            // 4 references to classes in addition to the array contents
+            Object[] array = new Object[allowed ? (int)value - 4 : (int)value - 3];
             for (int i = 0; i < array.length; i++) {
                 array[i] = otherObject;
             }
@@ -740,4 +754,25 @@
             return streamBytes;
         }
     }
+
+    // Deeper superclass hierarchy
+    static class A implements Serializable {
+        private static final long serialVersionUID = 1L;
+    };
+    static class B extends A {
+        private static final long serialVersionUID = 2L;
+    }
+    static class C extends B {
+        private static final long serialVersionUID = 3L;
+    }
+    static class D extends C {
+        private static final long serialVersionUID = 4L;
+    }
+    static class E extends D {
+        private static final long serialVersionUID = 5L;
+    }
+    static class F extends E {
+        private static final long serialVersionUID = 6L;
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Thread/ITLConstructor.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Basic test for Thread(ThreadGroup,Runnable,String,long,boolean)
+ */
+
+import sun.misc.SharedSecrets;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class ITLConstructor {
+    static InheritableThreadLocal<Integer> n = new InheritableThreadLocal<Integer>() {
+        protected Integer initialValue() {
+            return 0;
+        }
+
+        protected Integer childValue(Integer parentValue) {
+            return parentValue + 1;
+        }
+    };
+
+    static final int CHILD_THREAD_COUNT = 10;
+
+    public static void main(String args[]) throws Exception {
+        test();
+    }
+
+    static void test() throws Exception {
+        // concurrent access to separate indexes is ok
+        int[] x = new int[CHILD_THREAD_COUNT];
+        Thread child = createThread(new AnotherRunnable(0, x));
+        child.start();
+        child.join(); // waits for *all* threads to complete
+
+        // Check results
+        for(int i=0; i<CHILD_THREAD_COUNT; i++) {
+            int expectedValue = 1;
+            if (x[i] != expectedValue)
+                throw (new Exception("Got x[" + i + "] = " + x[i]
+                                     + ", expected: " + expectedValue));
+        }
+    }
+
+    static class AnotherRunnable implements Runnable {
+        final int threadId;
+        final int[] x;
+        AnotherRunnable(int threadId, int[] x) {
+            this.threadId = threadId;
+            this.x = x;
+        }
+
+        public void run() {
+            int itlValue = n.get();
+
+            if (threadId < CHILD_THREAD_COUNT-1) {
+                Thread child = createThread(
+                        new AnotherRunnable(threadId+1, x));
+                child.start();
+                try {
+                    child.join();
+                } catch(InterruptedException e) {
+                    throw(new RuntimeException("Interrupted", e));
+                }
+            }
+
+            x[threadId] = itlValue+1;
+        }
+    }
+
+    static Thread createThread(final Runnable r) {
+        final AccessControlContext acc = AccessController.getContext();
+        // 4290486: doPrivileged is needed to create a thread in
+        // an environment that restricts "modifyThreadGroup".
+        return AccessController.doPrivileged(
+                new PrivilegedAction<Thread>() {
+                    public Thread run() {
+                        return SharedSecrets.getJavaLangAccess()
+                                .newThreadWithAcc(r, acc);
+                    }
+                }
+        );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/regtesthelpers/JRobot.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JRobot is a wrapper around java.awt.Robot that provides some convenience
+ * methods.
+ * <p>When using jtreg you would include this class via something like:
+ * <pre>
+ * @library ../../../regtesthelpers
+ * @build JRobot
+ * </pre>
+ *
+ */
+import java.awt.AWTException;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.SwingUtilities;
+
+public class JRobot extends java.awt.Robot {
+    private static int DEFAULT_DELAY = 550;
+    private static int INTERNAL_DELAY = 250;
+
+    private int delay;
+    private boolean delaysEnabled;
+
+    protected JRobot(boolean enableDelays) throws AWTException {
+        super();
+        delaysEnabled = enableDelays;
+        setAutoWaitForIdle(enableDelays);
+        if (enableDelays) {
+            setAutoDelay(INTERNAL_DELAY);
+            setDelay(DEFAULT_DELAY);
+        }
+    }
+
+    /**
+     * Return a JRobot. Delays are enabled by default.
+     * @return a JRobot
+     */
+    public static JRobot getRobot() {
+        return getRobot(true);
+    }
+
+    /**
+     * Create a JRobot. The parameter controls whether delays are enabled.
+     * @param enableDelays controls whether delays are enabled.
+     * @return a JRobot
+     */
+    public static JRobot getRobot(boolean enableDelays) {
+        JRobot robot = null;
+        try {
+            robot = new JRobot(enableDelays);
+        } catch (AWTException e) {
+            System.err.println("Coudn't create Robot, details below");
+            throw new Error(e);
+        }
+        return robot;
+    }
+
+    /**
+     * Press and release a key.
+     * @param keycode which key to press. For example, KeyEvent.VK_DOWN
+     */
+    public void hitKey(int keycode) {
+        keyPress(keycode);
+        keyRelease(keycode);
+        delay();
+    }
+
+    /**
+     * Press and release a key with modifiers.
+     * @param keys keys to press. Keys are pressed in order they are passed as
+     * parameters to this method. All keys except the last one are considered
+     * modifiers. For example, to press Ctrl+Shift+T, call:
+     * hitKey(KeyEvent.VK_CONTROL, KeyEvent.VK_SHIFT, KeyEvent.VK_T);
+     */
+    public void hitKey(int... keys) {
+        for (int i = 0; i < keys.length; i++) {
+            keyPress(keys[i]);
+        }
+
+        for (int i = keys.length - 1; i >= 0; i--) {
+            keyRelease(keys[i]);
+        }
+        delay();
+    }
+
+    /**
+     * Move mouse cursor to the center of the Component.
+     * @param c Component the mouse is placed over
+     */
+    public void moveMouseTo(Component c) {
+        Point p = c.getLocationOnScreen();
+        Dimension size = c.getSize();
+        p.x += size.width / 2;
+        p.y += size.height / 2;
+        mouseMove(p.x, p.y);
+        delay();
+    }
+
+    /**
+     * Move mouse smoothly from (x0, y0) to (x1, y1).
+     */
+    public void glide(int x0, int y0, int x1, int y1) {
+        float dmax = (float)Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0));
+        float dx = (x1 - x0) / dmax;
+        float dy = (y1 - y0) / dmax;
+
+        mouseMove(x0, y0);
+        for (int i=1; i<=dmax; i++) {
+            mouseMove((int)(x0 + dx*i), (int)(y0 + dy*i));
+        }
+        delay();
+    }
+
+    /**
+     * Perform a mouse click, i.e. press and release mouse button(s).
+     * @param buttons mouse button(s).
+     *                For example, MouseEvent.BUTTON1_MASK
+     */
+    public void clickMouse(int buttons) {
+        mousePress(buttons);
+        mouseRelease(buttons);
+        delay();
+    }
+
+    /**
+     * Perform a click with the first mouse button.
+     */
+    public void clickMouse() {
+        clickMouse(InputEvent.BUTTON1_MASK);
+    }
+
+    /**
+     * Click in the center of the given Component
+     * @param c the Component to click on
+     * @param buttons mouse button(s).
+     */
+    public void clickMouseOn(Component c, int buttons) {
+        moveMouseTo(c);
+        clickMouse(buttons);
+    }
+
+    /**
+     * Click the first mouse button in the center of the given Component
+     * @param c the Component to click on
+     */
+    public void clickMouseOn(Component c) {
+        clickMouseOn(c, InputEvent.BUTTON1_MASK);
+    }
+
+    /**
+     * Return whether delays are enabled
+     * @return whether delays are enabled
+     */
+    public boolean getDelaysEnabled() {
+        return delaysEnabled;
+    }
+
+    /**
+     * Delay execution by delay milliseconds
+     */
+    public void delay() {
+        delay(delay);
+    }
+
+    /**
+     * Return the delay amount, in milliseconds
+     */
+    public int getDelay() {
+        return delay;
+    }
+
+    /**
+     * Set the delay amount, in milliseconds
+     */
+    public void setDelay(int delay) {
+        this.delay = delay;
+    }
+
+    /**
+     * Waits until all events currently on the event queue have been processed.
+     * Does nothing if called on EDT
+     */
+    public synchronized void waitForIdle() {
+        if (!EventQueue.isDispatchThread()) {
+            super.waitForIdle();
+        }
+    }
+
+    /**
+     * Calculate the center of the Rectangle passed, and return them
+     * in a Point object.
+     * @param r a non-null Rectangle
+     * @return a new Point object containing coordinates of r's center
+     */
+    public Point centerOf(Rectangle r) {
+        return new Point(r.x + r.width / 2, r.y + r.height / 2);
+    }
+
+    /**
+     * Calculate the center of the Rectangle passed, and store it in p.
+     * @param r a non-null Rectangle
+     * @param p a non-null Point that receives coordinates of r's center
+     * @return p
+     */
+    public Point centerOf(Rectangle r, Point p) {
+        p.x = r.x + r.width / 2;
+        p.y = r.y + r.height / 2;
+        return p;
+    }
+
+    /**
+     * Convert a rectangle from coordinate system of Component c to
+     * screen coordinate system.
+     * @param r a non-null Rectangle
+     * @param c a Component whose coordinate system is used for conversion
+     */
+    public void convertRectToScreen(Rectangle r, Component c) {
+        Point p = new Point(r.x, r.y);
+        SwingUtilities.convertPointToScreen(p, c);
+        r.x = p.x;
+        r.y = p.y;
+    }
+
+    /**
+     * Compares two rectangles pixel-by-pixel.
+     * @param r0 the first area
+     * @param r1 the second area
+     * return true if all pixels in the two areas are identical
+     */
+    public boolean compareRects(Rectangle r0, Rectangle r1) {
+        int xShift = r1.x - r0.x;
+        int yShift = r1.y - r0.y;
+
+        for (int y = r0.y; y < r0.y + r0.height; y++) {
+            for (int x = r0.x; x < r0.x + r0.width; x++) {
+                if (!comparePixels(x, y, x + xShift, y + yShift)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Compares colors of two points on the screen.
+     * @param p0 the first point
+     * @param p1 the second point
+     * return true if the two points have the same color
+     */
+    public boolean comparePixels(Point p0, Point p1) {
+        return comparePixels(p0.x, p0.y, p1.x, p1.y);
+    }
+
+    /**
+     * Compares colors of two points on the screen.
+     * @param x0 the x coordinate of the first point
+     * @param y0 the y coordinate of the first point
+     * @param x1 the x coordinate of the second point
+     * @param y1 the y coordinate of the second point
+     * return true if the two points have the same color
+     */
+    public boolean comparePixels(int x0, int y0, int x1, int y1) {
+        return (getPixelColor(x0, y0).equals(getPixelColor(x1, y1)));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/regtesthelpers/SwingTestHelper.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,862 @@
+/*
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+import javax.swing.*;
+
+/**
+ * SwingTestHelper is a utility class for writing AWT/Swing regression
+ * tests that require interacting with the UI.  Typically such tests
+ * consist of executing a chunk of code, waiting on an event, executing
+ * more code ...  This is painful in that you typically have to use various
+ * invokeLaters and threading to handle that interaction.  SwingTestHelper
+ * strealines this process.
+ * <p>
+ * SwingTestHelper uses reflection to invoke all methods starting with
+ * the name <code>onEDT</code> on the EDT and all methods starting with
+ * <code>onBackgroundThread</code> on a background thread.  Between each method
+ * invocation all pending events on the EDT are processed.  The methods
+ * are first sorted based on an integer after the method names and invoked
+ * in that order.  For example, the following subclass:
+ * <pre>
+ * class Test extends SwingTestHelper {
+ *   private void onEDT10();
+ *   private void onBackgroundThread20();
+ *   private void onBackgroundThread30();
+ *   private void onEDT40();
+ *   private void onBackgroundThread50();
+ * }
+ * </pre>
+ * Will have the methods invoked in the order <code>onEDT10</code>,
+ * <code>onBackgroundThread20</code>, <code>onBackgroundThread30</code>,
+ * <code>onEDT40</code>, <code>onBackgroundThread50</code>.
+ * <p>
+ * If you're not happy with method mangling you can also use annotations.
+ * The following gives the same result as the previous example:
+ * <pre>
+ * class Test extends SwingTestHelper {
+ *   &#064;Test(10)
+ *   private void foo(); // Was onEDT10
+ *
+ *   &#064;Test(value=20, onEDT=false)
+ *   private void bar(); // Was onBackgroundThread20
+ *
+ *   &#064;Test(value=30, onEDT=false)
+ *   private void baz(); // Was onBackgroundThread30
+ *
+ *   &#064;Test(40)
+ *   private void zed(); // Was onEDT40
+ *
+ *   &#064;Test(value=50, onEDT=false)
+ *   private void onBackgroundThread50(); // Was onBackgroundThread50
+ * }
+ * </pre>
+ * <p>
+ * It is recommended that you increment the value in increments of
+ * 10.  This makes it easier to add methods at a later date without
+ * having to change all method names/annotations after the newly added
+ * method.
+ * <p>
+ * Between each of the methods, all pending events (native and Java)
+ * are processed.
+ * <p>
+ * Failure of the test is signaled by any method throwing
+ * an exception, directly invoking <code>fail</code> or one of the
+ * <code>assert</code> variants.  If no methods throw an exception the test is
+ * assumed to have passed.
+ * <p>
+ * Often times it is necessary to block until focus has been gained on a
+ * particular widget.  This can be handled by the
+ * <code>requestAndWaitForFocus</code> method.  It will invoke
+ * <code>requestFocus</code> and block the test (not the EDT) until focus
+ * has been granted to the widget.
+ * <p>
+ * Care must be taken when using <code>Robot</code> directly.  For
+ * example, it's tempting to flood <code>Robot</code> with events and
+ * assume they will be received after some delay.  Depending upon the
+ * machine you may need to increase the delay.  Instead it's
+ * preferrable to block test execution until the event has been
+ * received and processed.  This can be done using the method
+ * <code>waitForEvent</code>.  For example, to block until a key typed
+ * event has been processed do the following:
+ * <pre>
+ *   private void onEDT() {
+ *     robot.moveMouseTo(myComponent);
+ *     robot.mousePress(xxx);
+ *     robot.mouseRelease(xxx);
+ *     waitForEvent(myComponent, MouseEvent.MOUSE_RELEASED);
+ *   }
+ * </pre>
+ * <p>
+ * Waiting for focus and events are specific examples of a more
+ * general problem.  Often times you need the EDT to continue processing
+ * events, but want to block test execution until something happens.
+ * In the case of focus you want to block test execution until focus
+ * is gained.  The method <code>waitForCondition</code> can be used to
+ * block test execution until the supplied <code>Runnable</code> returns.  The
+ * <code>Runnable</code> is invoked on the background thread.
+ * <p>
+ * To use this class you will need to do the following:
+ * <ol>
+ * <li>Override the method <code>createContentPane</code>.  All of your logic
+ *     for setting up the test environment should go here.  This method is
+ *     invoked on the EDT.
+ * <li>Implement the necessary <code>onEDTXX</code> and
+ *     <code>onBackgroundThreadXXX</code> methods to do the actual testing.
+ * <li>Make your <code>main</code> method look like:
+ *     <code>new MySwingTestHelper().run(args)</code>.  This will block
+ *     until the test fails or succeeds.
+ * <li>To use this with jtreg you'll need to have something like:
+ *   <pre>
+ *     &#064;library ../../../regtesthelpers
+ *     &#064;build Test JRobot Assert SwingTestHelper
+ *     &#064;run main MySwingTestHelper
+ *     * </pre>
+ * </ol>
+ * <p>
+ * Here's a complete example:
+ * <pre>
+ * public class bug4852305 extends SwingTestHelper {
+ *     private JTable table;
+ *
+ *     public static void main(String[] args) throws Throwable {
+ *         new bug4852305().run(args);
+ *     }
+ *
+ *     protected Component createContentPane() {
+ *         DefaultTableModel model = new DefaultTableModel(1, 2);
+ *         model.setValueAt("x", 0, 0);
+ *         model.setValueAt("z", 0, 1);
+ *         table = new JTable(model);
+ *         table.setDefaultEditor(Object.class, new DefaultCellEditor(new JTextField()) {
+ *             public boolean isCellEditable(EventObject anEvent) {
+ *                 if ((anEvent instanceof KeyEvent) ||
+ *                         (anEvent instanceof ActionEvent)) {
+ *                     return false;
+ *                 }
+ *                 return true;
+ *             }
+ *         });
+ *         return new JScrollPane(table);
+ *     }
+ *
+ *     private void onEDT10() {
+ *         requestAndWaitForFocus(table);
+ *     }
+ *
+ *     private void onEDT20() {
+ *         robot.keyPress(KeyEvent.VK_A);
+ *         robot.keyRelease(KeyEvent.VK_A);
+ *         waitForEvent(table, KeyEvent.KEY_RELEASED);
+ *     }
+ *
+ *     private void onEDT30() {
+ *         if (table.isEditing()) {
+ *             fail("Should not be editing");
+ *         }
+ *     }
+ * }
+ * </pre>
+ *
+ *
+ * @author Scott Violet
+ */
+public abstract class SwingTestHelper {
+    private static final String ON_EDT_METHOD_NAME = "onEDT";
+    private static final String IN_BACKGROUND_METHOD_NAME = "onBackgroundThread";
+
+    // Whether or not we've installed a PropertyChangeListener on the
+    // KeyboardFocusManager
+    private boolean installedFocusListener;
+    // Component currently blocking on until focus has been received.
+    private Component componentWaitingForFocus;
+
+    // Set to true when done.
+    private boolean done;
+    // If failed, this gives the exception.  Only the first exception is
+    // kept.
+    private Throwable error;
+
+    // List of methods to invoke
+    private java.util.List<Method> methods;
+
+    // The conditions the background thread is blocked on.
+    private java.util.List<Runnable> conditions;
+
+    // Whether or not we've installed the AWTEventListener
+    private boolean installedEventListener;
+
+    /**
+     * Instance of <code>Robot</code> returned from <code>createRobot</code>.
+     */
+    protected JRobot robot;
+
+    /**
+     * <code>Window</code> returned from <code>createWindow</code>.
+     */
+    protected Window window;
+
+    // Listens for the first paint event
+    private AWTEventListener paintListener;
+    // Whether or not we've received a paint event.
+    private boolean receivedFirstPaint;
+
+    // used if the user wants to slow down method processing
+    private PauseCondition delay = null;
+
+    private boolean showProgress;
+    private JProgressBar progBar;
+
+
+    public SwingTestHelper() {
+        paintListener = new AWTEventListener() {
+            public void eventDispatched(AWTEvent ev) {
+                if ((ev.getID() & PaintEvent.PAINT) != 0 &&
+                        ev.getSource() == window) {
+                    synchronized(SwingTestHelper.this) {
+                        if (receivedFirstPaint) {
+                            return;
+                        }
+                        receivedFirstPaint = true;
+                    }
+                    Toolkit.getDefaultToolkit().removeAWTEventListener(
+                                   paintListener);
+                    startControlLoop();
+                }
+            }
+        };
+        Toolkit.getDefaultToolkit().addAWTEventListener(
+            paintListener, AWTEvent.PAINT_EVENT_MASK);
+    }
+
+    /**
+     * Sets whether SwingTestHelper should use {@code SunToolkit.realSync}
+     * to wait for events to finish, or {@code Robot.waitForIdle}. The default
+     * is to use realSync.
+     * Nov 2014: no realSync any more, just robot.waitForIdle which actually
+     * _is_ realSync on all platforms but OS X (and thus cannot be used on EDT).
+     */
+    public void setUseRealSync(boolean useRealSync) {
+        //NOOP
+    }
+
+    /**
+     * Set the amount of time to delay between invoking methods in
+     * the control loop. Useful to slow down testing.
+     */
+    protected void setDelay(int delay) {
+        if (delay <= 0) {
+            this.delay = null;
+        } else {
+            this.delay = new PauseCondition(delay);
+        }
+    }
+
+    /**
+     * Sets whether or not progress through the list of methods is
+     * shown by a progress bar at the bottom of the window created
+     * by {@code createWindow}.
+     */
+    protected void setShowProgress(boolean showProgress) {
+        this.showProgress = showProgress;
+    }
+
+    /**
+     * Creates and returns the <code>Window</code> for the test.  This
+     * implementation returns a JFrame with a default close operation
+     * of <code>EXIT_ON_CLOSE</code>.  The <code>Component</code>
+     * returned from <code>createContentPane</code> is added the
+     * <code>JFrame</code> and the the frame is packed.
+     * <p>
+     * Typically you only need override <code>createContentPane</code>.
+     */
+    protected Window createWindow() {
+        JFrame frame = new JFrame("Test: " + getClass().getName());
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.add(createContentPane());
+        if (showProgress) {
+            progBar = new JProgressBar();
+            progBar.setString("");
+            progBar.setStringPainted(true);
+            frame.add(progBar, BorderLayout.SOUTH);
+        }
+        frame.pack();
+        return frame;
+    }
+
+    /**
+     * Returns the <code>Component</code> to place in the frame.
+     * Override this or the <code>createWindow</code> method.
+     */
+    protected Component createContentPane() {
+        return null;
+    }
+
+    /**
+     * Invokes <code>requestFocus</code> on the passed in component (assuming
+     * it doesn't already have focus).  Test execution is blocked until focus
+     * has been gained on the component.  This method <b>must</b> be invoked
+     * on the EDT, if you do not invoke it from the edt the test will fail.
+     *
+     * @param c the <code>Component</code> to wait for focus on
+     */
+    protected void requestAndWaitForFocus(Component c) {
+        requestAndWaitForFocus(c, true);
+    }
+
+    /**
+     * Blocks test execution until focus is gained on the component.
+     * This method <b>must</b> be invoked
+     * on the EDT, if you do not invoke it from the edt the test will fail.
+     */
+    protected void waitForFocusGained(Component c) {
+        requestAndWaitForFocus(c, false);
+    }
+
+    private void requestAndWaitForFocus(Component c, boolean requestFocus) {
+        if (!EventQueue.isDispatchThread()) {
+            System.out.println(
+                "requestAndWaitForFocus should be invoked on EDT");
+            throw new RuntimeException();
+        }
+        if (componentWaitingForFocus != null) {
+            System.out.println("Already waiting for focus");
+            throw new RuntimeException();
+        }
+        if (!installedFocusListener) {
+            installedFocusListener = true;
+            KeyboardFocusManager.getCurrentKeyboardFocusManager().
+                addPropertyChangeListener(new FocusListener());
+        }
+        synchronized(this) {
+            if (c.hasFocus()) {
+                return;
+            }
+            componentWaitingForFocus = c;
+        }
+        if (requestFocus) {
+            c.requestFocus();
+        }
+        waitForCondition(new FocusCondition());
+    }
+
+    /**
+     * Blocks test execution until the specified event has been received.
+     * This method immediately returns and the EDT will continue to
+     * process events, but test execution is blocked until
+     * the event is received.
+     *
+     * @param event the event type to wait for
+     */
+    protected void waitForEvent(int event) {
+        waitForEvent(null, event);
+    }
+
+    /**
+     * Blocks test execution until the specified event has been received.
+     * This method immediately returns and the EDT will continue to
+     * process events, but test execution is blocked until
+     * the event is received.
+     *
+     * @param target the <code>Component</code> to wait for the event on;
+     *               <code>null</code> indicates it does not matter which
+     *               component the event is received on
+     * @param event the event type to wait for
+     */
+    protected void waitForEvent(Component target, int event) {
+        waitForCondition(new EventCondition(target, event));
+        if (!installedEventListener) {
+            installedEventListener = true;
+            Toolkit.getDefaultToolkit().addAWTEventListener(
+                    new EventListener(), 0xFFFFFFFFFFFFFFFFl);
+        }
+    }
+
+    /**
+     * Paused test execution for the specified amount of time.  The caller
+     * immediately returns and the EDT can process events.
+     *
+     * @param time the amount of time, in milliseconds, to pause for
+     */
+    protected void pause(int time) {
+        waitForCondition(new PauseCondition(time));
+    }
+
+    /**
+     * Schedules a <code>Runnable</code> that will be processed in the
+     * background thread.  This method immediately returns, and the
+     * EDT is free to continue processing events. Test execution is
+     * blocked until the <code>Runnable</code> completes.
+     */
+    protected void waitForCondition(Runnable runnable) {
+        synchronized(this) {
+            if (conditions == null) {
+                conditions = new LinkedList<Runnable>();
+            }
+            conditions.add(runnable);
+        }
+    }
+
+    /**
+     * Runs the test.  This method blocks the caller until the test
+     * fails or succeeds. Recognized arguments are:
+     * <p>
+     * "-exit": Causes main to exit when the test is done.
+     * "-showProg": Indicate the progress of the test with a
+     *              progress bar in the main window. Only works
+     *              if the test hasn't overridden {@code createWindow}.
+     * "-delay int": Sets the delay between executing methods.
+     *               Useful when you want to slow a test to watch it.
+     *
+     * @param args the arguments from main, it's ok to pass in null
+     */
+    protected final void run(String[] args) throws Throwable {
+        boolean exit = false;
+        if (args != null) {
+            for (int i = 0; i < args.length; i++) {
+                if (args[i].equals("-exit")) {
+                    exit = true;
+                } else if (args[i].equals("-delay")) {
+                    try {
+                        setDelay(Integer.parseInt(args[++i]));
+                    } catch (NumberFormatException ne) {
+                        throw new RuntimeException("-delay requires an integer value");
+                    } catch (ArrayIndexOutOfBoundsException ae) {
+                        throw new RuntimeException("-delay requires an integer value");
+                    }
+                } else if (args[i].equals("-showProg")) {
+                    setShowProgress(true);
+                } else {
+                    throw new RuntimeException("Invalid argument \"" + args[i] + "\"");
+                }
+            }
+        }
+
+        createWindow0();
+        synchronized(this) {
+            while(!done) {
+                wait();
+            }
+        }
+        if (exit) {
+            // Not in harness
+            if (error != null) {
+                System.out.println("FAILED: " + error);
+                error.printStackTrace();
+            }
+            System.exit(0);
+        }
+        if (error != null) {
+            throw error;
+        }
+    }
+
+    /**
+     * Creates the window, on the EDT.
+     */
+    private void createWindow0() {
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                window = createWindow();
+                window.show();
+            }
+        });
+    }
+
+    /**
+     * Initializes the progress bar if necessary.
+     */
+    private void initProgressBar(final int size) {
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                if (progBar != null) {
+                    progBar.setMaximum(size);
+                }
+            }
+        });
+    }
+
+    /**
+     * Starst the control loop.
+     */
+    private void startControlLoop() {
+        robot = createRobot();
+        if (robot != null) {
+            calculateMethods();
+            initProgressBar(methods.size());
+            new Thread(new Runnable() {
+                public void run() {
+                    controlLoop();
+                }
+            }).start();
+        }
+    }
+
+    /**
+     * Increment the progress bar.
+     */
+    private void nextProgress(final String name) {
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                if (progBar != null) {
+                    progBar.setString(name);
+                    progBar.setValue(progBar.getValue() + 1);
+                }
+            }
+        });
+    }
+
+    private synchronized Runnable currentCondition() {
+        if (conditions != null && conditions.size() > 0) {
+            return conditions.get(0);
+        }
+        return null;
+    }
+
+    private synchronized Runnable nextCondition() {
+        return conditions.remove(0);
+    }
+
+    private void controlLoop() {
+        int methodIndex = 0;
+        while (methodIndex < methods.size()) {
+            // Wait for any pending conditions
+            Runnable condition;
+            while ((condition = currentCondition()) != null) {
+                try {
+                    condition.run();
+                } catch (Exception e) {
+                    fail(e);
+                    return;
+                }
+                waitForEDTToFinish();
+                synchronized(this) {
+                    if (done) {
+                        return;
+                    }
+                }
+                // Advance to next condition
+                nextCondition();
+            }
+
+            // Let all events on the EDT finish
+            waitForEDTToFinish();
+
+            if (delay != null) {
+                delay.run();
+            }
+
+            // Invoke the next method
+            Method method = methods.get(methodIndex++);
+            Test test = method.getAnnotation(Test.class);
+            boolean onEDT = true;
+            if (test != null) {
+                onEDT = test.onEDT();
+            }
+            else if (!method.getName().startsWith(ON_EDT_METHOD_NAME)) {
+                onEDT = false;
+            }
+            if (onEDT) {
+                invokeOnEDT(method);
+            }
+            else {
+                invoke(method);
+            }
+
+            // Let all events on the EDT finish
+            waitForEDTToFinish();
+
+            nextProgress(method.getName());
+
+            // If done, stop.
+            synchronized(this) {
+                if (done) {
+                    return;
+                }
+            }
+        }
+
+        // No more methods, if we get and done isn't true, set it true
+        // so that the main thread wakes up.
+        synchronized(this) {
+            if (!done) {
+                done = true;
+                notifyAll();
+            }
+        }
+    }
+
+    private void waitForEDTToFinish() {
+            robot.waitForIdle();
+        }
+
+    private void invokeOnEDT(final Method method) {
+        try {
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                    invoke(method);
+                }
+            });
+        } catch (InvocationTargetException ite) {
+            fail(ite);
+        } catch (InterruptedException ie) {
+            fail(ie);
+        }
+    }
+
+    private void invoke(Method method) {
+        System.out.println("invoking: " + method.getName());
+        try {
+            if (Modifier.isPrivate(method.getModifiers())) {
+                method.setAccessible(true);
+            }
+            method.invoke(this);
+        } catch (Exception e) {
+            fail(e);
+        }
+    }
+
+    // Determines the methods to execute.
+    private void calculateMethods() {
+        // Using a Set avoids duplicating methods returned by both
+        // getMethods() and getDeclaredMethods().
+        HashSet<Method> allMethods = new HashSet<Method>();
+        allMethods.addAll(Arrays.asList(getClass().getMethods()));
+        allMethods.addAll(Arrays.asList(getClass().getDeclaredMethods()));
+
+        methods = new ArrayList<Method>();
+        for (Method method : allMethods) {
+            Test test = method.getAnnotation(Test.class);
+            if (test != null) {
+                methods.add(method);
+            }
+            else if (method.getName().startsWith(ON_EDT_METHOD_NAME)) {
+                methods.add(method);
+            }
+            else if (method.getName().startsWith(IN_BACKGROUND_METHOD_NAME)) {
+                methods.add(method);
+            }
+        }
+        Comparator<Method> comparator = new Comparator<Method>() {
+            public int compare(Method m1, Method m2) {
+                int index1 = getIndex(m1);
+                int index2 = getIndex(m2);
+                return index1 - index2;
+            }
+            private int getIndex(Method m) {
+                String name = m.getName();
+                String indexAsString;
+                Test test = m.getAnnotation(Test.class);
+                if (test != null) {
+                    return test.value();
+                }
+                if (name.startsWith(ON_EDT_METHOD_NAME)) {
+                    indexAsString = name.substring(
+                            ON_EDT_METHOD_NAME.length());
+                }
+                else {
+                    indexAsString = name.substring(
+                            IN_BACKGROUND_METHOD_NAME.length());
+                }
+                if (indexAsString.length() == 0) {
+                    System.out.println(
+                            "onEDT and onBackgroundThread must be " +
+                            "followed by an integer specifying " +
+                            "order.");
+                    System.exit(0);
+                }
+                return Integer.parseInt(indexAsString);
+            }
+        };
+        Collections.sort(methods, comparator);
+    }
+
+    /**
+     * Invoke if the test should be considered to have failed.  This will
+     * stop test execution.
+     */
+    public void fail(String reason) {
+        fail(new RuntimeException(reason));
+    }
+
+    /**
+     * Invoke if the test should be considered to have failed.  This will
+     * stop test execution.
+     */
+    public void fail(Throwable error) {
+        synchronized(this) {
+            if (this.error == null) {
+                if (error instanceof InvocationTargetException) {
+                    this.error = ((InvocationTargetException)error).
+                            getCause();
+                }
+                else {
+                    this.error = error;
+                }
+                this.done = true;
+                notifyAll();
+            }
+        }
+    }
+
+    /**
+     * Invoke to prematurely stop test execution while there are remaining
+     * methods.  You typically don't invoke this, instead if all methods have
+     * been executed and fail hasn't been invoked, the test is considered to
+     * have passed.
+     */
+    public void succeeded() {
+        synchronized(this) {
+            this.done = true;
+            notifyAll();
+        }
+    }
+
+    /**
+     * Creates and returns the Robot that will be used.  You generally don't
+     * need to override this.
+     */
+    protected JRobot createRobot() {
+        JRobot robot = JRobot.getRobot(false);
+        return robot;
+    }
+
+
+    private class FocusListener implements PropertyChangeListener {
+        public void propertyChange(PropertyChangeEvent e) {
+            if (componentWaitingForFocus != null &&
+                    "focusOwner".equals(e.getPropertyName()) &&
+                    componentWaitingForFocus == e.getNewValue()) {
+                synchronized(SwingTestHelper.this) {
+                    componentWaitingForFocus = null;
+                    SwingTestHelper.this.notifyAll();
+                }
+            }
+        }
+    }
+
+
+    private class EventCondition implements Runnable {
+        private Component component;
+        private int eventID;
+        private boolean received;
+
+        EventCondition(Component component, int eventID) {
+            this.component = component;
+            this.eventID = eventID;
+        }
+
+        public int getEventID() {
+            return eventID;
+        }
+
+        public Component getComponent() {
+            return component;
+        }
+
+        public void received() {
+            synchronized(SwingTestHelper.this) {
+                this.received = true;
+                SwingTestHelper.this.notifyAll();
+            }
+        }
+
+        public boolean isWaiting() {
+            return !received;
+        }
+
+        public void run() {
+            synchronized(SwingTestHelper.this) {
+                while (!received) {
+                    try {
+                        SwingTestHelper.this.wait();
+                    } catch (InterruptedException ie) {
+                        fail(ie);
+                    }
+                }
+            }
+        }
+    }
+
+
+    private class FocusCondition implements Runnable {
+        public void run() {
+            synchronized(SwingTestHelper.this) {
+                while (componentWaitingForFocus != null) {
+                    try {
+                        SwingTestHelper.this.wait();
+                    } catch (InterruptedException ie) {
+                        fail(ie);
+                    }
+                }
+            }
+        }
+    }
+
+
+    private class PauseCondition implements Runnable {
+        private int time;
+        PauseCondition(int time) {
+            this.time = time;
+        }
+        public void run() {
+            try {
+                Thread.sleep(time);
+            } catch (InterruptedException ie) {
+                fail(ie);
+            }
+        }
+    }
+
+
+    private class EventListener implements AWTEventListener {
+        public void eventDispatched(AWTEvent ev) {
+            int eventID = ev.getID();
+            synchronized (SwingTestHelper.this) {
+                for (Runnable condition : conditions) {
+                    if (condition instanceof EventCondition) {
+                        EventCondition ec = (EventCondition)condition;
+                        if (ec.isWaiting()) {
+                            if (eventID == ec.getEventID() &&
+                                    (ec.getComponent() == null ||
+                                     ev.getSource() == ec.getComponent())) {
+                                ec.received();
+                            }
+                            return;
+                        }
+                    }
+                    else {
+                        return;
+                    }
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/regtesthelpers/Test.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Test {
+    int value();
+    boolean onEDT() default true;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/text/FlowView/LayoutTest.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6452106 6606443 8161195
+   @author Peter Zhelezniakov
+   @library ../../regtesthelpers
+   @build Test JRobot SwingTestHelper
+   @run main/timeout=300 LayoutTest
+*/
+
+import javax.swing.text.*;
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class LayoutTest extends SwingTestHelper {
+    JTextPane text;
+
+    public static void main(String[] args) throws Throwable {
+        new LayoutTest().run(args);
+    }
+
+    protected Component createContentPane() {
+        return text = new JTextPane();
+    }
+
+    @Test(value=10, onEDT=true)
+    private void onEDT10() {
+        requestAndWaitForFocus(text);
+    }
+
+
+    @Test(value=100, onEDT=true)
+    private void prepare6452106() {
+        text.setText("This is easily generated on my\nmachine");
+        Document doc = text.getDocument();
+
+        // wrap the long paragraph
+        Dimension d = text.getPreferredSize();
+        Dimension size = new Dimension(d.width * 2 / 3, d.height * 5);
+        window.setSize(size);
+
+        // place caret at the end of 2nd line
+        Element p1 = doc.getDefaultRootElement().getElement(0);
+        int pos = p1.getEndOffset();
+        text.setCaretPosition(pos - 1);
+    }
+
+    @Test(value=110, onEDT=false)
+    private void test6452106() {
+        robot.setDelay(300);
+        robot.hitKey(KeyEvent.VK_DELETE);
+        robot.hitKey(KeyEvent.VK_SPACE);
+        robot.hitKey(KeyEvent.VK_SPACE);
+    }
+
+
+    @Test(value=200, onEDT=true)
+    private void prepare6606443() {
+        text.setText("This is easily\ngenerated\non my machine");
+        text.setSelectionStart(15);
+        text.setSelectionEnd(24);
+    }
+
+    @Test(value=210, onEDT=false)
+    private void test6606443() {
+        robot.hitKey(KeyEvent.VK_ENTER);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/net/ftp/FtpURLConnectionLeak.java	Tue Apr 04 11:57:35 2017 -0700
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7167293
+ * @summary FtpURLConnection doesn't close FTP connection when FileNotFoundException is thrown
+ * @library ../www/ftptest/
+ * @build FtpServer FtpCommandHandler FtpAuthHandler FtpFileSystemHandler
+ * @run main FtpURLConnectionLeak
+ */
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+public class FtpURLConnectionLeak {
+
+    public static void main(String[] args) throws Exception {
+        FtpServer server = new FtpServer(0);
+        server.setFileSystemHandler(new CustomFileSystemHandler("/"));
+        server.setAuthHandler(new MyAuthHandler());
+        int port = server.getLocalPort();
+        server.start();
+        URL url = new URL("ftp://localhost:" + port + "/filedoesNotExist.txt");
+        for (int i = 0; i < 3; i++) {
+            try {
+                InputStream stream = url.openStream();
+            } catch (FileNotFoundException expectedFirstTimeAround) {
+                // should always reach this point since the path does not exist
+            } catch (IOException expected) {
+                System.out.println("caught expected " + expected);
+                int times = 1;
+                do {
+                    // give some time to close the connection...
+                    System.out.println("sleeping... " + times);
+                    Thread.sleep(times * 1000);
+                } while (server.activeClientsCount() > 0 && times++ < 5);
+
+                if (server.activeClientsCount() > 0) {
+                    server.killClients();
+                    throw new RuntimeException("URLConnection didn't close the" +
+                            " FTP connection on FileNotFoundException");
+                }
+            } finally {
+                server.terminate();
+            }
+        }
+    }
+
+    static class CustomFileSystemHandler implements FtpFileSystemHandler {
+
+        private String currentDir;
+
+        public CustomFileSystemHandler(String path) {
+            currentDir = path;
+        }
+
+        @Override
+        public boolean cd(String path) {
+            currentDir = path;
+            return true;
+        }
+
+        @Override
+        public boolean cdUp() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public String pwd() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public boolean fileExists(String name) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public InputStream getFile(String name) {
+            return null; //return null so that server will return 550 File not found.
+        }
+
+        @Override
+        public long getFileSize(String name) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public InputStream listCurrentDir() {
+            return null;
+        }
+
+        @Override
+        public OutputStream putFile(String name) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public boolean removeFile(String name) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public boolean mkdir(String name) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public boolean rename(String from, String to) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+    }
+
+    static class MyAuthHandler implements FtpAuthHandler {
+
+        @Override
+        public int authType() {
+            return 0;
+        }
+
+        @Override
+        public boolean authenticate(String user, String password) {
+            return true;
+        }
+
+        @Override
+        public boolean authenticate(String user, String password, String account) {
+            return true;
+        }
+    }
+}
--- a/test/sun/security/tools/jarsigner/TimestampCheck.java	Mon Mar 27 08:22:23 2017 -0700
+++ b/test/sun/security/tools/jarsigner/TimestampCheck.java	Tue Apr 04 11:57:35 2017 -0700
@@ -60,7 +60,7 @@
 
 /*
  * @test
- * @bug 6543842 6543440 6939248 8009636 8024302 8163304 8169911 8169688
+ * @bug 6543842 6543440 6939248 8009636 8024302 8163304 8169911 8169688 8171121
  * @summary checking response of timestamp
  * @modules java.base/sun.security.pkcs
  *          java.base/sun.security.timestamp