changeset 13335:0a89388f0b97 icedtea-3.8.0pre01

Merge jdk8u162-b12
author andrew
date Thu, 15 Mar 2018 03:52:16 +0000
parents 21e003963667 (current diff) ddae5cb11d6c (diff)
children 39bfc94b1f42
files .hgtags src/macosx/native/sun/awt/AWTView.m src/macosx/native/sun/osxapp/NSApplicationAWT.m src/share/bin/java.c src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java src/share/classes/java/awt/DefaultKeyboardFocusManager.java src/share/classes/java/awt/EventDispatchThread.java src/share/classes/java/awt/EventQueue.java src/share/classes/java/lang/ref/Finalizer.java src/share/classes/java/time/temporal/ValueRange.java src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java src/share/classes/sun/font/GlyphLayout.java src/share/classes/sun/font/TrueTypeFont.java src/share/classes/sun/management/Agent.java src/share/classes/sun/print/RasterPrinterJob.java src/share/classes/sun/security/pkcs11/Config.java src/share/classes/sun/security/ssl/SSLSocketImpl.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/solaris/native/java/lang/java_props_md.c src/windows/native/sun/windows/awt_Component.cpp test/TEST.groups test/java/lang/SecurityManager/CheckPackageAccess.java test/java/net/Authenticator/B4769350.java test/java/util/logging/AnonLoggerWeakRefLeak.java test/java/util/logging/AnonLoggerWeakRefLeak.sh test/java/util/logging/LoggerWeakRefLeak.java test/java/util/logging/LoggerWeakRefLeak.sh test/sun/tools/common/CommonTests.sh
diffstat 89 files changed, 3008 insertions(+), 1499 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Mar 07 05:37:58 2018 +0000
+++ b/.hgtags	Thu Mar 15 03:52:16 2018 +0000
@@ -884,3 +884,20 @@
 80cebaab0ba5da02658fb21eabb38b111a2e2c32 icedtea-3.7.0
 80cebaab0ba5da02658fb21eabb38b111a2e2c32 icedtea-3.8.0pre00
 aa2c9ce0663291af00f15b816882080833f4d0ed icedtea-4-branchpoint
+76f2c555cccab8df114dd6ebb8ed7634c7ce1896 jdk8u161-b12
+e03f9868f7df1e3db537f3b61704658e8a9dafb5 jdk8u162-b00
+538bdf24383954cd2356e39e8081c2cb3ac27281 jdk8u162-b01
+18e0bc77adafd0e5e459e381b6993bb0625b05be jdk8u162-b02
+e1e7eee76e15fd386fd22b556c916635b4e113ab jdk8u162-b03
+4c4efa8fa39ae0fe73638eeeb84546da4d010aef jdk8u162-b04
+a651df33d9a07d9fc4411de4854e9528d8708a6f jdk8u162-b05
+582c82cfebe262f2934e3577dc8809ec8acbbd87 jdk8u162-b06
+672bbe9bcdd79a72308e21dd67f560d4fe806f49 jdk8u162-b07
+672bbe9bcdd79a72308e21dd67f560d4fe806f49 jdk8u162-b07
+0000000000000000000000000000000000000000 jdk8u162-b07
+0000000000000000000000000000000000000000 jdk8u162-b07
+fce5b32117cc0b06acc2bcaa364ac62539d42707 jdk8u162-b07
+c9254e01820639526f803dbe05080fce0d33db98 jdk8u162-b08
+1aa2e6ec537c3dd0fd4f9780f16da3e38fb18cee jdk8u162-b09
+1d2ee5e60df1c3bc889c92154d839bfe73077f66 jdk8u162-b10
+95df717479b19f5ea244afc67434827f2f851287 jdk8u162-b11
--- a/src/aix/native/sun/tools/attach/AixVirtualMachine.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/aix/native/sun/tools/attach/AixVirtualMachine.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2015 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -26,6 +26,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
+#include "jvm.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -184,15 +185,26 @@
             res = errno;
         }
 
-        /* release p here before we throw an I/O exception */
-        if (isCopy) {
-            JNU_ReleaseStringPlatformChars(env, path, p);
-        }
-
         if (res == 0) {
-            if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
-                 ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
-                JNU_ThrowIOException(env, "well-known file is not secure");
+            char msg[100];
+            jboolean isError = JNI_FALSE;
+            if (sb.st_uid != uid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
+                isError = JNI_TRUE;
+            } else if (sb.st_gid != gid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
+                isError = JNI_TRUE;
+            } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
+                isError = JNI_TRUE;
+            }
+            if (isError) {
+                char buf[256];
+                jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
+                JNU_ThrowIOException(env, buf);
             }
         } else {
             char* msg = strdup(strerror(res));
@@ -201,6 +213,10 @@
                 free(msg);
             }
         }
+
+        if (isCopy) {
+            JNU_ReleaseStringPlatformChars(env, path, p);
+        }
     }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/macosx/classes/sun/font/CCompositeGlyphMapper.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,155 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.font;
+
+public final class CCompositeGlyphMapper extends CompositeGlyphMapper {
+
+    private CompositeFont font;
+    private CharToGlyphMapper slotMappers[];
+
+    public CCompositeGlyphMapper(CompositeFont compFont) {
+        super(compFont);
+        font = compFont;
+        slotMappers = new CharToGlyphMapper[font.numSlots];
+        missingGlyph = 0;
+    }
+
+    private CharToGlyphMapper getSlotMapper(int slot) {
+        CharToGlyphMapper mapper = slotMappers[slot];
+        if (mapper == null) {
+            mapper = font.getSlotFont(slot).getMapper();
+            slotMappers[slot] = mapper;
+        }
+        return mapper;
+    }
+
+    public boolean canDisplay(char ch) {
+        int glyph = charToGlyph(ch);
+        return glyph != missingGlyph;
+    }
+
+    private int convertToGlyph(int unicode) {
+        for (int slot = 0; slot < font.numSlots; slot++) {
+            CharToGlyphMapper mapper = getSlotMapper(slot);
+            int glyphCode = mapper.charToGlyph(unicode);
+            // The CFont Mappers will return a negative code
+            // for fonts that will fill the glyph from fallbacks
+            // - cascading font in OSX-speak. But we need to be
+            //  know here that only the codes > 0 are really present.
+            if (glyphCode > 0) {
+                glyphCode = compositeGlyphCode(slot, glyphCode);
+                return glyphCode;
+            }
+        }
+        return missingGlyph;
+    }
+
+    public int getNumGlyphs() {
+        int numGlyphs = 0;
+        for (int slot=0; slot<1 /*font.numSlots*/; slot++) {
+           CharToGlyphMapper mapper = slotMappers[slot];
+           if (mapper == null) {
+               mapper = font.getSlotFont(slot).getMapper();
+               slotMappers[slot] = mapper;
+           }
+           numGlyphs += mapper.getNumGlyphs();
+        }
+        return numGlyphs;
+    }
+
+    public int charToGlyph(int unicode) {
+        return convertToGlyph(unicode);
+    }
+
+    public int charToGlyph(char unicode) {
+        return convertToGlyph(unicode);
+    }
+
+    public boolean charsToGlyphsNS(int count, char[] unicodes, int[] glyphs) {
+
+        for (int i=0; i<count; i++) {
+            int code = unicodes[i]; // char is unsigned.
+
+            if (code >= HI_SURROGATE_START &&
+                code <= HI_SURROGATE_END && i < count - 1) {
+                char low = unicodes[i + 1];
+
+                if (low >= LO_SURROGATE_START &&
+                    low <= LO_SURROGATE_END) {
+                    code = (code - HI_SURROGATE_START) *
+                        0x400 + low - LO_SURROGATE_START + 0x10000;
+                    glyphs[i + 1] = INVISIBLE_GLYPH_ID;
+                }
+            }
+
+            glyphs[i] = convertToGlyph(code);
+
+            if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
+                continue;
+            }
+            else if (FontUtilities.isComplexCharCode(code)) {
+                return true;
+            }
+            else if (code >= 0x10000) {
+                i += 1; // Empty glyph slot after surrogate
+                continue;
+            }
+        }
+
+        return false;
+    }
+
+    public void charsToGlyphs(int count, char[] unicodes, int[] glyphs) {
+        for (int i=0; i<count; i++) {
+            int code = unicodes[i]; // char is unsigned.
+
+            if (code >= HI_SURROGATE_START &&
+                code <= HI_SURROGATE_END && i < count - 1) {
+                char low = unicodes[i + 1];
+
+                if (low >= LO_SURROGATE_START &&
+                    low <= LO_SURROGATE_END) {
+                    code = (code - HI_SURROGATE_START) *
+                        0x400 + low - LO_SURROGATE_START + 0x10000;
+
+                    glyphs[i] = convertToGlyph(code);
+                    i += 1; // Empty glyph slot after surrogate
+                    glyphs[i] = INVISIBLE_GLYPH_ID;
+                    continue;
+                }
+            }
+
+            glyphs[i] = convertToGlyph(code);
+        }
+    }
+
+    public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) {
+        for (int i=0; i<count; i++) {
+             glyphs[i] = convertToGlyph(unicodes[i]);
+        }
+    }
+
+}
--- a/src/macosx/classes/sun/font/CFont.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/classes/sun/font/CFont.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,13 @@
 import java.awt.geom.GeneralPath;;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
 
 // Right now this class is final to avoid a problem with native code.
 // For some reason the JNI IsInstanceOf was not working correctly
 // so we are checking the class specifically. If we subclass this
 // we need to modify the native code in CFontWrapper.m
-public final class CFont extends PhysicalFont {
+public final class CFont extends PhysicalFont implements FontSubstitution {
 
     /* CFontStrike doesn't call these methods so they are unimplemented.
      * They are here to meet the requirements of PhysicalFont, needed
@@ -76,6 +77,20 @@
        throw new InternalError("Not implemented");
     }
 
+    @Override
+    protected long getLayoutTableCache() {
+        return getLayoutTableCacheNative(getNativeFontPtr());
+    }
+
+    @Override
+    protected byte[] getTableBytes(int tag) {
+        return getTableBytesNative(getNativeFontPtr(), tag);
+    }
+
+    private native synchronized long getLayoutTableCacheNative(long nativeFontPtr);
+
+    private native byte[] getTableBytesNative(long nativeFontPtr, int tag);
+
     private static native long createNativeFont(final String nativeFontName,
                                                 final int style);
     private static native void disposeNativeFont(final long nativeFontPtr);
@@ -179,10 +194,55 @@
     protected synchronized long getNativeFontPtr() {
         if (nativeFontPtr == 0L) {
             nativeFontPtr = createNativeFont(nativeFontName, style);
-}
+        }
         return nativeFontPtr;
     }
 
+    static native void getCascadeList(long nativeFontPtr, ArrayList<String> listOfString);
+
+    private CompositeFont createCompositeFont() {
+        ArrayList<String> listOfString = new ArrayList<String>();
+        getCascadeList(nativeFontPtr, listOfString);
+
+        // add JRE "Lucida Sans Regular" to the cascade list to enable fallback
+        // to happen to this JRE font in case the intended glyph is missing in
+        // fonts provided in the CoreText provided cascaded list
+        listOfString.add("Lucida Sans Regular");
+        FontManager fm = FontManagerFactory.getInstance();
+        int numFonts = 1 + listOfString.size();
+        PhysicalFont[] fonts = new PhysicalFont[numFonts];
+        fonts[0] = this;
+        int idx = 1;
+        for (String s : listOfString) {
+            if (s.equals(".AppleSymbolsFB"))  {
+                // Don't know why we get the weird name above .. replace.
+                s = "AppleSymbols";
+            }
+            Font2D f2d = fm.findFont2D(s, Font.PLAIN, FontManager.NO_FALLBACK);
+            if (f2d == null || f2d == this) {
+                continue;
+            }
+            fonts[idx++] = (PhysicalFont)f2d;
+        }
+        if (idx < fonts.length) {
+            PhysicalFont[] orig = fonts;
+            fonts = new PhysicalFont[idx];
+            System.arraycopy(orig, 0, fonts, 0, idx);
+        }
+        CompositeFont compFont = new CompositeFont(fonts);
+        compFont.mapper = new CCompositeGlyphMapper(compFont);
+        return compFont;
+    }
+
+    private CompositeFont compFont;
+
+    public CompositeFont getCompositeFont2D() {
+        if (compFont == null) {
+           compFont = createCompositeFont();
+        }
+        return compFont;
+    }
+
     protected synchronized void finalize() {
         if (nativeFontPtr != 0) {
             disposeNativeFont(nativeFontPtr);
--- a/src/macosx/classes/sun/font/CStrike.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/classes/sun/font/CStrike.java	Thu Mar 15 03:52:16 2018 +0000
@@ -31,7 +31,7 @@
 
 import sun.awt.SunHints;
 
-public final class CStrike extends FontStrike {
+public final class CStrike extends PhysicalStrike {
 
     // Creates the native strike
     private static native long createNativeStrikePtr(long nativeFontPtr,
--- a/src/macosx/native/sun/awt/AWTView.m	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/awt/AWTView.m	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -284,7 +284,7 @@
     // Allow TSM to look at the event and potentially send back NSTextInputClient messages.
     [self interpretKeyEvents:[NSArray arrayWithObject:event]];
 
-    if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod]) {
+    if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && fInputMethodLOCKABLE) {
         fProcessingKeystroke = NO;
         if (!fInPressAndHold) {
             fInPressAndHold = YES;
@@ -980,6 +980,13 @@
         // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
         fKeyEventsNeeded = NO;
     }
+    else {
+        // Need to set back the fKeyEventsNeeded flag so that the string following the
+        // marked text is not ignored by keyDown
+        if (utf16Length > 0 || utf8Length > 0) {
+            fKeyEventsNeeded = YES;
+        }
+    }
 
     fPAHNeedsToSelect = NO;
 
--- a/src/macosx/native/sun/awt/LWCToolkit.m	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/awt/LWCToolkit.m	Thu Mar 15 03:52:16 2018 +0000
@@ -57,7 +57,7 @@
     return eventCount;
 }
 
-+ (void) eventCountPlusPlus{    
++ (void) eventCountPlusPlus{
     eventCount++;
 }
 
@@ -131,24 +131,34 @@
 JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue
 (JNIEnv *env, jobject self, jlong timeout)
 {
-    int currentEventNum = [AWTToolkit getEventCount];
+    long currentEventNum = [AWTToolkit getEventCount];
 
     NSApplication* sharedApp = [NSApplication sharedApplication];
     if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) {
         NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp;
-        [theApp postDummyEvent];
-        [theApp waitForDummyEvent];
+        // We use two different API to post events to the application,
+        //  - [NSApplication postEvent]
+        //  - CGEventPost(), see CRobot.m
+        // It was found that if we post an event via CGEventPost in robot and
+        // immediately after this we will post the second event via
+        // [NSApp postEvent] then sometimes the second event will be handled
+        // first. The opposite isn't proved, but we use both here to be safer.
+        [theApp postDummyEvent:false];
+        [theApp waitForDummyEvent:timeout / 2.0];
+        [theApp postDummyEvent:true];
+        [theApp waitForDummyEvent:timeout / 2.0];
+
     } else {
         // could happen if we are embedded inside SWT application,
-        // in this case just spin a single empty block through 
+        // in this case just spin a single empty block through
         // the event loop to give it a chance to process pending events
         [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}];
     }
-    
+
     if (([AWTToolkit getEventCount] - currentEventNum) != 0) {
         return JNI_TRUE;
     }
-        
+
     return JNI_FALSE;
 }
 
@@ -323,7 +333,7 @@
                                              beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]];
         if (processEvents) {
             //We do not spin a runloop here as date is nil, so does not matter which mode to use
-            // Processing all events excluding NSApplicationDefined which need to be processed 
+            // Processing all events excluding NSApplicationDefined which need to be processed
             // on the main loop only (those events are intended for disposing resources)
             NSEvent *event;
             if ((event = [NSApp nextEventMatchingMask:(NSAnyEventMask & ~NSApplicationDefinedMask)
--- a/src/macosx/native/sun/font/AWTFont.h	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/font/AWTFont.h	Thu Mar 15 03:52:16 2018 +0000
@@ -26,6 +26,8 @@
 #import <Cocoa/Cocoa.h>
 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
 
+#import "fontscalerdefs.h"
+
 #define MAX_STACK_ALLOC_GLYPH_BUFFER_SIZE 256
 
 @interface AWTFont : NSObject {
@@ -33,6 +35,7 @@
     NSFont    *fFont;
     CGFontRef  fNativeCGFont;
     BOOL       fIsFakeItalic;
+    TTLayoutTableCache* layoutTableCache;
 }
 
 + (AWTFont *) awtFontForName:(NSString *)name
--- a/src/macosx/native/sun/font/AWTFont.m	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/font/AWTFont.m	Thu Mar 15 03:52:16 2018 +0000
@@ -42,10 +42,33 @@
     if (self) {
         fFont = [font retain];
         fNativeCGFont = CTFontCopyGraphicsFont((CTFontRef)font, NULL);
+        layoutTableCache = NULL;
     }
     return self;
 }
 
+static TTLayoutTableCache* newCFontLayoutTableCache() {
+  TTLayoutTableCache* ltc = calloc(1, sizeof(TTLayoutTableCache));
+  if (ltc) {
+    int i;
+    for(i=0;i<LAYOUTCACHE_ENTRIES;i++) {
+      ltc->entries[i].len = -1;
+    }
+  }
+  return ltc;
+}
+
+static void freeCFontLayoutTableCache(TTLayoutTableCache* ltc) {
+  if (ltc) {
+    int i;
+    for(i=0;i<LAYOUTCACHE_ENTRIES;i++) {
+      if(ltc->entries[i].ptr) free (ltc->entries[i].ptr);
+    }
+    if (ltc->kernPairs) free(ltc->kernPairs);
+    free(ltc);
+  }
+}
+
 - (void) dealloc {
     [fFont release];
     fFont = nil;
@@ -53,6 +76,10 @@
     if (fNativeCGFont) {
         CGFontRelease(fNativeCGFont);
     fNativeCGFont = NULL;
+    if (layoutTableCache != NULL) {
+        freeCFontLayoutTableCache(layoutTableCache);
+        layoutTableCache = NULL;
+    }
     }
 
     [super dealloc];
@@ -63,6 +90,10 @@
         CGFontRelease(fNativeCGFont);
     fNativeCGFont = NULL;
     }
+    if (layoutTableCache != NULL) {
+        freeCFontLayoutTableCache(layoutTableCache);
+        layoutTableCache = NULL;
+    }
     [super finalize];
 }
 
@@ -391,6 +422,95 @@
 
 /*
  * Class:     sun_font_CFont
+ * Method:    getPlatformFontPtrNative
+ * Signature: (JI)[B
+ */
+JNIEXPORT jlong JNICALL
+Java_sun_font_CFont_getCGFontPtrNative
+    (JNIEnv *env, jclass clazz,
+     jlong awtFontPtr)
+{
+    AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
+    return (jlong)(awtFont->fNativeCGFont);
+}
+
+/*
+ * Class:     sun_font_CFont
+ * Method:    getLayoutTableCacheNative
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_sun_font_CFont_getLayoutTableCacheNative
+    (JNIEnv *env, jclass clazz,
+     jlong awtFontPtr)
+{
+    AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
+    if (awtFont->layoutTableCache == NULL) {
+        awtFont->layoutTableCache = newCFontLayoutTableCache();
+    }
+    return (jlong)(awtFont->layoutTableCache);
+}
+
+/*
+ * Class:     sun_font_CFont
+ * Method:    getTableBytesNative
+ * Signature: (JI)[B
+ */
+JNIEXPORT jbyteArray JNICALL
+Java_sun_font_CFont_getTableBytesNative
+    (JNIEnv *env, jclass clazz,
+     jlong awtFontPtr, jint jtag)
+{
+    jbyteArray jbytes = NULL;
+JNF_COCOA_ENTER(env);
+
+    CTFontTableTag tag = (CTFontTableTag)jtag;
+    int i, found = 0;
+    AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
+    NSFont* nsFont = awtFont->fFont;
+    CTFontRef ctfont = (CTFontRef)nsFont;
+    CFArrayRef tagsArray =
+        CTFontCopyAvailableTables(ctfont, kCTFontTableOptionNoOptions);
+    CFIndex numTags = CFArrayGetCount(tagsArray);
+    for (i=0; i<numTags; i++) {
+        if (tag ==
+            (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tagsArray, i)) {
+            found = 1;
+            break;
+        }
+    }
+    CFRelease(tagsArray);
+    if (!found) {
+        return NULL;
+    }
+    CFDataRef table = CTFontCopyTable(ctfont, tag, kCTFontTableOptionNoOptions);
+    if (table == NULL) {
+        return NULL;
+    }
+
+    char *tableBytes = (char*)(CFDataGetBytePtr(table));
+    size_t tableLength = CFDataGetLength(table);
+    if (tableBytes == NULL || tableLength == 0) {
+        CFRelease(table);
+        return NULL;
+    }
+
+    jbytes = (*env)->NewByteArray(env, (jsize)tableLength);
+    if (jbytes == NULL) {
+        return NULL;
+    }
+    (*env)->SetByteArrayRegion(env, jbytes, 0,
+                               (jsize)tableLength,
+                               (jbyte*)tableBytes);
+    CFRelease(table);
+
+JNF_COCOA_EXIT(env);
+
+    return jbytes;
+}
+
+/*
+ * Class:     sun_font_CFont
  * Method:    initNativeFont
  * Signature: (Ljava/lang/String;I)J
  */
@@ -506,3 +626,42 @@
 {
 }
 #endif
+
+/*
+ * Class:     sun_awt_FontDescriptor
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_font_CFont_getCascadeList
+    (JNIEnv *env, jclass cls, jlong awtFontPtr, jobject arrayListOfString)
+{
+    jclass alc = (*env)->FindClass(env, "java/util/ArrayList");
+    if (alc == NULL) return;
+    jmethodID addMID = (*env)->GetMethodID(env, alc, "add", "(Ljava/lang/Object;)Z");
+    if (addMID == NULL) return;
+
+    CFIndex i;
+    AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
+    NSFont* nsFont = awtFont->fFont;
+    CTFontRef font = (CTFontRef)nsFont;
+    CFStringRef base = CTFontCopyFullName(font);
+    CFArrayRef codes = CFLocaleCopyISOLanguageCodes();
+
+#ifdef DEBUG
+    NSLog(@"BaseFont is : %@", (NSString*)base);
+#endif
+    CFArrayRef fds = CTFontCopyDefaultCascadeListForLanguages(font, codes);
+    CFIndex cnt = CFArrayGetCount(fds);
+    for (i=0; i<cnt; i++) {
+        CTFontDescriptorRef ref = CFArrayGetValueAtIndex(fds, i);
+        CFStringRef fontname =
+            CTFontDescriptorCopyAttribute(ref, kCTFontNameAttribute);
+#ifdef DEBUG
+        NSLog(@"Font is : %@", (NSString*)fontname);
+#endif
+        jstring jFontName = (jstring)JNFNSToJavaString(env, fontname);
+        (*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName); 
+        (*env)->DeleteLocalRef(env, jFontName);
+    }
+}
--- a/src/macosx/native/sun/osxapp/NSApplicationAWT.h	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,9 +36,9 @@
 - (void) finishLaunching;
 - (void) registerWithProcessManager;
 - (void) setDockIconWithEnv:(JNIEnv *)env;
-- (void) postDummyEvent;
+- (void) postDummyEvent:(bool) useCocoa;
 - (void) postRunnableEvent:(void (^)())block;
-- (void) waitForDummyEvent;
+- (void) waitForDummyEvent:(double) timeout;
 
 + (void) runAWTLoopWithApp:(NSApplication*)app;
 
--- a/src/macosx/native/sun/osxapp/NSApplicationAWT.m	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m	Thu Mar 15 03:52:16 2018 +0000
@@ -377,9 +377,7 @@
     [pool drain];
 }
 
-
-
-- (void)postDummyEvent {
+- (void)postDummyEvent:(bool)useCocoa {
     seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
     dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
     
@@ -393,13 +391,28 @@
                                          subtype: 0
                                            data1: 0
                                            data2: 0];
-    [NSApp postEvent: event atStart: NO];
+    if (useCocoa) {
+        [NSApp postEvent:event atStart:NO];
+    } else {
+        ProcessSerialNumber psn;
+        GetCurrentProcess(&psn);
+        CGEventPostToPSN(&psn, [event CGEvent]);
+    }
     [pool drain];
 }
 
-- (void)waitForDummyEvent {
-    [seenDummyEventLock lockWhenCondition:YES];
-    [seenDummyEventLock unlock];
+- (void)waitForDummyEvent:(double)timeout {
+    bool unlock = true;
+    if (timeout >= 0) {
+        double sec = timeout / 1000;
+        unlock = [seenDummyEventLock lockWhenCondition:YES
+                               beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
+    } else {
+        [seenDummyEventLock lockWhenCondition:YES];
+    }
+    if (unlock) {
+        [seenDummyEventLock unlock];
+    }
     [seenDummyEventLock release];
 
     seenDummyEventLock = nil;
--- a/src/share/back/debugLoop.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/back/debugLoop.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 
 static volatile struct PacketList *cmdQueue;
 static jrawMonitorID cmdQueueLock;
-static jrawMonitorID resumeLock;
+static jrawMonitorID vmDeathLock;
 static jboolean transportError;
 
 static jboolean
@@ -60,28 +60,17 @@
     }
 }
 
-static jboolean
-resumeCommand(jdwpCmdPacket *cmd)
-{
-    if ( (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)) &&
-         (cmd->cmd == JDWP_COMMAND(VirtualMachine, Resume)) ) {
-        return JNI_TRUE;
-    } else {
-        return JNI_FALSE;
-    }
-}
-
 void
 debugLoop_initialize(void)
 {
-    resumeLock = debugMonitorCreate("JDWP Resume Lock");
+    vmDeathLock = debugMonitorCreate("JDWP VM_DEATH Lock");
 }
 
 void
 debugLoop_sync(void)
 {
-    debugMonitorEnter(resumeLock);
-    debugMonitorExit(resumeLock);
+    debugMonitorEnter(vmDeathLock);
+    debugMonitorExit(vmDeathLock);
 }
 
 /*
@@ -136,15 +125,13 @@
             jboolean replyToSender = JNI_TRUE;
 
             /*
-             * For VirtualMachine.Resume commands we hold the resumeLock
+             * For all commands we hold the vmDeathLock
              * while executing and replying to the command. This ensures
-             * that a Resume after VM_DEATH will be allowed to complete
+             * that a command after VM_DEATH will be allowed to complete
              * before the thread posting the VM_DEATH continues VM
              * termination.
              */
-            if (resumeCommand(cmd)) {
-                debugMonitorEnter(resumeLock);
-            }
+            debugMonitorEnter(vmDeathLock);
 
             /* Initialize the input and output streams */
             inStream_init(&in, p);
@@ -181,11 +168,9 @@
             }
 
             /*
-             * Release the resumeLock as the reply has been posted.
+             * Release the vmDeathLock as the reply has been posted.
              */
-            if (resumeCommand(cmd)) {
-                debugMonitorExit(resumeLock);
-            }
+            debugMonitorExit(vmDeathLock);
 
             inStream_destroy(&in);
             outStream_destroy(&out);
--- a/src/share/back/eventHelper.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/back/eventHelper.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -240,10 +240,10 @@
 
         size = commandSize(command);
         /*
-         * Immediately close out any commands enqueued from a
-         * previously attached debugger.
+         * Immediately close out any commands enqueued from
+         * a dead VM or a previously attached debugger.
          */
-        if (command->sessionID != currentSessionID) {
+        if (gdata->vmDead || command->sessionID != currentSessionID) {
             log_debugee_location("dequeueCommand(): command session removal", NULL, NULL, 0);
             completeCommand(command);
             command = NULL;
--- a/src/share/bin/java.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/bin/java.c	Thu Mar 15 03:52:16 2018 +0000
@@ -650,9 +650,26 @@
 SetJvmEnvironment(int argc, char **argv) {
 
     static const char*  NMT_Env_Name    = "NMT_LEVEL_";
-
     int i;
     for (i = 0; i < argc; i++) {
+        char *arg = argv[i];
+        /*
+         * Since this must be a VM flag we stop processing once we see
+         * an argument the launcher would not have processed beyond (such
+         * as -version or -h), or an argument that indicates the following
+         * arguments are for the application (i.e. the main class name, or
+         * the -jar argument).
+         */
+        if ((i > 0 && *arg != '-')
+                || JLI_StrCmp(arg, "-version") == 0
+                || JLI_StrCmp(arg, "-fullversion") == 0
+                || JLI_StrCmp(arg, "-help") == 0
+                || JLI_StrCmp(arg, "-?") == 0
+                || JLI_StrCmp(arg, "-jar") == 0
+                || JLI_StrCmp(arg, "-X") == 0
+                ) {
+            return;
+        }
         /*
          * The following case checks for "-XX:NativeMemoryTracking=value".
          * If value is non null, an environmental variable set to this value
@@ -660,7 +677,6 @@
          * The argument is passed to the JVM, which will check validity.
          * The JVM is responsible for removing the env variable.
          */
-        char *arg = argv[i];
         if (JLI_StrCCmp(arg, "-XX:NativeMemoryTracking=") == 0) {
             int retval;
             // get what follows this parameter, include "="
--- a/src/share/classes/com/sun/tools/jdi/TargetVM.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/com/sun/tools/jdi/TargetVM.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 
 public class TargetVM implements Runnable {
     private Map<String, Packet> waitingQueue = new HashMap<String, Packet>(32,0.75f);
-    private boolean shouldListen = true;
+    private volatile boolean shouldListen = true;
     private List<EventQueue> eventQueues = Collections.synchronizedList(new ArrayList<EventQueue>(2));
     private VirtualMachineImpl vm;
     private Connection connection;
@@ -173,6 +173,9 @@
 
         // inform the VM mamager that this VM is history
         vm.vmManager.disposeVirtualMachine(vm);
+        if (eventController != null) {
+            eventController.release();
+        }
 
         // close down all the event queues
         // Closing a queue causes a VMDisconnectEvent to
@@ -234,7 +237,7 @@
 
     private EventController eventController() {
         if (eventController == null) {
-            eventController = new EventController(vm);
+            eventController = new EventController();
         }
         return eventController;
     }
@@ -323,13 +326,11 @@
         } catch (IOException ioe) { }
     }
 
-    static private class EventController extends Thread {
-        VirtualMachineImpl vm;
+    private class EventController extends Thread {
         int controlRequest = 0;
 
-        EventController(VirtualMachineImpl vm) {
+        EventController() {
             super(vm.threadGroupForJDI(), "JDI Event Control Thread");
-            this.vm = vm;
             setDaemon(true);
             setPriority((MAX_PRIORITY + NORM_PRIORITY)/2);
             super.start();
@@ -351,6 +352,9 @@
                 synchronized(this) {
                     while (controlRequest == 0) {
                         try {wait();} catch (InterruptedException e) {}
+                        if (!shouldListen) {
+                           return;
+                        }
                     }
                     currentRequest = controlRequest;
                     controlRequest = 0;
--- a/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -238,7 +238,7 @@
     }
 
     public void stop(ObjectReference throwable) throws InvalidTypeException {
-        validateMirror(throwable);
+        validateMirrorOrNull(throwable);
         // Verify that the given object is a Throwable instance
         List<ReferenceType> list = vm.classesByName("java.lang.Throwable");
         ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);
--- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Thu Mar 15 03:52:16 2018 +0000
@@ -76,6 +76,7 @@
     private LinkedList<KeyEvent> enqueuedKeyEvents = new LinkedList<KeyEvent>();
     private LinkedList<TypeAheadMarker> typeAheadMarkers = new LinkedList<TypeAheadMarker>();
     private boolean consumeNextKeyTyped;
+    private Component restoreFocusTo;
 
     static {
         AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
@@ -146,12 +147,28 @@
     }
     private boolean restoreFocus(Window aWindow, Component vetoedComponent,
                                  boolean clearOnFailure) {
+        restoreFocusTo = null;
         Component toFocus =
             KeyboardFocusManager.getMostRecentFocusOwner(aWindow);
 
-        if (toFocus != null && toFocus != vetoedComponent && doRestoreFocus(toFocus, vetoedComponent, false)) {
-            return true;
-        } else if (clearOnFailure) {
+        if (toFocus != null && toFocus != vetoedComponent) {
+            if (getHeavyweight(aWindow) != getNativeFocusOwner()) {
+                // cannot restore focus synchronously
+                if (!toFocus.isShowing() || !toFocus.canBeFocusOwner()) {
+                    toFocus = toFocus.getNextFocusCandidate();
+                }
+                if (toFocus != null && toFocus != vetoedComponent) {
+                    if (!toFocus.requestFocus(false,
+                                                   CausedFocusEvent.Cause.ROLLBACK)) {
+                        restoreFocusTo = toFocus;
+                    }
+                    return true;
+                }
+            } else if (doRestoreFocus(toFocus, vetoedComponent, false)) {
+                return true;
+            }
+        }
+        if (clearOnFailure) {
             clearGlobalFocusOwnerPriv();
             return true;
         } else {
@@ -164,11 +181,16 @@
     private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                                    boolean clearOnFailure)
     {
+        boolean success = true;
         if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
-            toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
+            (success = toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)))
         {
             return true;
         } else {
+            if (!success && getGlobalFocusedWindow() != SunToolkit.getContainingWindow(toFocus)) {
+                restoreFocusTo = toFocus;
+                return true;
+            }
             Component nextFocus = toFocus.getNextFocusCandidate();
             if (nextFocus != null && nextFocus != vetoedComponent &&
                 nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
@@ -413,6 +435,8 @@
                     // may cause deadlock, thus we don't synchronize this block.
                     Component toFocus = KeyboardFocusManager.
                         getMostRecentFocusOwner(newFocusedWindow);
+                    boolean isFocusRestore = restoreFocusTo != null &&
+                                                      toFocus == restoreFocusTo;
                     if ((toFocus == null) &&
                         newFocusedWindow.isFocusableWindow())
                     {
@@ -431,7 +455,10 @@
                                        tempLost, toFocus);
                     }
                     if (tempLost != null) {
-                        tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+                        tempLost.requestFocusInWindow(
+                                    isFocusRestore && tempLost == toFocus ?
+                                                CausedFocusEvent.Cause.ROLLBACK :
+                                                CausedFocusEvent.Cause.ACTIVATION);
                     }
 
                     if (toFocus != null && toFocus != tempLost) {
@@ -440,6 +467,7 @@
                         toFocus.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
                     }
                 }
+                restoreFocusTo = null;
 
                 Window realOppositeWindow = this.realOppositeWindowWR.get();
                 if (realOppositeWindow != we.getOppositeWindow()) {
@@ -489,6 +517,7 @@
             }
 
             case FocusEvent.FOCUS_GAINED: {
+                restoreFocusTo = null;
                 FocusEvent fe = (FocusEvent)e;
                 CausedFocusEvent.Cause cause = (fe instanceof CausedFocusEvent) ?
                     ((CausedFocusEvent)fe).getCause() : CausedFocusEvent.Cause.UNKNOWN;
--- a/src/share/classes/java/awt/EventDispatchThread.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/java/awt/EventDispatchThread.java	Thu Mar 15 03:52:16 2018 +0000
@@ -153,6 +153,23 @@
         }
     }
 
+    boolean filterAndCheckEvent(AWTEvent event) {
+        boolean eventOK = true;
+        synchronized (eventFilters) {
+            for (int i = eventFilters.size() - 1; i >= 0; i--) {
+                EventFilter f = eventFilters.get(i);
+                EventFilter.FilterAction accept = f.acceptEvent(event);
+                if (accept == EventFilter.FilterAction.REJECT) {
+                    eventOK = false;
+                    break;
+                } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
+                    break;
+                }
+            }
+        }
+        return eventOK && SunDragSourceContextPeer.checkEvent(event);
+    }
+
     void pumpOneEventForFilters(int id) {
         AWTEvent event = null;
         boolean eventOK = false;
@@ -170,20 +187,7 @@
                     event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id);
                 }
 
-                eventOK = true;
-                synchronized (eventFilters) {
-                    for (int i = eventFilters.size() - 1; i >= 0; i--) {
-                        EventFilter f = eventFilters.get(i);
-                        EventFilter.FilterAction accept = f.acceptEvent(event);
-                        if (accept == EventFilter.FilterAction.REJECT) {
-                            eventOK = false;
-                            break;
-                        } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) {
-                            break;
-                        }
-                    }
-                }
-                eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event);
+                eventOK = filterAndCheckEvent(event);
                 if (!eventOK) {
                     event.consume();
                 }
--- a/src/share/classes/java/awt/EventQueue.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/java/awt/EventQueue.java	Thu Mar 15 03:52:16 2018 +0000
@@ -711,7 +711,9 @@
                     fwDispatcher.scheduleDispatch(new Runnable() {
                         @Override
                         public void run() {
-                            dispatchEventImpl(event, src);
+                            if (dispatchThread.filterAndCheckEvent(event)) {
+                                dispatchEventImpl(event, src);
+                            }
                         }
                     });
                 }
@@ -1000,6 +1002,32 @@
         return createSecondaryLoop(null, null, 0);
     }
 
+    private class FwSecondaryLoopWrapper implements SecondaryLoop {
+        final private SecondaryLoop loop;
+        final private EventFilter filter;
+
+        public FwSecondaryLoopWrapper(SecondaryLoop loop, EventFilter filter) {
+            this.loop = loop;
+            this.filter = filter;
+        }
+
+        @Override
+        public boolean enter() {
+            if (filter != null) {
+                dispatchThread.addEventFilter(filter);
+            }
+            return loop.enter();
+        }
+
+        @Override
+        public boolean exit() {
+            if (filter != null) {
+                dispatchThread.removeEventFilter(filter);
+            }
+            return loop.exit();
+        }
+    }
+
     SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
         pushPopLock.lock();
         try {
@@ -1008,7 +1036,7 @@
                 return nextQueue.createSecondaryLoop(cond, filter, interval);
             }
             if (fwDispatcher != null) {
-                return fwDispatcher.createSecondaryLoop();
+                return new FwSecondaryLoopWrapper(fwDispatcher.createSecondaryLoop(), filter);
             }
             if (dispatchThread == null) {
                 initDispatchThread();
--- a/src/share/classes/java/lang/ref/Finalizer.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/java/lang/ref/Finalizer.java	Thu Mar 15 03:52:16 2018 +0000
@@ -122,18 +122,18 @@
         AccessController.doPrivileged(
             new PrivilegedAction<Void>() {
                 public Void run() {
-                ThreadGroup tg = Thread.currentThread().getThreadGroup();
-                for (ThreadGroup tgn = tg;
-                     tgn != null;
-                     tg = tgn, tgn = tg.getParent());
-                Thread sft = new Thread(tg, proc, "Secondary finalizer");
-                sft.start();
-                try {
-                    sft.join();
-                } catch (InterruptedException x) {
-                    /* Ignore */
-                }
-                return null;
+                    ThreadGroup tg = Thread.currentThread().getThreadGroup();
+                    for (ThreadGroup tgn = tg;
+                         tgn != null;
+                         tg = tgn, tgn = tg.getParent());
+                    Thread sft = new Thread(tg, proc, "Secondary finalizer");
+                    sft.start();
+                    try {
+                        sft.join();
+                    } catch (InterruptedException x) {
+                        Thread.currentThread().interrupt();
+                    }
+                    return null;
                 }});
     }
 
@@ -146,6 +146,7 @@
         forkSecondaryFinalizer(new Runnable() {
             private volatile boolean running;
             public void run() {
+                // in case of recursive call to run()
                 if (running)
                     return;
                 final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@@ -168,6 +169,7 @@
         forkSecondaryFinalizer(new Runnable() {
             private volatile boolean running;
             public void run() {
+                // in case of recursive call to run()
                 if (running)
                     return;
                 final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@@ -189,6 +191,7 @@
             super(g, "Finalizer");
         }
         public void run() {
+            // in case of recursive call to run()
             if (running)
                 return;
 
--- a/src/share/classes/java/time/temporal/ValueRange.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/java/time/temporal/ValueRange.java	Thu Mar 15 03:52:16 2018 +0000
@@ -385,7 +385,7 @@
         }
         if (obj instanceof ValueRange) {
             ValueRange other = (ValueRange) obj;
-           return minSmallest == other.minSmallest && minLargest == other.minLargest &&
+            return minSmallest == other.minSmallest && minLargest == other.minLargest &&
                    maxSmallest == other.maxSmallest && maxLargest == other.maxLargest;
         }
         return false;
@@ -398,8 +398,9 @@
      */
     @Override
     public int hashCode() {
-        long hash = minSmallest + minLargest << 16 + minLargest >> 48 + maxSmallest << 32 +
-            maxSmallest >> 32 + maxLargest << 48 + maxLargest >> 16;
+        long hash = minSmallest + (minLargest << 16) + (minLargest >> 48) +
+                (maxSmallest << 32) + (maxSmallest >> 32) + (maxLargest << 48) +
+                (maxLargest >> 16);
         return (int) (hash ^ (hash >>> 32));
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Thu Mar 15 03:52:16 2018 +0000
@@ -271,11 +271,6 @@
         // Home Button
         File homeDir = fsv.getHomeDirectory();
         String toolTipText = homeFolderToolTipText;
-        if (fsv.isRoot(homeDir)) {
-            toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
-        }
-
-
 
 
         JButton b = new JButton(homeFolderIcon);
--- a/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Thu Mar 15 03:52:16 2018 +0000
@@ -806,11 +806,12 @@
 
         // Paint the background for the tab area
         if ( tabPane.isOpaque() ) {
-            if (!c.isBackgroundSet() && (tabAreaBackground != null)) {
+            Color background = c.getBackground();
+            if (background instanceof UIResource && tabAreaBackground != null) {
                 g.setColor(tabAreaBackground);
             }
             else {
-                g.setColor( c.getBackground() );
+                g.setColor(background);
             }
             switch ( tabPlacement ) {
             case LEFT:
--- a/src/share/classes/sun/font/CompositeFont.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/CompositeFont.java	Thu Mar 15 03:52:16 2018 +0000
@@ -154,6 +154,25 @@
         }
     }
 
+    /*
+     * Build a composite from a set of individual slot fonts.
+     */
+    CompositeFont(PhysicalFont[] slotFonts) {
+
+        isStdComposite = false;
+        handle = new Font2DHandle(this);
+        fullName = slotFonts[0].fullName;
+        familyName = slotFonts[0].familyName;
+        style = slotFonts[0].style;
+
+        numMetricsSlots = 1; /* Only the physical Font */
+        numSlots = slotFonts.length;
+
+        components = new PhysicalFont[numSlots];
+        System.arraycopy(slotFonts, 0, components, 0, numSlots);
+        deferredInitialisation = new boolean[numSlots]; // all false.
+    }
+
     /* This method is currently intended to be called only from
      * FontManager.getCompositeFontUIResource(Font)
      * It creates a new CompositeFont with the contents of the Physical
--- a/src/share/classes/sun/font/CompositeGlyphMapper.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/CompositeGlyphMapper.java	Thu Mar 15 03:52:16 2018 +0000
@@ -42,7 +42,7 @@
  * this appears to cause problems.
  */
 
-public final class CompositeGlyphMapper extends CharToGlyphMapper {
+public class CompositeGlyphMapper extends CharToGlyphMapper {
 
     public static final int SLOTMASK =  0xff000000;
     public static final int GLYPHMASK = 0x00ffffff;
--- a/src/share/classes/sun/font/CompositeStrike.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/CompositeStrike.java	Thu Mar 15 03:52:16 2018 +0000
@@ -72,6 +72,10 @@
 
     PhysicalStrike getStrikeForSlot(int slot) {
 
+        if (slot >= strikes.length) {
+            slot = 0;
+        }
+
         PhysicalStrike strike = strikes[slot];
         if (strike == null) {
             strike =
--- a/src/share/classes/sun/font/Font2D.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/Font2D.java	Thu Mar 15 03:52:16 2018 +0000
@@ -461,10 +461,17 @@
      * to check the font class before attempting to run, rather than needing
      * to promote this method up from TrueTypeFont
      */
-    byte[] getTableBytes(int tag) {
+    protected byte[] getTableBytes(int tag) {
         return null;
     }
 
+    /* implemented for fonts backed by an sfnt that has
+     * OpenType or AAT layout tables.
+     */
+    protected long getLayoutTableCache() {
+        return 0L;
+    }
+
     /* for layout code */
     protected long getUnitsPerEm() {
         return 2048;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/font/FontSubstitution.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,38 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.font;
+
+
+
+/**
+ * Interface that indicates a Font2D that is not a Composite but has the
+ * property that it internally behaves like one, substituting glyphs
+ * from another font at render time.
+ * In this case the Font must provide a way to behave like a regular
+ * composite when that behaviour is not wanted.
+ */
+public interface FontSubstitution {
+    public CompositeFont getCompositeFont2D();
+}
--- a/src/share/classes/sun/font/GlyphLayout.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/GlyphLayout.java	Thu Mar 15 03:52:16 2018 +0000
@@ -408,6 +408,9 @@
         int lang = -1; // default for now
 
         Font2D font2D = FontUtilities.getFont2D(font);
+        if (font2D instanceof FontSubstitution) {
+            font2D = ((FontSubstitution)font2D).getCompositeFont2D();
+        }
 
         _textRecord.init(text, offset, lim, min, max);
         int start = offset;
--- a/src/share/classes/sun/font/StandardGlyphVector.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/StandardGlyphVector.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1124,6 +1124,9 @@
 
     private void initFontData() {
         font2D = FontUtilities.getFont2D(font);
+        if (font2D instanceof FontSubstitution) {
+           font2D = ((FontSubstitution)font2D).getCompositeFont2D();
+        }
         float s = font.getSize2D();
         if (font.isTransformed()) {
             ftx = font.getTransform();
@@ -1742,7 +1745,12 @@
                                                      aa, fm);
             // Get the strike via the handle. Shouldn't matter
             // if we've invalidated the font but its an extra precaution.
-            FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)
+        // do we want the CompFont from CFont here ?
+        Font2D f2d = sgv.font2D;
+        if (f2d instanceof FontSubstitution) {
+           f2d = ((FontSubstitution)f2d).getCompositeFont2D();
+        }
+            FontStrike strike = f2d.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)
 
             return new GlyphStrike(sgv, strike, dx, dy);
         }
--- a/src/share/classes/sun/font/SunLayoutEngine.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/SunLayoutEngine.java	Thu Mar 15 03:52:16 2018 +0000
@@ -154,10 +154,7 @@
                        Point2D.Float pt, GVData data) {
         Font2D font = key.font();
         FontStrike strike = font.getStrike(desc);
-        long layoutTables = 0;
-        if (font instanceof TrueTypeFont) {
-            layoutTables = ((TrueTypeFont) font).getLayoutTableCache();
-        }
+        long layoutTables = font.getLayoutTableCache();
         nativeLayout(font, strike, mat, gmask, baseIndex,
              tr.text, tr.start, tr.limit, tr.min, tr.max,
              key.script(), key.lang(), typo_flags, pt, data,
--- a/src/share/classes/sun/font/TrueTypeFont.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/font/TrueTypeFont.java	Thu Mar 15 03:52:16 2018 +0000
@@ -887,8 +887,8 @@
         }
     }
 
-    /* NB: is it better to move declaration to Font2D? */
-    long getLayoutTableCache() {
+    @Override
+    protected long getLayoutTableCache() {
         try {
           return getScaler().getLayoutTableCache();
         } catch(FontScalerException fe) {
@@ -897,7 +897,7 @@
     }
 
     @Override
-    byte[] getTableBytes(int tag) {
+    protected byte[] getTableBytes(int tag) {
         ByteBuffer buffer = getTableBuffer(tag);
         if (buffer == null) {
             return null;
--- a/src/share/classes/sun/management/Agent.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/Agent.java	Thu Mar 15 03:52:16 2018 +0000
@@ -34,7 +34,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
-import java.net.Socket;
 import java.net.UnknownHostException;
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
@@ -88,7 +87,7 @@
     // return empty property set
     private static Properties parseString(String args) {
         Properties argProps = new Properties();
-        if (args != null) {
+        if (args != null && !args.trim().equals("")) {
             for (String option : args.split(",")) {
                 String s[] = option.split("=", 2);
                 String name = s[0].trim();
@@ -160,53 +159,59 @@
             throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
         }
 
-        Properties argProps = parseString(args);
-        Properties configProps = new Properties();
+        try {
+            Properties argProps = parseString(args);
+            Properties configProps = new Properties();
 
-        // Load the management properties from the config file
-        // if config file is not specified readConfiguration implicitly
-        // reads <java.home>/lib/management/management.properties
+            // Load the management properties from the config file
+            // if config file is not specified readConfiguration implicitly
+            // reads <java.home>/lib/management/management.properties
+
+            String fname = System.getProperty(CONFIG_FILE);
+            readConfiguration(fname, configProps);
 
-        String fname = System.getProperty(CONFIG_FILE);
-        readConfiguration(fname, configProps);
+            // management properties can be overridden by system properties
+            // which take precedence
+            Properties sysProps = System.getProperties();
+            synchronized (sysProps) {
+                configProps.putAll(sysProps);
+            }
 
-        // management properties can be overridden by system properties
-        // which take precedence
-        Properties sysProps = System.getProperties();
-        synchronized (sysProps) {
-            configProps.putAll(sysProps);
-        }
+            // if user specifies config file into command line for either
+            // jcmd utilities or attach command it overrides properties set in
+            // command line at the time of VM start
+            String fnameUser = argProps.getProperty(CONFIG_FILE);
+            if (fnameUser != null) {
+                readConfiguration(fnameUser, configProps);
+            }
 
-        // if user specifies config file into command line for either
-        // jcmd utilities or attach command it overrides properties set in
-        // command line at the time of VM start
-        String fnameUser = argProps.getProperty(CONFIG_FILE);
-        if (fnameUser != null) {
-            readConfiguration(fnameUser, configProps);
-        }
+            // arguments specified in command line of jcmd utilities
+            // override both system properties and one set by config file
+            // specified in jcmd command line
+            configProps.putAll(argProps);
 
-        // arguments specified in command line of jcmd utilities
-        // override both system properties and one set by config file
-        // specified in jcmd command line
-        configProps.putAll(argProps);
+            // jcmd doesn't allow to change ThreadContentionMonitoring, but user
+            // can specify this property inside config file, so enable optional
+            // monitoring functionality if this property is set
+            final String enableThreadContentionMonitoring =
+                    configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
 
-        // jcmd doesn't allow to change ThreadContentionMonitoring, but user
-        // can specify this property inside config file, so enable optional
-        // monitoring functionality if this property is set
-        final String enableThreadContentionMonitoring =
-                configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
+            if (enableThreadContentionMonitoring != null) {
+                ManagementFactory.getThreadMXBean().
+                        setThreadContentionMonitoringEnabled(true);
+            }
 
-        if (enableThreadContentionMonitoring != null) {
-            ManagementFactory.getThreadMXBean().
-                    setThreadContentionMonitoringEnabled(true);
-        }
+            String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
+            if (jmxremotePort != null) {
+                jmxServer = ConnectorBootstrap.
+                        startRemoteConnectorServer(jmxremotePort, configProps);
 
-        String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
-        if (jmxremotePort != null) {
-            jmxServer = ConnectorBootstrap.
-                    startRemoteConnectorServer(jmxremotePort, configProps);
-
-            startDiscoveryService(configProps);
+                startDiscoveryService(configProps);
+            } else {
+                throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, "No port specified");
+            }
+        } catch (AgentConfigurationError err) {
+            error(err.getError(), err.getParams());
         }
     }
 
@@ -507,7 +512,7 @@
         String keyText = getText(key);
         System.err.print(getText("agent.err.error") + ": " + keyText);
         System.err.println(": " + message);
-        throw new RuntimeException(keyText);
+        throw new RuntimeException(keyText + ": " + message);
     }
 
     public static void error(Exception e) {
--- a/src/share/classes/sun/management/resources/agent.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) does not exist in agent class
 agent.err.agentclass.access.denied = Access to premain(String) is denied
 agent.err.invalid.agentclass       = Invalid com.sun.management.agent.class property value
-agent.err.invalid.state            = Invalid agent state
+agent.err.invalid.state            = Invalid agent state: {0}
 agent.err.invalid.jmxremote.port   = Invalid com.sun.management.jmxremote.port number
 agent.err.invalid.jmxremote.rmi.port = Invalid com.sun.management.jmxremote.rmi.port number
 
--- a/src/share/classes/sun/management/resources/agent_de.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_de.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) ist in Agent-Klasse nicht vorhanden
 agent.err.agentclass.access.denied = Zugriff auf premain(String) wurde abgelehnt
 agent.err.invalid.agentclass       = Ung\u00FCltiger Eigenschaftswert f\u00FCr com.sun.management.agent.class
-agent.err.invalid.state            = Ung\u00FCltiger Agent-Zustand
+agent.err.invalid.state            = Ung\u00FCltiger Agent-Zustand: {0}
 agent.err.invalid.jmxremote.port   = Ung\u00FCltige Nummer f\u00FCr com.sun.management.jmxremote.port
 agent.err.invalid.jmxremote.rmi.port = Ung\u00FCltige Nummer f\u00FCr com.sun.management.jmxremote.rmi.port
 
--- a/src/share/classes/sun/management/resources/agent_es.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_es.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) no existe en la clase del agente
 agent.err.agentclass.access.denied = Acceso denegado a premain(String)
 agent.err.invalid.agentclass       = Valor de propiedad com.sun.management.agent.class no v\u00E1lido
-agent.err.invalid.state            = Estado del agente no v\u00E1lido
+agent.err.invalid.state            = Estado de agente no v\u00E1lido: {0}
 agent.err.invalid.jmxremote.port   = N\u00FAmero com.sun.management.jmxremote.port no v\u00E1lido
 agent.err.invalid.jmxremote.rmi.port = N\u00FAmero com.sun.management.jmxremote.rmi.port no v\u00E1lido
 
--- a/src/share/classes/sun/management/resources/agent_fr.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_fr.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) n'existe pas dans la classe d'agents
 agent.err.agentclass.access.denied = Acc\u00E8s \u00E0 premain(String) refus\u00E9
 agent.err.invalid.agentclass       = Valeur de propri\u00E9t\u00E9 com.sun.management.agent.class incorrecte
-agent.err.invalid.state            = Etat de l'agent non valide
+agent.err.invalid.state            = Etat de l''agent non valide : {0}
 agent.err.invalid.jmxremote.port   = Num\u00E9ro com.sun.management.jmxremote.port incorrect
 agent.err.invalid.jmxremote.rmi.port = Num\u00E9ro com.sun.management.jmxremote.rmi.port non valide
 
--- a/src/share/classes/sun/management/resources/agent_it.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_it.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) non esiste nella classe agente
 agent.err.agentclass.access.denied = Accesso negato a premain(String)
 agent.err.invalid.agentclass       = Valore propriet\u00E0 com.sun.management.agent.class non valido
-agent.err.invalid.state            = Stato agente non valido
+agent.err.invalid.state            = Stato agente non valido: {0}
 agent.err.invalid.jmxremote.port   = Numero com.sun.management.jmxremote.port non valido
 agent.err.invalid.jmxremote.rmi.port = Numero com.sun.management.jmxremote.rmi.port non valido
 
--- a/src/share/classes/sun/management/resources/agent_ja.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_ja.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String)\u304C\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30FB\u30AF\u30E9\u30B9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093
 agent.err.agentclass.access.denied = premain(String)\u3078\u306E\u30A2\u30AF\u30BB\u30B9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F
 agent.err.invalid.agentclass       = com.sun.management.agent.class\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u5024\u304C\u7121\u52B9\u3067\u3059
-agent.err.invalid.state            = \u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306E\u72B6\u614B\u304C\u7121\u52B9\u3067\u3059
+agent.err.invalid.state            = \u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306E\u72B6\u614B\u304C\u7121\u52B9\u3067\u3059: {0}
 agent.err.invalid.jmxremote.port   = com.sun.management.jmxremote.port\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059
 agent.err.invalid.jmxremote.rmi.port = com.sun.management.jmxremote.rmi.port\u306E\u756A\u53F7\u304C\u7121\u52B9\u3067\u3059
 
--- a/src/share/classes/sun/management/resources/agent_ko.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_ko.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = \uC5D0\uC774\uC804\uD2B8 \uD074\uB798\uC2A4\uC5D0 premain(\uBB38\uC790\uC5F4)\uC774 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.
 agent.err.agentclass.access.denied = premain(\uBB38\uC790\uC5F4)\uC5D0 \uB300\uD55C \uC561\uC138\uC2A4\uAC00 \uAC70\uBD80\uB418\uC5C8\uC2B5\uB2C8\uB2E4.
 agent.err.invalid.agentclass       = com.sun.management.agent.class \uC18D\uC131 \uAC12\uC774 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4.
-agent.err.invalid.state            = \uBD80\uC801\uD569\uD55C \uC5D0\uC774\uC804\uD2B8 \uC0C1\uD0DC
+agent.err.invalid.state            = \uBD80\uC801\uD569\uD55C \uC5D0\uC774\uC804\uD2B8 \uC0C1\uD0DC: {0}
 agent.err.invalid.jmxremote.port   = com.sun.management.jmxremote.port \uBC88\uD638\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4.
 agent.err.invalid.jmxremote.rmi.port = \uBD80\uC801\uD569\uD55C com.sun.management.jmxremote.rmi.port \uBC88\uD638
 
--- a/src/share/classes/sun/management/resources/agent_pt_BR.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_pt_BR.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) n\u00E3o existe na classe do agente
 agent.err.agentclass.access.denied = Acesso negado a premain(String)
 agent.err.invalid.agentclass       = Valor inv\u00E1lido da propriedade com.sun.management.agent.class
-agent.err.invalid.state            = Estado de agente inv\u00E1lido
+agent.err.invalid.state            = Estado inv\u00E1lido do agente: {0}
 agent.err.invalid.jmxremote.port   = N\u00FAmero inv\u00E1lido de com.sun.management.jmxremote.port
 agent.err.invalid.jmxremote.rmi.port = N\u00FAmero inv\u00E1lido do com.sun.management.jmxremote.rmi.port
 
--- a/src/share/classes/sun/management/resources/agent_sv.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_sv.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = premain(String) finns inte i agentklassen
 agent.err.agentclass.access.denied = \u00C5tkomst till premain(String) nekad
 agent.err.invalid.agentclass       = Ogiltigt egenskapsv\u00E4rde f\u00F6r com.sun.management.agent.class
-agent.err.invalid.state            = Ogiltigt agenttillst\u00E5nd
+agent.err.invalid.state            = Ogiltig agentstatus: {0}
 agent.err.invalid.jmxremote.port   = Ogiltigt com.sun.management.jmxremote.port-nummer
 agent.err.invalid.jmxremote.rmi.port = Ogiltigt com.sun.management.jmxremote.rmi.port-nummer
 
--- a/src/share/classes/sun/management/resources/agent_zh_CN.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_zh_CN.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = \u4EE3\u7406\u7C7B\u4E2D\u4E0D\u5B58\u5728 premain(String)
 agent.err.agentclass.access.denied = \u62D2\u7EDD\u8BBF\u95EE premain(String)
 agent.err.invalid.agentclass       = com.sun.management.agent.class \u5C5E\u6027\u503C\u65E0\u6548
-agent.err.invalid.state            = \u4EE3\u7406\u72B6\u6001\u65E0\u6548
+agent.err.invalid.state            = \u65E0\u6548\u7684\u4EE3\u7406\u72B6\u6001: {0}
 agent.err.invalid.jmxremote.port   = com.sun.management.jmxremote.port \u7F16\u53F7\u65E0\u6548
 agent.err.invalid.jmxremote.rmi.port = com.sun.management.jmxremote.rmi.port \u7F16\u53F7\u65E0\u6548
 
--- a/src/share/classes/sun/management/resources/agent_zh_TW.properties	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/management/resources/agent_zh_TW.properties	Thu Mar 15 03:52:16 2018 +0000
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 agent.err.premain.notfound         = \u4EE3\u7406\u7A0B\u5F0F\u985E\u5225\u4E2D\u4E0D\u5B58\u5728 premain(String)
 agent.err.agentclass.access.denied = \u5B58\u53D6 premain(String) \u906D\u5230\u62D2\u7D55
 agent.err.invalid.agentclass       = com.sun.management.agent.class \u5C6C\u6027\u503C\u7121\u6548
-agent.err.invalid.state            = \u7121\u6548\u7684\u4EE3\u7406\u7A0B\u5F0F\u72C0\u614B
+agent.err.invalid.state            = \u7121\u6548\u7684\u4EE3\u7406\u7A0B\u5F0F\u72C0\u614B: {0}
 agent.err.invalid.jmxremote.port   = com.sun.management.jmxremote.port \u865F\u78BC\u7121\u6548
 agent.err.invalid.jmxremote.rmi.port = com.sun.management.jmxremote.rmi.port \u865F\u78BC\u7121\u6548
 
--- a/src/share/classes/sun/misc/ObjectInputFilter.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/misc/ObjectInputFilter.java	Thu Mar 15 03:52:16 2018 +0000
@@ -379,7 +379,20 @@
          */
         public static ObjectInputFilter createFilter(String pattern) {
             Objects.requireNonNull(pattern, "pattern");
-            return Global.createFilter(pattern);
+            return Global.createFilter(pattern, true);
+        }
+
+        /**
+         * Returns an ObjectInputFilter from a string of patterns that
+         * checks only the length for arrays, not the component type.
+         *
+         * @param pattern the pattern string to parse; not null
+         * @return a filter to check a class being deserialized;
+         *          {@code null} if no patterns
+         */
+        public static ObjectInputFilter createFilter2(String pattern) {
+            Objects.requireNonNull(pattern, "pattern");
+            return Global.createFilter(pattern, false);
         }
 
         /**
@@ -413,18 +426,24 @@
              * Maximum length of any array.
              */
             private long maxArrayLength;
+            /**
+             * True to check the component type for arrays.
+             */
+            private final boolean checkComponentType;
 
             /**
              * Returns an ObjectInputFilter from a string of patterns.
              *
              * @param pattern the pattern string to parse
+             * @param checkComponentType true if the filter should check
+             *                           the component type of arrays
              * @return a filter to check a class being deserialized; not null
              * @throws IllegalArgumentException if the parameter is malformed
              *                if the pattern is missing the name, the long value
              *                is not a number or is negative.
              */
-            static ObjectInputFilter createFilter(String pattern) {
-                Global filter = new Global(pattern);
+            static ObjectInputFilter createFilter(String pattern, boolean checkComponentType) {
+                Global filter = new Global(pattern, checkComponentType);
                 return filter.isEmpty() ? null : filter;
             }
 
@@ -432,10 +451,13 @@
              * Construct a new filter from the pattern String.
              *
              * @param pattern a pattern string of filters
+             * @param checkComponentType true if the filter should check
+             *                           the component type of arrays
              * @throws IllegalArgumentException if the pattern is malformed
              */
-            private Global(String pattern) {
+            private Global(String pattern, boolean checkComponentType) {
                 this.pattern = pattern;
+                this.checkComponentType = checkComponentType;
 
                 maxArrayLength = Long.MAX_VALUE; // Default values are unlimited
                 maxDepth = Long.MAX_VALUE;
@@ -594,6 +616,10 @@
                             // array length is too big
                             return Status.REJECTED;
                         }
+                        if (!checkComponentType) {
+                            // As revised; do not check the component type for arrays
+                            return Status.UNDECIDED;
+                        }
                         do {
                             // Arrays are decided based on the component type
                             clazz = clazz.getComponentType();
--- a/src/share/classes/sun/print/RasterPrinterJob.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/print/RasterPrinterJob.java	Thu Mar 15 03:52:16 2018 +0000
@@ -843,12 +843,45 @@
         }
    }
 
-   protected PageFormat getPageFormatFromAttributes() {
-       if (attributes == null || attributes.isEmpty()) {
+    protected PageFormat getPageFormatFromAttributes() {
+        if (attributes == null || attributes.isEmpty()) {
             return null;
         }
-        return attributeToPageFormat(getPrintService(), this.attributes);
-   }
+
+        PageFormat newPf = attributeToPageFormat(
+            getPrintService(), attributes);
+        PageFormat oldPf = null;
+        Pageable pageable = getPageable();
+        if ((pageable != null) &&
+            (pageable instanceof OpenBook) &&
+            ((oldPf = pageable.getPageFormat(0)) != null)) {
+            // If orientation, media, imageable area attributes are not in
+            // "attributes" set, then use respective values of the existing
+            // page format "oldPf".
+            if (attributes.get(OrientationRequested.class) == null) {
+                newPf.setOrientation(oldPf.getOrientation());
+            }
+
+            Paper newPaper = newPf.getPaper();
+            Paper oldPaper = oldPf.getPaper();
+            boolean oldPaperValWasSet = false;
+            if (attributes.get(MediaSizeName.class) == null) {
+                newPaper.setSize(oldPaper.getWidth(), oldPaper.getHeight());
+                oldPaperValWasSet = true;
+            }
+            if (attributes.get(MediaPrintableArea.class) == null) {
+                newPaper.setImageableArea(
+                    oldPaper.getImageableX(), oldPaper.getImageableY(),
+                    oldPaper.getImageableWidth(),
+                    oldPaper.getImageableHeight());
+                oldPaperValWasSet = true;
+            }
+            if (oldPaperValWasSet) {
+                newPf.setPaper(newPaper);
+            }
+        }
+        return newPf;
+    }
 
 
    /**
--- a/src/share/classes/sun/rmi/registry/RegistryImpl.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/rmi/registry/RegistryImpl.java	Thu Mar 15 03:52:16 2018 +0000
@@ -103,7 +103,7 @@
     private static final int REGISTRY_MAX_DEPTH = 20;
 
     /** Registry maximum array size in remote invocations. **/
-    private static final int REGISTRY_MAX_ARRAY_SIZE = 10000;
+    private static final int REGISTRY_MAX_ARRAY_SIZE = 1_000_000;
 
     /**
      * The registryFilter created from the value of the {@code "sun.rmi.registry.registryFilter"}
@@ -123,7 +123,7 @@
             props = Security.getProperty(REGISTRY_FILTER_PROPNAME);
         }
         if (props != null) {
-            filter = ObjectInputFilter.Config.createFilter(props);
+            filter = ObjectInputFilter.Config.createFilter2(props);
             Log regLog = Log.getLog("sun.rmi.registry", "registry", -1);
             if (regLog.isLoggable(Log.BRIEF)) {
                 regLog.log(Log.BRIEF, "registryFilter = " + filter);
@@ -419,17 +419,10 @@
         Class<?> clazz = filterInfo.serialClass();
         if (clazz != null) {
             if (clazz.isArray()) {
-                if (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE) {
-                    return ObjectInputFilter.Status.REJECTED;
-                }
-                do {
-                    // Arrays are allowed depending on the component type
-                    clazz = clazz.getComponentType();
-                } while (clazz.isArray());
-            }
-            if (clazz.isPrimitive()) {
-                // Arrays of primitives are allowed
-                return ObjectInputFilter.Status.ALLOWED;
+                // Arrays are REJECTED only if they exceed the limit
+                return (filterInfo.arrayLength() >= 0 && filterInfo.arrayLength() > REGISTRY_MAX_ARRAY_SIZE)
+                    ? ObjectInputFilter.Status.REJECTED
+                    : ObjectInputFilter.Status.UNDECIDED;
             }
             if (String.class == clazz
                     || java.lang.Number.class.isAssignableFrom(clazz)
--- a/src/share/classes/sun/security/pkcs11/Config.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/security/pkcs11/Config.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.io.*;
 import static java.io.StreamTokenizer.*;
 import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 import java.security.*;
@@ -213,7 +214,8 @@
             }
         }
         if (reader == null) {
-            reader = new BufferedReader(new InputStreamReader(in));
+            reader = new BufferedReader(new InputStreamReader(in,
+                    StandardCharsets.ISO_8859_1));
         }
         parsedKeywords = new HashSet<String>();
         st = new StreamTokenizer(reader);
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1778,7 +1778,12 @@
                 try {
                     readRecord(inrec, true);
                 } catch (SocketTimeoutException e) {
-                    // if time out, ignore the exception and continue
+                    if ((debug != null) && Debug.isOn("ssl")) {
+                        System.out.println(
+                            Thread.currentThread().getName() +
+                            ", received Exception: " + e);
+                    }
+                    fatal((byte)(-1), "Did not receive close_notify from peer", e);
                 }
             }
             inrec = null;
--- a/src/share/classes/sun/security/util/Pem.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/security/util/Pem.java	Thu Mar 15 03:52:16 2018 +0000
@@ -26,6 +26,7 @@
 package sun.security.util;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 
 /**
@@ -42,7 +43,8 @@
      * @throws java.io.IOException if input is invalid
      */
     public static byte[] decode(String input) throws IOException {
-        byte[] src = input.replaceAll("\\s+", "").getBytes();
+        byte[] src = input.replaceAll("\\s+", "")
+                .getBytes(StandardCharsets.ISO_8859_1);
         try {
             return Base64.getDecoder().decode(src);
         } catch (IllegalArgumentException e) {
--- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Thu Mar 15 03:52:16 2018 +0000
@@ -259,9 +259,6 @@
     // Home Button
     File homeDir = fsv.getHomeDirectory();
     String toolTipText = homeFolderToolTipText;
-    if (fsv.isRoot(homeDir)) {
-        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
-    }
 
     JButton b = new JButton(homeFolderIcon);
     b.setToolTipText(toolTipText);
--- a/src/share/lib/security/java.security-aix	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/lib/security/java.security-aix	Thu Mar 15 03:52:16 2018 +0000
@@ -898,10 +898,33 @@
 #
 # The filter pattern uses the same format as jdk.serialFilter.
 # This filter can override the builtin filter if additional types need to be
-# allowed or rejected from the RMI Registry.
+# allowed or rejected from the RMI Registry or to decrease limits but not
+# to increase limits.
+# If the limits (maxdepth, maxrefs, or maxbytes) are exceeded, the object is rejected.
+#
+# Each non-array type is allowed or rejected if it matches one of the patterns,
+# evaluated from left to right, and is otherwise allowed. Arrays of any
+# component type, including subarrays and arrays of primitives, are allowed.
+#
+# Array construction of any component type, including subarrays and arrays of
+# primitives, are allowed unless the length is greater than the maxarray limit.
+# The filter is applied to each array element.
 #
-#sun.rmi.registry.registryFilter=pattern;pattern
-
+# The built-in filter allows subclasses of allowed classes and
+# can approximately be represented as the pattern:
+#
+#sun.rmi.registry.registryFilter=\
+#    maxarray=1000000;\
+#    maxdepth=20;\
+#    java.lang.String;\
+#    java.lang.Number;\
+#    java.lang.reflect.Proxy;\
+#    java.rmi.Remote;\
+#    sun.rmi.server.UnicastRef;\
+#    sun.rmi.server.RMIClientSocketFactory;\
+#    sun.rmi.server.RMIServerSocketFactory;\
+#    java.rmi.activation.ActivationID;\
+#    java.rmi.server.UID
 #
 # RMI Distributed Garbage Collector (DGC) Serial Filter
 #
--- a/src/share/lib/security/java.security-linux	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/lib/security/java.security-linux	Thu Mar 15 03:52:16 2018 +0000
@@ -901,7 +901,9 @@
 #
 # The filter pattern uses the same format as jdk.serialFilter.
 # This filter can override the builtin filter if additional types need to be
-# allowed or rejected from the RMI Registry.
+# allowed or rejected from the RMI Registry or to decrease limits but not
+# to increase limits.
+# If the limits (maxdepth, maxrefs, or maxbytes) are exceeded, the object is rejected.
 #
 # The maxdepth of any array passed to the RMI Registry is set to
 # 10000.  The maximum depth of the graph is set to 20.
@@ -910,6 +912,26 @@
 #sun.rmi.registry.registryFilter=pattern;pattern
 
 #
+# Array construction of any component type, including subarrays and arrays of
+# primitives, are allowed unless the length is greater than the maxarray limit.
+# The filter is applied to each array element.
+#
+# The built-in filter allows subclasses of allowed classes and
+# can approximately be represented as the pattern:
+#
+#sun.rmi.registry.registryFilter=\
+#    maxarray=1000000;\
+#    maxdepth=20;\
+#    java.lang.String;\
+#    java.lang.Number;\
+#    java.lang.reflect.Proxy;\
+#    java.rmi.Remote;\
+#    sun.rmi.server.UnicastRef;\
+#    sun.rmi.server.RMIClientSocketFactory;\
+#    sun.rmi.server.RMIServerSocketFactory;\
+#    java.rmi.activation.ActivationID;\
+#    java.rmi.server.UID
+#
 # RMI Distributed Garbage Collector (DGC) Serial Filter
 #
 # The filter pattern uses the same format as jdk.serialFilter.
--- a/src/share/lib/security/java.security-macosx	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/lib/security/java.security-macosx	Thu Mar 15 03:52:16 2018 +0000
@@ -902,10 +902,33 @@
 #
 # The filter pattern uses the same format as jdk.serialFilter.
 # This filter can override the builtin filter if additional types need to be
-# allowed or rejected from the RMI Registry.
+# allowed or rejected from the RMI Registry or to decrease limits but not
+# to increase limits.
+# If the limits (maxdepth, maxrefs, or maxbytes) are exceeded, the object is rejected.
+#
+# Each non-array type is allowed or rejected if it matches one of the patterns,
+# evaluated from left to right, and is otherwise allowed. Arrays of any
+# component type, including subarrays and arrays of primitives, are allowed.
+#
+# Array construction of any component type, including subarrays and arrays of
+# primitives, are allowed unless the length is greater than the maxarray limit.
+# The filter is applied to each array element.
 #
-#sun.rmi.registry.registryFilter=pattern;pattern
-
+# The built-in filter allows subclasses of allowed classes and
+# can approximately be represented as the pattern:
+#
+#sun.rmi.registry.registryFilter=\
+#    maxarray=1000000;\
+#    maxdepth=20;\
+#    java.lang.String;\
+#    java.lang.Number;\
+#    java.lang.reflect.Proxy;\
+#    java.rmi.Remote;\
+#    sun.rmi.server.UnicastRef;\
+#    sun.rmi.server.RMIClientSocketFactory;\
+#    sun.rmi.server.RMIServerSocketFactory;\
+#    java.rmi.activation.ActivationID;\
+#    java.rmi.server.UID
 #
 # RMI Distributed Garbage Collector (DGC) Serial Filter
 #
--- a/src/share/lib/security/java.security-solaris	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/lib/security/java.security-solaris	Thu Mar 15 03:52:16 2018 +0000
@@ -901,10 +901,33 @@
 #
 # The filter pattern uses the same format as jdk.serialFilter.
 # This filter can override the builtin filter if additional types need to be
-# allowed or rejected from the RMI Registry.
+# allowed or rejected from the RMI Registry or to decrease limits but not
+# to increase limits.
+# If the limits (maxdepth, maxrefs, or maxbytes) are exceeded, the object is rejected.
+#
+# Each non-array type is allowed or rejected if it matches one of the patterns,
+# evaluated from left to right, and is otherwise allowed. Arrays of any
+# component type, including subarrays and arrays of primitives, are allowed.
+#
+# Array construction of any component type, including subarrays and arrays of
+# primitives, are allowed unless the length is greater than the maxarray limit.
+# The filter is applied to each array element.
 #
-#sun.rmi.registry.registryFilter=pattern;pattern
-
+# The built-in filter allows subclasses of allowed classes and
+# can approximately be represented as the pattern:
+#
+#sun.rmi.registry.registryFilter=\
+#    maxarray=1000000;\
+#    maxdepth=20;\
+#    java.lang.String;\
+#    java.lang.Number;\
+#    java.lang.reflect.Proxy;\
+#    java.rmi.Remote;\
+#    sun.rmi.server.UnicastRef;\
+#    sun.rmi.server.RMIClientSocketFactory;\
+#    sun.rmi.server.RMIServerSocketFactory;\
+#    java.rmi.activation.ActivationID;\
+#    java.rmi.server.UID
 #
 # RMI Distributed Garbage Collector (DGC) Serial Filter
 #
--- a/src/share/lib/security/java.security-windows	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/lib/security/java.security-windows	Thu Mar 15 03:52:16 2018 +0000
@@ -902,10 +902,33 @@
 #
 # The filter pattern uses the same format as jdk.serialFilter.
 # This filter can override the builtin filter if additional types need to be
-# allowed or rejected from the RMI Registry.
+# allowed or rejected from the RMI Registry or to decrease limits but not
+# to increase limits.
+# If the limits (maxdepth, maxrefs, or maxbytes) are exceeded, the object is rejected.
+#
+# Each non-array type is allowed or rejected if it matches one of the patterns,
+# evaluated from left to right, and is otherwise allowed. Arrays of any
+# component type, including subarrays and arrays of primitives, are allowed.
+#
+# Array construction of any component type, including subarrays and arrays of
+# primitives, are allowed unless the length is greater than the maxarray limit.
+# The filter is applied to each array element.
 #
-#sun.rmi.registry.registryFilter=pattern;pattern
-
+# The built-in filter allows subclasses of allowed classes and
+# can approximately be represented as the pattern:
+#
+#sun.rmi.registry.registryFilter=\
+#    maxarray=1000000;\
+#    maxdepth=20;\
+#    java.lang.String;\
+#    java.lang.Number;\
+#    java.lang.reflect.Proxy;\
+#    java.rmi.Remote;\
+#    sun.rmi.server.UnicastRef;\
+#    sun.rmi.server.RMIClientSocketFactory;\
+#    sun.rmi.server.RMIServerSocketFactory;\
+#    java.rmi.activation.ActivationID;\
+#    java.rmi.server.UID
 #
 # RMI Distributed Garbage Collector (DGC) Serial Filter
 #
--- a/src/share/native/sun/font/FontInstanceAdapter.cpp	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/native/sun/font/FontInstanceAdapter.cpp	Thu Mar 15 03:52:16 2018 +0000
@@ -136,12 +136,18 @@
     }
 
     LEGlyphID id = (LEGlyphID)env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, (jint)mappedChar);
+    if ((int)id < 0) {
+        id = 0;
+    }
     return id;
 }
 
 LEGlyphID FontInstanceAdapter::mapCharToGlyph(LEUnicode32 ch) const
 {
     LEGlyphID id = (LEGlyphID)env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, ch);
+    if ((int)id < 0) {
+        id = 0;
+    }
     return id;
 }
 
@@ -189,8 +195,12 @@
         return 1;
     }
 
-    return (LEGlyphID)env->CallIntMethod(font2D, sunFontIDs.charToGlyphMID,
+    LEGlyphID id = (LEGlyphID)env->CallIntMethod(font2D, sunFontIDs.charToGlyphMID,
                                          mappedChar);
+    if ((int)id < 0) {
+       id = 0;
+    }
+   return id;
 }
 
 void FontInstanceAdapter::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
--- a/src/share/native/sun/management/GcInfoBuilder.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/share/native/sun/management/GcInfoBuilder.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,9 +87,32 @@
     for (i = 0; i < num_attributes; i++) {
         nativeTypes[i] = ext_att_info[i].type;
         attName = (*env)->NewStringUTF(env, ext_att_info[i].name);
-        desc = (*env)->NewStringUTF(env, ext_att_info[i].description);
+        if ((*env)->ExceptionCheck(env)) {
+           free(ext_att_info);
+           free(nativeTypes);
+           return;
+        }
+
         (*env)->SetObjectArrayElement(env, attributeNames, i, attName);
+        if ((*env)->ExceptionCheck(env)) {
+           free(ext_att_info);
+           free(nativeTypes);
+           return;
+        }
+
+        desc = (*env)->NewStringUTF(env, ext_att_info[i].description);
+        if ((*env)->ExceptionCheck(env)) {
+           free(ext_att_info);
+           free(nativeTypes);
+           return;
+        }
+
         (*env)->SetObjectArrayElement(env, descriptions, i, desc);
+        if ((*env)->ExceptionCheck(env)) {
+           free(ext_att_info);
+           free(nativeTypes);
+           return;
+        }
     }
     (*env)->SetCharArrayRegion(env, types, 0, num_attributes, nativeTypes);
 
--- a/src/solaris/native/java/lang/java_props_md.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/solaris/native/java/lang/java_props_md.c	Thu Mar 15 03:52:16 2018 +0000
@@ -463,8 +463,21 @@
         struct utsname name;
         uname(&name);
         sprops.os_name = strdup(name.sysname);
+#ifdef _AIX
+        {
+            char *os_version = malloc(strlen(name.version) +
+                                      strlen(name.release) + 2);
+            if (os_version != NULL) {
+                strcpy(os_version, name.version);
+                strcat(os_version, ".");
+                strcat(os_version, name.release);
+            }
+            sprops.os_version = os_version;
+        }
+#else
         sprops.os_version = strdup(name.release);
-#endif
+#endif /* _AIX   */
+#endif /* MACOSX */
 
         sprops.os_arch = ARCHPROPNAME;
 
--- a/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
+#include "jvm.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -149,15 +150,26 @@
             res = errno;
         }
 
-        /* release p here before we throw an I/O exception */
-        if (isCopy) {
-            JNU_ReleaseStringPlatformChars(env, path, p);
-        }
-
         if (res == 0) {
-            if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
-                 ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
-                JNU_ThrowIOException(env, "well-known file is not secure");
+            char msg[100];
+            jboolean isError = JNI_FALSE;
+            if (sb.st_uid != uid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
+                isError = JNI_TRUE;
+            } else if (sb.st_gid != gid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
+                isError = JNI_TRUE;
+            } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
+                isError = JNI_TRUE;
+            }
+            if (isError) {
+                char buf[256];
+                jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
+                JNU_ThrowIOException(env, buf);
             }
         } else {
             char* msg = strdup(strerror(res));
@@ -166,6 +178,10 @@
                 free(msg);
             }
         }
+
+        if (isCopy) {
+            JNU_ReleaseStringPlatformChars(env, path, p);
+        }
     }
 }
 
--- a/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
+#include "jvm.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -367,15 +368,26 @@
             res = errno;
         }
 
-        /* release p here before we throw an I/O exception */
-        if (isCopy) {
-            JNU_ReleaseStringPlatformChars(env, path, p);
-        }
-
         if (res == 0) {
-            if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
-                 ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
-                JNU_ThrowIOException(env, "well-known file is not secure");
+            char msg[100];
+            jboolean isError = JNI_FALSE;
+            if (sb.st_uid != uid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
+                isError = JNI_TRUE;
+            } else if (sb.st_gid != gid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
+                isError = JNI_TRUE;
+            } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
+                isError = JNI_TRUE;
+            }
+            if (isError) {
+                char buf[256];
+                jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
+                JNU_ThrowIOException(env, buf);
             }
         } else {
             char* msg = strdup(strerror(res));
@@ -384,6 +396,10 @@
                 free(msg);
             }
         }
+
+        if (isCopy) {
+            JNU_ReleaseStringPlatformChars(env, path, p);
+        }
     }
 }
 
--- a/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c	Wed Mar 07 05:37:58 2018 +0000
+++ b/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c	Thu Mar 15 03:52:16 2018 +0000
@@ -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
@@ -35,6 +35,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
+#include "jvm.h"
 
 #include "sun_tools_attach_SolarisVirtualMachine.h"
 
@@ -112,15 +113,26 @@
             res = errno;
         }
 
-        /* release p here before we throw an I/O exception */
-        if (isCopy) {
-            JNU_ReleaseStringPlatformChars(env, path, p);
-        }
-
         if (res == 0) {
-            if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
-                 ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
-                JNU_ThrowIOException(env, "well-known file is not secure");
+            char msg[100];
+            jboolean isError = JNI_FALSE;
+            if (sb.st_uid != uid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
+                isError = JNI_TRUE;
+            } else if (sb.st_gid != gid) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
+                isError = JNI_TRUE;
+            } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
+                jio_snprintf(msg, sizeof(msg)-1,
+                    "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
+                isError = JNI_TRUE;
+            }
+            if (isError) {
+                char buf[256];
+                jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
+                JNU_ThrowIOException(env, buf);
             }
         } else {
             char* msg = strdup(strerror(res));
@@ -129,6 +141,10 @@
                 free(msg);
             }
         }
+
+        if (isCopy) {
+            JNU_ReleaseStringPlatformChars(env, path, p);
+        }
     }
 }
 
--- a/test/TEST.groups	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/TEST.groups	Thu Mar 15 03:52:16 2018 +0000
@@ -333,8 +333,7 @@
   java/util/Collections/EmptyIterator.java \
   java/util/concurrent/locks/Lock/TimedAcquireLeak.java \
   java/util/jar/JarInputStream/ExtraFileInMetaInf.java \
-  java/util/logging/AnonLoggerWeakRefLeak.sh \
-  java/util/logging/LoggerWeakRefLeak.sh \
+  java/util/logging/TestLoggerWeakRefLeak.java \
   java/util/zip/3GBZipFiles.sh \
   jdk/lambda/FDTest.java \
   jdk/lambda/separate/Compiler.java \
--- a/test/com/sun/tools/attach/StartManagementAgent.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/com/sun/tools/attach/StartManagementAgent.java	Thu Mar 15 03:52:16 2018 +0000
@@ -93,7 +93,7 @@
         } catch(AttachOperationFailedException ex) {
             // We expect parsing of "apa" above to fail, but if the file path
             // can't be read we get a different exception message
-            if (!ex.getMessage().contains("java.lang.NumberFormatException")) {
+            if (!ex.getMessage().contains("Invalid com.sun.management.jmxremote.port number")) {
                 throw ex;
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/FocusTransitionTest/FocusTransitionTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8155197
+ * @summary Tests whether the value of mostRecentFocusOwner for a window is correct, if
+ *          another window is displayed during focus transition
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main FocusTransitionTest
+ */
+
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class FocusTransitionTest {
+    private static Frame frame;
+    private static TextField textField1;
+    private static Button button;
+
+    public static void main(String[] args) throws InterruptedException {
+        try {
+            Robot robot = Util.createRobot();
+
+            createAndShowGUI();
+            Util.waitForIdle(robot);
+
+            for (int i = 0; i < 100; i++) {
+                Util.clickOnComp(button, robot);
+
+                synchronized (frame) {
+                    frame.wait();
+                }
+                Util.waitForIdle(robot);
+
+                Component focusOwner = frame.getMostRecentFocusOwner();
+                if (focusOwner != textField1) {
+                    throw new RuntimeException("Test FAILED: incorrect focus owner!");
+                }
+            }
+        } finally {
+            if (frame != null) {
+                frame.dispose();
+            }
+        }
+    }
+
+    private static void createAndShowGUI() {
+        frame = new Frame("Test Frame");
+
+        textField1 = new TextField(5);
+
+        button = new Button("Go");
+        button.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                textField1.requestFocusInWindow();
+                startUpdate();
+            }
+        });
+
+        frame.setLayout(new FlowLayout());
+        frame.setSize(400, 200);
+        frame.add(textField1);
+        frame.add(new TextField(5));
+        frame.add(new TextField(5));
+        frame.add(button);
+        frame.setVisible(true);
+    }
+
+    private static void startUpdate() {
+        UpdateThread updateThread = new UpdateThread(frame, 10);
+        updateThread.start();
+    }
+}
+
+class UpdateThread extends Thread {
+    private final Frame frame;
+    private final int delay;
+
+    UpdateThread(Frame frame, int delay) {
+        this.frame = frame;
+        this.delay = delay;
+    }
+
+    @Override
+    public void run() {
+        Dialog dialog = new Dialog(frame);
+        dialog.setSize(300, 100);
+        dialog.setVisible(true);
+
+        try {
+            sleep(delay);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+
+        dialog.setVisible(false);
+        dialog.dispose();
+
+        synchronized (frame) {
+            frame.notify();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/RollbackFocusFromAnotherWindowTest/RollbackFocusFromAnotherWindowTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,114 @@
+/*
+ * 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       8139218
+  @summary   Dialog that opens and closes quickly changes focus in original
+             focusowner
+  @author    Semyon Sadetsky: area=awt-focus
+  @run       main RollbackFocusFromAnotherWindowTest
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+public class RollbackFocusFromAnotherWindowTest extends JFrame implements KeyListener
+{
+    private static RollbackFocusFromAnotherWindowTest tfs;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        robot = new Robot();
+
+        SwingUtilities.invokeAndWait(() -> {
+            tfs = new RollbackFocusFromAnotherWindowTest();
+            tfs.setVisible(true);
+        });
+
+        robot.waitForIdle();
+        robot.delay(200);
+
+        try {
+            for (int i = 0; i < 10; i++) {
+                robot.keyPress(KeyEvent.VK_A);
+                robot.delay(10);
+                robot.keyRelease(KeyEvent.VK_A);
+                robot.waitForIdle();
+                robot.delay(200);
+                SwingUtilities.invokeAndWait(() -> {
+                    String name = tfs.getFocusOwner().getName();
+                    System.out.println(name);
+                    if (!"Comp0".equals(name)) {
+                        throw new RuntimeException(
+                                "Focus is not restored correctly");
+                    }
+                });
+            }
+            System.out.println("ok");
+        } finally {
+            SwingUtilities.invokeLater(() -> tfs.dispose());
+        }
+    }
+
+    public RollbackFocusFromAnotherWindowTest()
+    {
+        setUndecorated(true);
+        Container c = getContentPane();
+        c.setLayout(new FlowLayout());
+        for (int i = 0; i < 10; i++)
+        {
+            JTextField tf = new JTextField("" + i, 10);
+            tf.setName("Comp" + i);
+            c.add(tf);
+            tf.addKeyListener(this);
+        }
+        pack();
+    }
+
+    @Override
+    public void keyTyped(KeyEvent e) {
+
+    }
+
+    @Override
+    public void keyPressed(KeyEvent e) {
+        Frame frame = new Frame();
+        frame.setVisible(true);
+        try {
+            Thread.sleep(2);
+        } catch (InterruptedException e1) {
+            e1.printStackTrace();
+        }
+        frame.dispose();
+    }
+
+    @Override
+    public void keyReleased(KeyEvent e) {
+
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/InputMethods/InputMethodKeyEventsTest/InputMethodKeyEventsTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8177414
+ * @summary KEY_PRESSED and KEY_TYPED events are not generated if a key's held
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/manual InputMethodKeyEventsTest
+ */
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class InputMethodKeyEventsTest {
+    private static final AtomicBoolean testCompleted = new AtomicBoolean(false);
+    private static volatile boolean testResult = false;
+
+    private static Dialog controlDialog;
+    private static Frame testFrame;
+
+    private static final String instructions =
+            "Verify that KEY_PRESSED and KEY_TYPED events are generated after a key's " +
+            "\npressed and held.\n" +
+            "\nThis test is for OS X only. For other platforms please simply press \"Pass\".\n" +
+            "\n1. Go to \"System Preferences -> Keyboard -> Input Sources\" and add \"British\" IM." +
+            "\n2. Set current IM to \"British\"." +
+            "\n3. Set focus to the frame located at north-west corner." +
+            "\n4. Pres and hold the \"i\" key for 3 seconds." +
+            "\n5. Press and release the \"i\" key again. Use log area to ensure that " +
+            "\n   KEY_TYPED and KEY_PRESSED events are still generated." +
+            "\nIf KEY_PRESSED, KEY_TYPED and KEY_RELEASED are generated for every key press then " +
+            "\npress \"Pass\", otherwise press \"Fail\".";
+
+    public static void main(String[] args) {
+        try {
+            Robot robot = Util.createRobot();
+
+            createAndShowGUI();
+            Util.waitForIdle(robot);
+
+            Util.waitForCondition(testCompleted);
+            if (!testResult) {
+                throw new RuntimeException("Test FAILED!");
+            }
+        } finally {
+            if (controlDialog != null) {
+                controlDialog.dispose();
+            }
+            if (testFrame != null) {
+                testFrame.dispose();
+            }
+        }
+    }
+
+    private static void createAndShowGUI() {
+        controlDialog = new Dialog((Frame)null, "InputMethodKeyEventsTest");
+
+        TextArea messageArea = new TextArea(instructions, 15, 80, TextArea.SCROLLBARS_BOTH);
+        controlDialog.add("North", messageArea);
+
+        TextArea logArea = new TextArea("Test's logs are displayed here\n", 15, 80, TextArea.SCROLLBARS_BOTH);
+        controlDialog.add("Center", logArea);
+
+        Button passedButton = new Button("Pass");
+        passedButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                testResult = true;
+                completeTest();
+            }
+        });
+
+        Button failedButton = new Button("Fail");
+        failedButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                testResult = false;
+                completeTest();
+            }
+        });
+
+        Panel buttonPanel = new Panel();
+        buttonPanel.add("West",passedButton);
+        buttonPanel.add("East", failedButton);
+        controlDialog.add("South", buttonPanel);
+
+        controlDialog.setBounds(250, 0, 500, 500);
+        controlDialog.setVisible(true);
+
+        testFrame = new Frame("InputMethodKeyEventsTest");
+        testFrame.setSize(200, 200);
+        testFrame.addKeyListener(new KeyListener() {
+            @Override
+            public void keyTyped(KeyEvent e) {
+                logArea.append("KEY_TYPED keyCode = " + e.getKeyCode() + "\n");
+            }
+
+            @Override
+            public void keyPressed(KeyEvent e) {
+                logArea.append("KEY_PRESSED keyCode = " + e.getKeyCode() + "\n");
+            }
+
+            @Override
+            public void keyReleased(KeyEvent e) {
+                logArea.append("KEY_RELEASED keyCode = " + e.getKeyCode() + "\n");
+            }
+        });
+        testFrame.setVisible(true);
+    }
+
+    private static void completeTest() {
+        testCompleted.set(true);
+        synchronized (testCompleted) {
+            testCompleted.notifyAll();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/Fallback/MissingGlyphTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8147002
+ * @summary  Verifies if Arabic character alef is rendered in osx
+ * @run main/manual MissingGlyphTest
+ */
+import java.awt.Font;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+public class MissingGlyphTest {
+    private static Thread mainThread;
+    private static boolean testPassed;
+    private static boolean testGeneratedInterrupt;
+    private static JFrame frame;
+
+    public static void main(String[] args) throws Exception {
+        if (!System.getProperty("os.name").startsWith("Mac")) {
+            return;
+        }
+        SwingUtilities.invokeAndWait(() -> {
+            doTest(MissingGlyphTest::glyphTest);
+        });
+        mainThread = Thread.currentThread();
+        try {
+            Thread.sleep(180000);
+        } catch (InterruptedException e) {
+            if (!testPassed && testGeneratedInterrupt) {
+                throw new RuntimeException("Alef character is not rendered");
+            }
+        }
+        if (!testGeneratedInterrupt) {
+            throw new RuntimeException("user has not executed the test");
+        }
+    }
+
+    private static void glyphTest() {
+        frame = new JFrame("Test");
+        frame.add(new MyComponent());
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    public static synchronized void pass() {
+        testPassed = true;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    public static synchronized void fail() {
+        testPassed = false;
+        testGeneratedInterrupt = true;
+        mainThread.interrupt();
+    }
+
+    private static void doTest(Runnable action) {
+        String description
+                = " The test is supposed to display arabic alef character.\n"
+                + " If it resembles like the one shown in\n "
+                + " www.fileformat.info/info/unicode/char/0627/index.htm\n "
+                + " in Italic style ,press PASS.\n"
+                + " If the glyph is not shown or empty rectangle is shown, press FAIL";
+
+        final JDialog dialog = new JDialog();
+        dialog.setTitle("printBannerTest");
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton testButton = new JButton("Start Test");
+        final JButton passButton = new JButton("PASS");
+        passButton.setEnabled(false);
+        passButton.addActionListener((e) -> {
+            dialog.dispose();
+            frame.dispose();
+            pass();
+        });
+        final JButton failButton = new JButton("FAIL");
+        failButton.setEnabled(false);
+        failButton.addActionListener((e) -> {
+            dialog.dispose();
+            frame.dispose();
+            fail();
+        });
+        testButton.addActionListener((e) -> {
+            testButton.setEnabled(false);
+            action.run();
+            passButton.setEnabled(true);
+            failButton.setEnabled(true);
+        });
+        JPanel mainPanel = new JPanel(new BorderLayout());
+        mainPanel.add(textArea, BorderLayout.CENTER);
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(testButton);
+        buttonPanel.add(passButton);
+        buttonPanel.add(failButton);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+        dialog.add(mainPanel);
+        dialog.pack();
+        dialog.setVisible(true);
+        dialog.addWindowListener(new WindowAdapter() {
+           @Override
+            public void windowClosing(WindowEvent e) {
+                System.out.println("main dialog closing");
+                testGeneratedInterrupt = false;
+                mainThread.interrupt();
+            }
+        });
+    }
+}
+
+class MyComponent extends JComponent {
+    private final Font font = new Font("Menlo", Font.ITALIC, 100);
+    private final String text = "\u0627"; // Arabic letter alef
+
+    @Override
+    protected void paintComponent(Graphics g) {
+        if (font.canDisplayUpTo(text) == -1) {
+            g.setColor(Color.black);
+            g.setFont(font);
+            g.drawString(text, 70, 110);
+        }
+    }
+}
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/TextLayout/NegativeGlyphIDException.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.image.BufferedImage;
+
+/**
+ * @test
+ * @bug 8190280
+ * @summary ensure no negative glyph ids propagate to code used by TextLayout
+ */
+
+public class NegativeGlyphIDException {
+    public static void main(String[] args) {
+        Font font = new Font("Monospaced", Font.PLAIN, 12);
+        String text = "\u0601";
+        FontRenderContext frc = new FontRenderContext(null, false, false);
+        TextLayout layout = new TextLayout(text, font, frc);
+        BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2d = bi.createGraphics();
+        layout.draw(g2d, 50.0f, 50.0f);
+        layout.getCaretShapes(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/TextLayout/OSXLigatureTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,82 @@
+/*
+ * 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 7162125
+ * @summary Test ligatures form on OS X.
+ */
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.font.TextAttribute;
+import java.util.HashMap;
+import java.util.Map;
+
+public class OSXLigatureTest {
+
+    public static void main(String[] args) {
+        if (!System.getProperty("os.name").startsWith("Mac")) {
+            return;
+        }
+        String ligStr = "ffi";
+        int w = 50, h = 50;
+
+        BufferedImage bi1 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D bi1Graphics = bi1.createGraphics();
+        bi1Graphics.setColor(Color.white);
+        bi1Graphics.fillRect(0, 0, w, h);
+        bi1Graphics.setColor(Color.black);
+        Font noLigFont = new Font("Gill Sans", Font.PLAIN, 30);
+        bi1Graphics.setFont(noLigFont);
+        bi1Graphics.drawString(ligStr, 10, 40);
+
+        BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D bi2Graphics = bi2.createGraphics();
+        bi2Graphics.setColor(Color.white);
+        bi2Graphics.fillRect(0, 0, w, h);
+        bi2Graphics.setColor(Color.black);
+        Map<TextAttribute, Object> attributes = new HashMap<>();
+        attributes.put(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON);
+        Font ligFont = noLigFont.deriveFont(attributes);
+        bi2Graphics.setFont(ligFont);
+        bi2Graphics.drawString(ligStr, 10, 40);
+
+        boolean same = true;
+        for (int x = 0; x < w; x++) {
+            for (int y = 0; y < h; y++) {
+                int c1 = bi1.getRGB(x, y);
+                int c2 = bi2.getRGB(x, y);
+                same &= (c1 == c2);
+            }
+            if (!same) {
+               break;
+            }
+        }
+        if (same) {
+            throw new RuntimeException("Images do not differ - no ligature");
+        }
+    }
+}
--- a/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -22,9 +22,8 @@
  */
 
 /* @test
-   @bug 8167102
+   @bug 8167102 8181659
    @summary PrintRequestAttributeSet breaks page size set using PageFormat
-   @ignore Exclude the test until 8167102 is resolved by a new reassessed fix
    @run main/manual WrongPaperPrintingTest
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/System/finalization/FinInterrupt.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4354680
+ * @summary runFinalization() should not clear or ignore interrupt bit
+ * @run main FinInterrupt
+ */
+
+public class FinInterrupt {
+    public static void main(String[] args) throws Exception {
+        Thread.currentThread().interrupt();
+        System.runFinalization();
+        if (Thread.interrupted()) {
+            System.out.println("Passed: interrupt bit was still set.");
+        } else {
+            throw new AssertionError("interrupt bit was cleared");
+        }
+    }
+}
--- a/test/java/net/Authenticator/B4769350.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/java/net/Authenticator/B4769350.java	Thu Mar 15 03:52:16 2018 +0000
@@ -66,14 +66,15 @@
             this.allowerror = allowerror;
         }
 
+        @Override
         public void run () {
             try {
                 URI u = new URI ("http", authority, path, null, null);
                 URL url = u.toURL();
                 URLConnection urlc = url.openConnection();
-                InputStream is = urlc.getInputStream();
-                read (is);
-                is.close();
+                try (InputStream is = urlc.getInputStream()) {
+                    read (is);
+                }
             } catch (URISyntaxException  e) {
                 System.out.println (e);
                 error = true;
@@ -91,8 +92,6 @@
     class Server implements AutoCloseable {
         HttpServer server;
         Executor executor;
-        CyclicBarrier t1Cond1;
-        CyclicBarrier t1Cond2;
 
         public String getAddress() {
             return server.getAddress().getHostName();
@@ -126,8 +125,7 @@
                     new AuthenticationHandlerT3bc());
             server.createContext("/test/realm4/t3c",
                     new AuthenticationHandlerT3bc());
-            t1Cond1 = new CyclicBarrier(2);
-            t1Cond2 = new CyclicBarrier(2);
+            t1Cond1 = new CyclicBarrier(3);
             server.start();
         }
 
@@ -135,6 +133,7 @@
             return server.getAddress().getPort();
         }
 
+        @Override
         public void close() {
             if (executor != null)
                 ((ExecutorService)executor).shutdownNow();
@@ -163,7 +162,6 @@
                             break;
                         case 1:
                             t1Cond1.await();
-                            t1cond2latch.await();
                             AuthenticationHandler.okReply(exchange);
                             break;
                         default:
@@ -192,8 +190,6 @@
                             break;
                         case 1:
                             t1Cond1.await();
-                            t1cond1latch.countDown();
-                            t1cond2latch.await();
                             AuthenticationHandler.okReply(exchange);
                             break;
                         default:
@@ -216,13 +212,6 @@
                     case 0:
                         AuthenticationHandler.errorReply(exchange,
                                 "Basic realm=\"realm1\"");
-                        try {
-                            t1Cond2.await();
-                        } catch (InterruptedException |
-                                 BrokenBarrierException e)
-                        {
-                            throw new RuntimeException(e);
-                        }
                         break;
                     case 1:
                         AuthenticationHandler.okReply(exchange);
@@ -244,14 +233,6 @@
                     case 0:
                         AuthenticationHandler.errorReply(exchange,
                                 "Basic realm=\"realm2\"");
-                        try {
-                            t1Cond2.await();
-                        } catch (InterruptedException |
-                                 BrokenBarrierException e)
-                        {
-                            throw new RuntimeException(e);
-                        }
-                        t1cond2latch.countDown();
                         break;
                     case 1:
                         AuthenticationHandler.okReply(exchange);
@@ -377,9 +358,9 @@
             exchange.getResponseHeaders().add("Connection", "close");
             String response = "Hello .";
             exchange.sendResponseHeaders(200, response.getBytes().length);
-            OutputStream os = exchange.getResponseBody();
-            os.write(response.getBytes());
-            os.close();
+            try (OutputStream os = exchange.getResponseBody()) {
+                os.write(response.getBytes());
+            }
             exchange.close();
         }
     }
@@ -391,10 +372,9 @@
 
     static Client c1,c2,c3,c4,c5,c6,c7,c8,c9;
 
-    static CountDownLatch t1cond1latch;
-    static CountDownLatch t1cond2latch;
     static CountDownLatch t2condlatch;
     static CountDownLatch t3cond1;
+    static CyclicBarrier t1Cond1;
 
     static void doServerTests (String authority, Server server) throws Exception
     {
@@ -404,10 +384,8 @@
         c2 = new Client (authority, "/test/realm2/t1b", false);
         c3 = new Client (authority, "/test/realm1/t1c", false);
         c4 = new Client (authority, "/test/realm2/t1d", false);
-        t1cond1latch = new CountDownLatch(1);
-        t1cond2latch = new CountDownLatch(1);
         c1.start(); c2.start();
-        t1cond1latch.await();
+        t1Cond1.await();
         c3.start(); c4.start();
         c1.join(); c2.join(); c3.join(); c4.join();
 
--- a/test/java/rmi/registry/serialFilter/RegistryFilterTest.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/java/rmi/registry/serialFilter/RegistryFilterTest.java	Thu Mar 15 03:52:16 2018 +0000
@@ -35,7 +35,6 @@
 import java.util.Objects;
 
 import org.testng.Assert;
-import org.testng.TestNG;
 import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -43,10 +42,6 @@
 /*
  * @test
  * @library /java/rmi/testlibrary
- * @modules java.rmi/sun.rmi.registry
- *          java.rmi/sun.rmi.server
- *          java.rmi/sun.rmi.transport
- *          java.rmi/sun.rmi.transport.tcp
  * @build TestLibrary
  * @summary Test filters for the RMI Registry
  * @run testng/othervm RegistryFilterTest
@@ -65,21 +60,14 @@
 
     static final int REGISTRY_MAX_DEPTH = 20;
 
-    static final int REGISTRY_MAX_ARRAY = 10000;
+    static final int REGISTRY_MAX_ARRAY = 1_000_000;
 
     static final String registryFilter =
             System.getProperty("sun.rmi.registry.registryFilter",
                     Security.getProperty("sun.rmi.registry.registryFilter"));
 
-    @DataProvider(name = "bindAllowed")
-    static Object[][] bindAllowedObjects() {
-        Object[][] objects = {
-        };
-        return objects;
-    }
-
     /**
-     * Data RMI Regiry bind test.
+     * Data RMI Registry bind test.
      * - name
      * - Object
      * - true/false if object is blacklisted by a filter (implicit or explicit)
@@ -90,9 +78,11 @@
         Object[][] data = {
                 { "byte[max]", new XX(new byte[REGISTRY_MAX_ARRAY]), false },
                 { "String", new XX("now is the time"), false},
-                { "String[]", new XX(new String[3]), false},
-                { "Long[4]", new XX(new Long[4]), registryFilter != null },
+                { "String[3]", new XX(new String[3]), false},
+                { "Long[4]", new XX(new Long[4]), false },
+                { "Object[REGISTRY_MAX_ARRAY]", new XX(new Object[REGISTRY_MAX_ARRAY]), false },
                 { "rej-byte[toobig]", new XX(new byte[REGISTRY_MAX_ARRAY + 1]), true },
+                { "rej-Object[toobig]", new XX(new Object[REGISTRY_MAX_ARRAY + 1]), true },
                 { "rej-MarshalledObject", createMarshalledObject(), true },
                 { "rej-RejectableClass", new RejectableClass(), registryFilter != null},
         };
--- a/test/java/util/logging/AnonLoggerWeakRefLeak.java	Wed Mar 07 05:37:58 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.logging.*;
-
-public class AnonLoggerWeakRefLeak extends SimpleApplication {
-    // The test driver script will allow this program to run until we
-    // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
-    // observed. For this particular WeakReference leak, the count
-    // was always observed to be increasing so if we get a decreasing
-    // count, then the leak is fixed in the bits being tested.
-    // Two minutes has been enough time to observe a decrease in
-    // fixed bits on overloaded systems, but the test will likely
-    // finish more quickly.
-    public static int DEFAULT_LOOP_TIME = 120;  // time is in seconds
-
-    // execute the AnonLoggerWeakRefLeak app work
-    public void doMyAppWork(String[] args) throws Exception {
-        int loop_time = 0;
-        int max_loop_time = DEFAULT_LOOP_TIME;
-
-        // args[0] is the port-file
-        if (args.length < 2) {
-            System.out.println("INFO: using default time of "
-                + max_loop_time + " seconds.");
-        } else {
-            try {
-                max_loop_time = Integer.parseInt(args[1]);
-            } catch (NumberFormatException nfe) {
-                throw new RuntimeException("Error: '" + args[1]
-                    + "': is not a valid seconds value.");
-            }
-        }
-
-        long count = 0;
-        long now = 0;
-        long startTime = System.currentTimeMillis();
-
-        while (now < (startTime + (max_loop_time * 1000))) {
-            if ((count % 1000) == 0) {
-                // Print initial call count to let caller know that
-                // we're up and running and then periodically
-                System.out.println("INFO: call count = " + count);
-            }
-
-            for (int i = 0; i < 100; i++) {
-                // this Logger call is leaking a WeakReference in Logger.kids
-                java.util.logging.Logger.getAnonymousLogger();
-                count++;
-            }
-
-            try {
-                // delay for 1/10 of a second to avoid CPU saturation
-                Thread.sleep(100);
-            } catch (InterruptedException ie) {
-                // ignore any exceptions
-            }
-
-            now = System.currentTimeMillis();
-        }
-
-        System.out.println("INFO: final loop count = " + count);
-    }
-
-    public static void main(String[] args) throws Exception {
-        AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
-
-        SimpleApplication.setMyApp(myApp);
-
-        SimpleApplication.main(args);
-    }
-}
--- a/test/java/util/logging/AnonLoggerWeakRefLeak.sh	Wed Mar 07 05:37:58 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,254 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# 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 6942989
-# @summary Check for WeakReference leak in anonymous Logger objects
-# @author Daniel D. Daugherty
-#
-# @library ../../../sun/tools/common
-# @build SimpleApplication ShutdownSimpleApplication
-# @build AnonLoggerWeakRefLeak
-# @run shell/timeout=240 AnonLoggerWeakRefLeak.sh
-
-# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
-#
-
-. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
-. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
-
-
-TEST_NAME="AnonLoggerWeakRefLeak"
-TARGET_CLASS="java\.lang\.ref\.WeakReference"
-
-
-# MAIN begins here
-#
-
-seconds=
-if [ "$#" -gt 0 ]; then
-    seconds="$1"
-fi
-
-# see if this version of jmap supports the '-histo:live' option
-jmap_option="-histo:live"
-set +e
-"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
-status="$?"
-set -e
-if [ "$status" != 0 ]; then
-    # usage message doesn't show ':live' option
-
-    if $isWindows; then
-        # If SA isn't present, then jmap gives a different usage message
-        # that doesn't show the ':live' option. However, that's a bug that
-        # is covered by 6971851 so we try using the option just to be sure.
-        # For some reason, this problem has only been seen on OpenJDK6 on
-        # Windows. Not sure why.
-        set +e
-        # Note: Don't copy this code to try probing process 0 on Linux; it
-        # will kill the process group in strange ways.
-        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
-        status="$?"
-        set -e
-        if [ "$status" = 0 ]; then
-            # Usage message generated so flag the problem.
-            status=1
-        else
-            # No usage message so clear the flag.
-            status=0
-        fi
-    fi
-
-    if [ "$status" != 0 ]; then
-        echo "WARNING: 'jmap $jmap_option' is not supported on this platform"
-        echo "WARNING: so this test cannot work reliably. Aborting!"
-        exit 0
-    fi
-fi
-
-# Start application and use TEST_NAME.port for coordination
-startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
-
-finished_early=false
-
-decreasing_cnt=0
-increasing_cnt=0
-loop_cnt=0
-prev_instance_cnt=0
-
-MAX_JMAP_TRY_CNT=10
-jmap_retry_cnt=0
-loop_cnt_on_retry=0
-
-while true; do
-    # see if the target process has finished its run and bail if it has
-    set +e
-    grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
-    status="$?"
-    set -e
-    if [ "$status" = 0 ]; then
-        break
-    fi
-
-    # Output format for 'jmap -histo' in JDK1.5.0:
-    #
-    #     <#bytes> <#instances> <class_name>
-    #
-    # Output format for 'jmap -histo:live':
-    #
-    #     <num>: <#instances> <#bytes> <class_name>
-    #
-    set +e
-    "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
-    status="$?"
-    set -e
-
-    if [ "$status" != 0 ]; then
-        echo "INFO: jmap exited with exit code = $status"
-
-        # There are intermittent jmap failures; see 6498448.
-        #
-        # So far the following have been observed in a jmap call
-        # that was not in a race with target process termination:
-        #
-        # (Solaris specific, 2nd sample)
-        # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
-        # The -F option can be used when the target process is not responding
-        #
-        # (on Solaris so far)
-        # java.io.IOException
-        #
-        # (on Solaris so far, 1st sample)
-        # <pid>: Permission denied
-        #
-        sed 's/^/INFO: /' "$TEST_NAME.jmap"
-
-        if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
-            # loop count hasn't changed
-            jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
-        else
-            # loop count has changed so remember it
-            jmap_retry_cnt=1
-            loop_cnt_on_retry="$loop_cnt"
-        fi
-
-        # This is '-ge' because we have the original attempt plus
-        # MAX_JMAP_TRY_CNT - 1 retries.
-        if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
-            echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
-                "without making any progress."
-            echo "FAIL: jmap is unable to take any samples." >&2
-            killApplication
-            exit 2
-        fi
-
-        # short delay and try again
-        # Note: sleep 1 didn't help with "<pid>: Permission denied"
-        sleep 2
-        echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
-        continue
-    fi
-
-    set +e
-    instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
-        "$TEST_NAME.jmap" \
-        | sed '
-            # strip leading whitespace; does nothing in JDK1.5.0
-            s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <#bytes> in JDK1.5.0; does nothing otherwise
-            s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <num>: field; does nothing in JDK1.5.0
-            s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <class_name> field
-            s/'"${PATTERN_WS}"'.*//
-            '`
-    set -e
-    if [ -z "$instance_cnt" ]; then
-        echo "INFO: instance count is unexpectedly empty"
-        if [ "$loop_cnt" = 0 ]; then
-            echo "INFO: on the first iteration so no sample was found."
-            echo "INFO: There is likely a problem with the sed filter."
-            echo "INFO: start of jmap output:"
-            cat "$TEST_NAME.jmap"
-            echo "INFO: end of jmap output."
-            echo "FAIL: cannot find the instance count value." >&2
-            killApplication
-            exit 2
-        fi
-    else
-        echo "INFO: instance_cnt = $instance_cnt"
-
-        if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
-            increasing_cnt=`expr $increasing_cnt + 1`
-        else
-            # actually decreasing or the same
-            decreasing_cnt=`expr $decreasing_cnt + 1`
-
-            # For this particular WeakReference leak, the count was
-            # always observed to be increasing so if we get a decreasing
-            # or the same count, then the leak is fixed in the bits
-            # being tested.
-            echo "INFO: finishing early due to non-increasing instance count."
-            finished_early=true
-            killApplication
-            break
-        fi
-        prev_instance_cnt="$instance_cnt"
-    fi
-
-    # delay between samples
-    sleep 5
-
-    loop_cnt=`expr $loop_cnt + 1`
-done
-
-if [ $finished_early = false ]; then
-    stopApplication "$TEST_NAME.port"
-    waitForApplication
-fi
-
-echo "INFO: $TEST_NAME has finished running."
-echo "INFO: increasing_cnt = $increasing_cnt"
-echo "INFO: decreasing_cnt = $decreasing_cnt"
-if [ "$jmap_retry_cnt" -gt 0 ]; then
-    echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
-fi
-
-if [ "$loop_cnt" = 0 ]; then
-    echo "FAIL: jmap is unable to take any samples." >&2
-    exit 2
-fi
-
-echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
-if [ "$decreasing_cnt" = 0 ]; then
-    echo "INFO: is always increasing."
-    echo "FAIL: This indicates that there is a memory leak." >&2
-    exit 2
-fi
-
-echo "INFO: is not always increasing."
-echo "PASS: This indicates that there is not a memory leak."
-exit 0
--- a/test/java/util/logging/LoggerWeakRefLeak.java	Wed Mar 07 05:37:58 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.logging.*;
-
-public class LoggerWeakRefLeak extends SimpleApplication {
-    // The test driver script will allow this program to run until we
-    // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
-    // observed. For these particular WeakReference leaks, the count
-    // was always observed to be increasing so if we get a decreasing
-    // count, then the leaks are fixed in the bits being tested.
-    // Two minutes has been enough time to observe a decrease in
-    // fixed bits on overloaded systems, but the test will likely
-    // finish more quickly.
-    public static int DEFAULT_LOOP_TIME = 120;  // time is in seconds
-
-    // execute the LoggerWeakRefLeak app work
-    public void doMyAppWork(String[] args) throws Exception {
-        int loop_time = 0;
-        int max_loop_time = DEFAULT_LOOP_TIME;
-
-        // args[0] is the port-file
-        if (args.length < 2) {
-            System.out.println("INFO: using default time of "
-                + max_loop_time + " seconds.");
-        } else {
-            try {
-                max_loop_time = Integer.parseInt(args[1]);
-            } catch (NumberFormatException nfe) {
-                throw new RuntimeException("Error: '" + args[1]
-                    + "': is not a valid seconds value.");
-            }
-        }
-
-        long count = 0;
-        int  loggerCount = 0;
-        long now = 0;
-        long startTime = System.currentTimeMillis();
-
-        while (now < (startTime + (max_loop_time * 1000))) {
-            if ((count % 1000) == 0) {
-                // Print initial call count to let caller know that
-                // we're up and running and then periodically
-                System.out.println("INFO: call count = " + count);
-            }
-
-            for (int i = 0; i < 100; i++) {
-                // This Logger call is leaking two different WeakReferences:
-                // - one in LogManager.LogNode
-                // - one in Logger.kids
-                java.util.logging.Logger.getLogger("logger-" + loggerCount);
-                count++;
-                if (++loggerCount >= 25000) {
-                    // Limit the Logger namespace used by the test so
-                    // the weak refs in LogManager.loggers that are
-                    // being properly managed don't skew the counts
-                    // by too much.
-                    loggerCount = 0;
-                }
-            }
-
-            try {
-                // delay for 1/10 of a second to avoid CPU saturation
-                Thread.sleep(100);
-            } catch (InterruptedException ie) {
-                // ignore any exceptions
-            }
-
-            now = System.currentTimeMillis();
-        }
-
-        System.out.println("INFO: final loop count = " + count);
-    }
-
-    public static void main(String[] args) throws Exception {
-        AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
-
-        SimpleApplication.setMyApp(myApp);
-
-        SimpleApplication.main(args);
-    }
-}
--- a/test/java/util/logging/LoggerWeakRefLeak.sh	Wed Mar 07 05:37:58 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,254 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# 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 6942989
-# @summary Check for WeakReference leak in Logger objects
-# @author Daniel D. Daugherty
-#
-# @library ../../../sun/tools/common
-# @build SimpleApplication ShutdownSimpleApplication
-# @build LoggerWeakRefLeak
-# @run shell/timeout=240 LoggerWeakRefLeak.sh
-
-# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
-#
-
-. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
-. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
-
-
-TEST_NAME="LoggerWeakRefLeak"
-TARGET_CLASS="java\.lang\.ref\.WeakReference"
-
-
-# MAIN begins here
-#
-
-seconds=
-if [ "$#" -gt 0 ]; then
-    seconds="$1"
-fi
-
-# see if this version of jmap supports the '-histo:live' option
-jmap_option="-histo:live"
-set +e
-"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
-status="$?"
-set -e
-if [ "$status" != 0 ]; then
-    # usage message doesn't show ':live' option
-
-    if $isWindows; then
-        # If SA isn't present, then jmap gives a different usage message
-        # that doesn't show the ':live' option. However, that's a bug that
-        # is covered by 6971851 so we try using the option just to be sure.
-        # For some reason, this problem has only been seen on OpenJDK6 on
-        # Windows. Not sure why.
-        set +e
-        # Note: Don't copy this code to try probing process 0 on Linux; it
-        # will kill the process group in strange ways.
-        "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
-        status="$?"
-        set -e
-        if [ "$status" = 0 ]; then
-            # Usage message generated so flag the problem.
-            status=1
-        else
-            # No usage message so clear the flag.
-            status=0
-        fi
-    fi
-
-    if [ "$status" != 0 ]; then
-        echo "WARNING: 'jmap $jmap_option' is not supported on this platform"
-        echo "WARNING: so this test cannot work reliably. Aborting!"
-        exit 0
-    fi
-fi
-
-# Start application and use TEST_NAME.port for coordination
-startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
-
-finished_early=false
-
-decreasing_cnt=0
-increasing_cnt=0
-loop_cnt=0
-prev_instance_cnt=0
-
-MAX_JMAP_TRY_CNT=10
-jmap_retry_cnt=0
-loop_cnt_on_retry=0
-
-while true; do
-    # see if the target process has finished its run and bail if it has
-    set +e
-    grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
-    status="$?"
-    set -e
-    if [ "$status" = 0 ]; then
-        break
-    fi
-
-    # Output format for 'jmap -histo' in JDK1.5.0:
-    #
-    #     <#bytes> <#instances> <class_name>
-    #
-    # Output format for 'jmap -histo:live':
-    #
-    #     <num>: <#instances> <#bytes> <class_name>
-    #
-    set +e
-    "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
-    status="$?"
-    set -e
-
-    if [ "$status" != 0 ]; then
-        echo "INFO: jmap exited with exit code = $status"
-
-        # There are intermittent jmap failures; see 6498448.
-        #
-        # So far the following have been observed in a jmap call
-        # that was not in a race with target process termination:
-        #
-        # (Solaris specific, 2nd sample)
-        # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
-        # The -F option can be used when the target process is not responding
-        #
-        # (on Solaris so far)
-        # java.io.IOException
-        #
-        # (on Solaris so far, 1st sample)
-        # <pid>: Permission denied
-        #
-        sed 's/^/INFO: /' "$TEST_NAME.jmap"
-
-        if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
-            # loop count hasn't changed
-            jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
-        else
-            # loop count has changed so remember it
-            jmap_retry_cnt=1
-            loop_cnt_on_retry="$loop_cnt"
-        fi
-
-        # This is '-ge' because we have the original attempt plus
-        # MAX_JMAP_TRY_CNT - 1 retries.
-        if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
-            echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
-                "without making any progress."
-            echo "FAIL: jmap is unable to take any samples." >&2
-            killApplication
-            exit 2
-        fi
-
-        # short delay and try again
-        # Note: sleep 1 didn't help with "<pid>: Permission denied"
-        sleep 2
-        echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
-        continue
-    fi
-
-    set +e
-    instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
-        "$TEST_NAME.jmap" \
-        | sed '
-            # strip leading whitespace; does nothing in JDK1.5.0
-            s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <#bytes> in JDK1.5.0; does nothing otherwise
-            s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <num>: field; does nothing in JDK1.5.0
-            s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
-            # strip <class_name> field
-            s/'"${PATTERN_WS}"'.*//
-            '`
-    set -e
-    if [ -z "$instance_cnt" ]; then
-        echo "INFO: instance count is unexpectedly empty"
-        if [ "$loop_cnt" = 0 ]; then
-            echo "INFO: on the first iteration so no sample was found."
-            echo "INFO: There is likely a problem with the sed filter."
-            echo "INFO: start of jmap output:"
-            cat "$TEST_NAME.jmap"
-            echo "INFO: end of jmap output."
-            echo "FAIL: cannot find the instance count value." >&2
-            killApplication
-            exit 2
-        fi
-    else
-        echo "INFO: instance_cnt = $instance_cnt"
-
-        if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
-            increasing_cnt=`expr $increasing_cnt + 1`
-        else
-            # actually decreasing or the same
-            decreasing_cnt=`expr $decreasing_cnt + 1`
-
-            # For these particular WeakReference leaks, the count was
-            # always observed to be increasing so if we get a decreasing
-            # or the same count, then the leaks are fixed in the bits
-            # being tested.
-            echo "INFO: finishing early due to non-increasing instance count."
-            finished_early=true
-            killApplication
-            break
-        fi
-        prev_instance_cnt="$instance_cnt"
-    fi
-
-    # delay between samples
-    sleep 5
-
-    loop_cnt=`expr $loop_cnt + 1`
-done
-
-if [ $finished_early = false ]; then
-    stopApplication "$TEST_NAME.port"
-    waitForApplication
-fi
-
-echo "INFO: $TEST_NAME has finished running."
-echo "INFO: increasing_cnt = $increasing_cnt"
-echo "INFO: decreasing_cnt = $decreasing_cnt"
-if [ "$jmap_retry_cnt" -gt 0 ]; then
-    echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
-fi
-
-if [ "$loop_cnt" = 0 ]; then
-    echo "FAIL: jmap is unable to take any samples." >&2
-    exit 2
-fi
-
-echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
-if [ "$decreasing_cnt" = 0 ]; then
-    echo "INFO: is always increasing."
-    echo "FAIL: This indicates that there is a memory leak." >&2
-    exit 2
-fi
-
-echo "INFO: is not always increasing."
-echo "PASS: This indicates that there is not a memory leak."
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/TestLoggerWeakRefLeak.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import static jdk.testlibrary.Asserts.assertGreaterThan;
+import jdk.testlibrary.ProcessTools;
+
+import com.sun.tools.attach.AttachNotSupportedException;
+import com.sun.tools.attach.VirtualMachine;
+
+import sun.tools.attach.HotSpotVirtualMachine;
+
+/*
+ * @test
+ * @bug 6942989
+ * @summary Check for WeakReference leak in Logger and anonymous Logger objects
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @run main/othervm TestLoggerWeakRefLeak Logger
+ * @run main/othervm TestLoggerWeakRefLeak AnonymousLogger
+ */
+public class TestLoggerWeakRefLeak {
+
+    private static final String TARGET_CLASS = "java.lang.ref.WeakReference";
+    private static final int INSTANCE_COUNT = 100;
+    private static int loggerCount = 0;
+
+    public static void main(String[] args) throws Exception {
+        if (args[0].equals("AnonymousLogger")) {
+            System.out.println("Test for WeakReference leak in AnonymousLogger object");
+            testIfLeaking(TestLoggerWeakRefLeak::callAnonymousLogger);
+        } else {
+            System.out.println("Test for WeakReference leak in Logger object");
+            testIfLeaking(TestLoggerWeakRefLeak::callLogger);
+        }
+    }
+
+    /**
+     * For these particular WeakReference leaks, the count was always observed
+     * to be increasing so if decreasing or the same count is observed,
+     * then there is no leak.
+     */
+    private static void testIfLeaking(Runnable callLogger) throws Exception {
+        long count = 0;
+        int instanceCount = 0;
+        int previousInstanceCount = 0;
+        int increasingCount = 0;
+        int decreasingCount = 0;
+
+        while (true) {
+            callLogger.run();
+            count += INSTANCE_COUNT;
+
+            if ((count % 1000) == 0) {
+                System.out.println("call count = " + count);
+
+                instanceCount = getInstanceCountFromHeapHisto();
+                if (instanceCount > previousInstanceCount) {
+                    increasingCount++;
+                } else {
+                    decreasingCount++;
+                    System.out.println("increasing count: " + increasingCount);
+                    System.out.println("decreasing or the same count: " + decreasingCount);
+                    System.out.println("Test passed: decreasing or the same instance count is observed");
+                    break;
+                }
+                previousInstanceCount = instanceCount;
+            }
+
+            delayExecution();
+        }
+    }
+
+    /**
+     * This Logger call is leaking two different WeakReferences:
+     * - one in LogManager.LogNode
+     * - one in Logger.kids
+     */
+    private static void callLogger() {
+        for (int i = 0; i < INSTANCE_COUNT; i++) {
+            java.util.logging.Logger.getLogger("logger-" + loggerCount);
+            if (++loggerCount >= 25000) {
+                // Limit the Logger namespace used by the test so the weak refs
+                // in LogManager.loggers that are being properly managed
+                // don't skew the counts by too much.
+                loggerCount = 0;
+            }
+        }
+    }
+
+    /**
+     * This Logger call is leaking a WeakReference in Logger.kids
+     */
+    private static void callAnonymousLogger() {
+        for (int i = 0; i < INSTANCE_COUNT; i++) {
+            java.util.logging.Logger.getAnonymousLogger();
+        }
+    }
+
+    /**
+     * 'vm.heapHisto("-live")' will request a full GC
+     */
+    private static int getInstanceCountFromHeapHisto() throws AttachNotSupportedException, Exception {
+        int instanceCount = 0;
+
+        HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine
+                .attach(Integer.toString(ProcessTools.getProcessId()));
+        try {
+            try (InputStream heapHistoStream = vm.heapHisto("-live");
+                    BufferedReader in = new BufferedReader(new InputStreamReader(heapHistoStream))) {
+                String inputLine;
+                while ((inputLine = in.readLine()) != null) {
+                    if (inputLine.contains(TARGET_CLASS)) {
+                        instanceCount = Integer.parseInt(inputLine
+                                .split("[ ]+")[2]);
+                        System.out.println("instance count: " + instanceCount);
+                        break;
+                    }
+                }
+            }
+        } finally {
+            vm.detach();
+        }
+
+        assertGreaterThan(instanceCount, 0, "No instances of " + TARGET_CLASS + " are found");
+
+        return instanceCount;
+    }
+
+    /**
+     * Delay for 1/10 of a second to avoid CPU saturation
+     */
+    private static void delayExecution() {
+        try {
+            Thread.sleep(100);
+        } catch (InterruptedException ie) {
+            // Ignore any exceptions
+        }
+    }
+
+}
--- a/test/javax/swing/JTabbedPane/8007563/Test8007563.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/javax/swing/JTabbedPane/8007563/Test8007563.java	Thu Mar 15 03:52:16 2018 +0000
@@ -21,9 +21,7 @@
  * questions.
  */
 
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Robot;
+import java.awt.*;
 import java.util.ArrayList;
 import java.util.concurrent.CountDownLatch;
 import javax.swing.JFrame;
@@ -119,6 +117,20 @@
             }
 
         }
-        invokeLater(this);
+        SecondaryLoop secondaryLoop =
+                Toolkit.getDefaultToolkit().getSystemEventQueue()
+                        .createSecondaryLoop();
+        new Thread() {
+            @Override
+            public void run() {
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                }
+                secondaryLoop.exit();
+                invokeLater(Test8007563.this);
+            }
+        }.start();
+        secondaryLoop.enter();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTextField/MissingCharsKorean/MissingCharsKorean.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 8180370
+ * @summary Checks whether non-alpha chars are skipped while entering KoreanText
+ * @requires (os.family == "mac")
+ * @run main/manual MissingCharsKorean
+ */
+
+/**
+ * This test requires a manual intervention as the keyboard layout has to be
+ * changed to 2-set Korean. Once the keyboard layout has been selected, click on
+ * Start Test to start the automated tests. Along with testing for non-alpha
+ * chars, this test also ensures that the MarkedText property is not broken by
+ * running cases where different glyphs are combined and also cases where
+ * combined glyphs are broken.
+ */
+
+import java.awt.AWTException;
+import java.awt.Font;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Robot;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+import java.awt.event.KeyEvent;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+public class MissingCharsKorean {
+    private static boolean testPassed = false;
+    private static boolean startTest = false;
+    private static int expectedResults[] = null;
+    private static int inKeyCodes[][] = null;
+
+    private static JFrame frame = null;
+    private static JLabel lblTestStatus = null;
+    private static JTextField textFieldMain = null;
+    private static String testResult;
+
+    private static final CountDownLatch testStartLatch = new CountDownLatch(1);
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            setupUI();
+        });
+
+        testStartLatch.await();
+
+        if (startTest) {
+            glyphTest();
+
+            frame.dispose();
+
+            if (testPassed) {
+                System.out.println(testResult);
+            } else {
+                throw new RuntimeException("Korean text missing characters : "
+                        + testResult);
+            }
+        } else {
+            throw new RuntimeException("User has not executed the test");
+        }
+    }
+
+    private static void setupUI() {
+        String description = " 1. Go to \"System Preferences -> Keyboard -> "
+                            + "Input Sources\" and add \"2-Set Korean\""
+                            + " from Korean language group \n"
+                            + " 2. Set current IM to \"2-Set Korean\" \n"
+                            + " 3. Try typing in the text field to ensure"
+                            + " that Korean keyboard has been successfully"
+                            + " selected \n"
+                            + " 4. Now click on \"Start Test\" button \n";
+        String title = "Missing Characters Korean Test (Mac OS)";
+
+        frame = new JFrame(title);
+
+        JPanel mainPanel = new JPanel(new BorderLayout());
+
+        JPanel textEditPanel = new JPanel(new FlowLayout());
+
+        textFieldMain = new JTextField(20);
+        Font font = new Font("Source Han Serif K", Font.BOLD,12);
+        textFieldMain.setFont(font);
+
+        textEditPanel.add(textFieldMain);
+
+        mainPanel.add(textEditPanel, BorderLayout.CENTER);
+
+        JTextArea textArea = new JTextArea(description);
+        textArea.setEditable(false);
+        final JButton btnStartTest = new JButton("Start Test");
+        final JButton btnCancelTest = new JButton("Cancel Test");
+
+        btnStartTest.addActionListener((e) -> {
+            btnStartTest.setEnabled(false);
+            btnCancelTest.setEnabled(false);
+            startTest = true;
+            testStartLatch.countDown();
+        });
+
+        btnCancelTest.addActionListener((e) -> {
+            frame.dispose();
+            testStartLatch.countDown();
+        });
+        mainPanel.add(textArea, BorderLayout.NORTH);
+
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        buttonPanel.add(btnStartTest);
+        buttonPanel.add(btnCancelTest);
+        mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+
+        lblTestStatus = new JLabel("");
+        lblTestStatus.setMinimumSize(new Dimension(150, 20));
+        lblTestStatus.setPreferredSize(new Dimension(150, 20));
+        lblTestStatus.setVisible(true);
+        textEditPanel.add(lblTestStatus);
+
+        frame.add(mainPanel);
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+        frame.pack();
+        frame.setLocationRelativeTo(null);
+
+        frame.addWindowListener(new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                testStartLatch.countDown();
+            }
+            @Override
+            public void windowOpened( WindowEvent e ){
+                textFieldMain.requestFocusInWindow();
+            }
+        });
+
+        frame.setVisible(true);
+    }
+
+    private static void glyphTest() {
+        try {
+            Robot robotKeySimulator = new Robot();
+            performTasks(robotKeySimulator);
+        } catch (AWTException e) {
+            System.err.print("Creation Of Robot Failed : " + e.getMessage());
+            testPassed = false;
+        }
+    }
+
+    public static void performTasks(Robot robotForKeyInput) {
+        int taskCount = 0;
+
+        lblTestStatus.setText("Running Tests..");
+        robotForKeyInput.setAutoDelay(500);
+
+        while (setKeyInput(taskCount)) {
+            textFieldMain.setText("");
+            textFieldMain.requestFocusInWindow();
+            enterInput(robotForKeyInput, inKeyCodes);
+            taskCount++;
+
+            try {
+                SwingUtilities.invokeAndWait(() -> {
+                    validateInput();
+                });
+            } catch (Exception e) {
+                System.err.print("validateInput Failed : " + e.getMessage());
+                testPassed = false;
+                break;
+            }
+
+            if (!testPassed) {
+                break;
+            }
+            setTaskStatus(false, taskCount);
+        }
+        setTaskStatus(true, taskCount);
+    }
+
+    private static boolean setKeyInput(int iCount) {
+        boolean inputSet = true;
+
+        switch(iCount) {
+            case 0:
+                // Input Korean q (#12610) /(#47)
+                expectedResults = new int[]{ 12610, 47 };
+                inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_SLASH}
+                                        };
+                break;
+
+            case 1:
+                // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
+                expectedResults = new int[]{ 12610, 47, 54840, 92 };
+                inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_SLASH},
+                                            {KeyEvent.VK_G},
+                                            {KeyEvent.VK_H},
+                                            {KeyEvent.VK_BACK_SLASH}
+                                        };
+                break;
+
+            case 2:
+                // Input Korean q (#12610) /(#47) ghq (#54857) \(#92)
+                expectedResults = new int[]{ 12610, 47, 54857, 92 };
+                inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_SLASH},
+                                            {KeyEvent.VK_G},
+                                            {KeyEvent.VK_H},
+                                            {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_BACK_SLASH}
+                                        };
+                break;
+
+            case 3:
+                // Input Korean q (#12610) /(#47) gh (#54840) \(#92)
+                expectedResults = new int[]{ 12610, 47, 54840, 92 };
+                inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_SLASH},
+                                            {KeyEvent.VK_G},
+                                            {KeyEvent.VK_H},
+                                            {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_BACK_SPACE},
+                                            {KeyEvent.VK_BACK_SLASH}
+                                        };
+                break;
+
+            case 4:
+                // Input Korean q (#12610) /(#47) g (#12622) \(#92)
+                expectedResults = new int[]{ 12610, 47, 12622, 92 };
+                inKeyCodes = new int[][] {  {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_SLASH},
+                                            {KeyEvent.VK_G},
+                                            {KeyEvent.VK_H},
+                                            {KeyEvent.VK_Q},
+                                            {KeyEvent.VK_BACK_SPACE},
+                                            {KeyEvent.VK_BACK_SPACE},
+                                            {KeyEvent.VK_BACK_SLASH}
+                                        };
+                break;
+
+            default:
+                inputSet = false;
+                break;
+        }
+
+        return inputSet;
+    }
+
+    private static void enterInput(Robot robotKeyInput, int keyInputs[][]) {
+        for (int i = 0; i < keyInputs.length; i++) {
+            String strKeyInput = "KeyPress=>";
+            final int noOfKeyInputs = keyInputs[i].length;
+            for (int j = 0; j < noOfKeyInputs; j++) {
+                robotKeyInput.keyPress(keyInputs[i][j]);
+                strKeyInput += (Integer.toHexString(keyInputs[i][j])) + ":";
+            }
+
+            strKeyInput += "KeyRelease=>";
+            for (int j = noOfKeyInputs - 1; j >= 0; j--) {
+                robotKeyInput.keyRelease(keyInputs[i][j]);
+                strKeyInput += (Integer.toHexString(keyInputs[i][j])) + ":";
+            }
+            System.out.println(strKeyInput);
+        }
+    }
+
+    private static void validateInput() {
+        testPassed = false;
+
+        if (expectedResults != null) {
+            String strCurr = textFieldMain.getText();
+            if (expectedResults.length == strCurr.length()) {
+                testPassed = true;
+
+                for (int i = 0; i < strCurr.length(); i++) {
+                    final int charActual = strCurr.charAt(i);
+                    if (charActual != expectedResults[i]) {
+                        System.err.println("<" + i + "> Actual = " + charActual
+                                + " Expected = " + expectedResults[i]);
+                        testPassed = false;
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    public static void setTaskStatus(boolean allTasksPerformed, int taskCount) {
+        if (testPassed) {
+            if (allTasksPerformed) {
+                testResult = "All Tests Passed";
+            } else {
+                testResult = "Test " + Integer.toString(taskCount)
+                        + " Passed";
+            }
+        } else {
+            testResult = "Test " + Integer.toString(taskCount)
+                    + " Failed";
+        }
+        lblTestStatus.setText(testResult);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.security.Provider;
+import java.security.Security;
+
+public class ReadConfInUTF16Env {
+    public static void main(String argv[]) {
+        Provider p = Security.getProvider("SunPKCS11");
+        if (p == null) {
+            p = Security.getProvider("SunPKCS11-Solaris");
+            if (p == null) {
+                System.out.println("Skipping test - no PKCS11 provider available");
+                return;
+            }
+        }
+
+        System.out.println(p.getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 8187023
+# @summary Pkcs11 config file should be assumed in ISO-8859-1
+# @build ReadConfInUTF16Env
+# @run shell ReadConfInUTF16Env.sh
+
+# jtreg does not like -Dfile.encoding=UTF-16 inside a @run main line,
+# testlibrary.ProcessTools.createJavaProcessBuilder() also had troubles
+# executing a subprocess with -Dfile.encoding=UTF-16 option added,
+# therefore a shell test is written.
+
+$TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES \
+  -Dfile.encoding=UTF-16 \
+  ReadConfInUTF16Env
+
--- a/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java	Thu Mar 15 03:52:16 2018 +0000
@@ -31,19 +31,20 @@
 import java.security.spec.DSAGenParameterSpec;
 import java.security.spec.DSAParameterSpec;
 import java.security.spec.InvalidParameterSpecException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
 
 /*
  * @test
  * @bug 8075286
  * @summary Verify that DSAGenParameterSpec can and can only be used to generate
  *          DSA within some certain range of key sizes as described in the class
- *          specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and
- *          (3072, 256) should be OK for DSAGenParameterSpec.
- * @run main TestDSAGenParameterSpec 2048,256,true 2048,224,true 1024,160,true 4096,256 3072,224 2048,160 1024,224 512,160
- * @run main TestDSAGenParameterSpec 3072,256,true
+ *          specification (L, N) as (1024, 160), (2048, 224) and (2048, 256)
+ *          should be OK for DSAGenParameterSpec.
+ * @run main TestDSAGenParameterSpec 512 160
+ * @run main TestDSAGenParameterSpec 1024 160 true
+ * @run main TestDSAGenParameterSpec 1024 224
+ * @run main TestDSAGenParameterSpec 2048 160
+ * @run main/timeout=300 TestDSAGenParameterSpec 2048 224 true
+ * @run main/timeout=300 TestDSAGenParameterSpec 2048 256 true
  */
 public class TestDSAGenParameterSpec {
 
@@ -56,8 +57,8 @@
         System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n",
                 dataTuple.primePLen, dataTuple.subprimeQLen);
 
-        AlgorithmParameterGenerator apg =
-                AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,
+        AlgorithmParameterGenerator apg
+                = AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,
                         PROVIDER_NAME);
 
         DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple);
@@ -79,8 +80,8 @@
 
     private static void checkParam(AlgorithmParameters param,
             DSAGenParameterSpec genParam) throws InvalidParameterSpecException,
-                    NoSuchAlgorithmException, NoSuchProviderException,
-                    InvalidAlgorithmParameterException {
+            NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidAlgorithmParameterException {
         String algorithm = param.getAlgorithm();
         if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) {
             throw new RuntimeException(
@@ -138,21 +139,25 @@
     }
 
     public static void main(String[] args) throws Exception {
-        List<DataTuple> dataTuples = Arrays.stream(args)
-                .map(arg -> arg.split(",")).map(params -> {
-                    int primePLen = Integer.valueOf(params[0]);
-                    int subprimeQLen = Integer.valueOf(params[1]);
-                    boolean isDSASpecSupported = false;
-                    if (params.length == 3) {
-                        isDSASpecSupported = Boolean.valueOf(params[2]);
-                    }
-                    return new DataTuple(primePLen, subprimeQLen,
-                            isDSASpecSupported);
-                }).collect(Collectors.toList());
+        if (args == null || args.length < 2) {
+            throw new RuntimeException("Invalid number of arguments to generate"
+                    + " DSA parameter.");
+        }
+        DataTuple dataTuple = null;
+        switch (args.length) {
+            case 3:
+                dataTuple = new DataTuple(Integer.valueOf(args[0]),
+                        Integer.valueOf(args[1]), Boolean.valueOf(args[2]));
+                break;
+            case 2:
+                dataTuple = new DataTuple(Integer.valueOf(args[0]),
+                        Integer.valueOf(args[1]), false);
+                break;
+            default:
+                throw new RuntimeException("Unsupported arguments found.");
+        }
+        testDSAGenParameterSpec(dataTuple);
 
-        for (DataTuple dataTuple : dataTuples) {
-            testDSAGenParameterSpec(dataTuple);
-        }
     }
 
     private static class DataTuple {
@@ -169,4 +174,3 @@
         }
     }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8184328
+ * @summary JDK8u131-b34-socketRead0 hang at SSL read
+ * @run main/othervm SSLSocketCloseHang
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.security.*;
+import javax.net.ssl.*;
+
+public class SSLSocketCloseHang {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    static String pathToStores = "../../../../sun/security/ssl/etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile static boolean serverReady = false;
+
+    /*
+     * Was the client responsible for closing the socket
+     */
+    volatile static boolean clientClosed = false;
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * If the client or server is doing some kind of object creation
+     * that the other side depends on, and that thread prematurely
+     * exits, you may experience a hang.  The test harness will
+     * terminate all hung threads after its timeout has expired,
+     * currently 3 minutes by default, but you might try to be
+     * smart about it....
+     */
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+        SSLServerSocketFactory sslssf =
+            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+        SSLServerSocket sslServerSocket =
+            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+
+        serverPort = sslServerSocket.getLocalPort();
+
+        /*
+         * Signal Client, we're ready for his connect.
+         */
+        serverReady = true;
+
+        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        sslSocket.startHandshake();
+        while (!clientClosed) {
+            Thread.sleep(500);
+        }
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+        boolean caught = false;
+
+        /*
+         * Wait for server to get started.
+         */
+        System.out.println("waiting on server");
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+        System.out.println("server ready");
+
+        Socket baseSocket = new Socket("localhost", serverPort);
+        baseSocket.setSoTimeout(100);
+
+        SSLSocketFactory sslsf =
+            (SSLSocketFactory) SSLSocketFactory.getDefault();
+        SSLSocket sslSocket = (SSLSocket)
+            sslsf.createSocket(baseSocket, "localhost", serverPort, false);
+
+        // handshaking
+        sslSocket.startHandshake();
+        System.out.println("handshake done");
+
+        Thread.sleep(500);
+        System.out.println("client closing");
+
+        sslSocket.close();
+        clientClosed = true;
+        System.out.println("client closed");
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    volatile byte[] serverDigest = null;
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + keyStoreFile;
+        String trustFilename =
+            System.getProperty("test.src", "./") + "/" + pathToStores +
+                "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        if (debug)
+            System.setProperty("javax.net.debug", "all");
+
+        /*
+         * Start the tests.
+         */
+        new SSLSocketCloseHang();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    SSLSocketCloseHang() throws Exception {
+        if (separateServerThread) {
+            startServer(true);
+            startClient(false);
+        } else {
+            startClient(true);
+            startServer(false);
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         *
+         * If the main thread excepted, that propagates back
+         * immediately.  If the other thread threw an exception, we
+         * should report back.
+         */
+        if (serverException != null) {
+            System.out.print("Server Exception:");
+            throw serverException;
+        }
+        if (clientException != null) {
+            System.out.print("Client Exception:");
+            throw clientException;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died...");
+                        System.err.println(e);
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            doServerSide();
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died...");
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            doClientSide();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/util/Pem/PemEncoding.java	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.FileInputStream;
+import java.security.cert.CertificateFactory;
+
+public class PemEncoding {
+    public static void main(String[] args) throws Exception {
+        try (FileInputStream fis = new FileInputStream(args[0])) {
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            System.out.println(cf.generateCertificate(fis));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/util/Pem/encoding.sh	Thu Mar 15 03:52:16 2018 +0000
@@ -0,0 +1,35 @@
+#
+# 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 8158633
+# @summary BASE64 encoded cert not correctly parsed with UTF-16
+# @build PemEncoding
+# @run shell encoding.sh
+
+# jtreg does not like -Dfile.encoding=UTF-16 inside a @run main line,
+# therefore a shell test is written.
+
+$TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES \
+        -Dfile.encoding=UTF-16 \
+        PemEncoding $TESTSRC/../HostnameMatcher/cert5.crt
--- a/test/sun/tools/common/CommonTests.sh	Wed Mar 07 05:37:58 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,314 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# 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 6964018
-# @summary Unit test for common tools infrastructure.
-#
-# @build SimpleApplication SleeperApplication ShutdownSimpleApplication
-# @run shell CommonTests.sh
-
-. ${TESTSRC}/CommonSetup.sh
-. ${TESTSRC}/ApplicationSetup.sh
-
-# hope for the best:
-status=0
-
-
-# Test program path constants from CommonSetup.sh:
-#
-for name in JAVA JHAT JINFO JMAP JPS JSTACK; do
-    eval value=$`echo $name`
-
-    echo "INFO: $name=$value"
-    if [ -x "$value" ]; then
-        echo "INFO: '$value' is executable."
-    else
-        echo "ERROR: '$value' is not executable." >&2
-        status=1
-    fi
-done
-
-
-# Display flag values from CommonSetup.sh:
-#
-for name in isCygwin isMKS isLinux isSolaris isUnknownOS isWindows; do
-    eval value=$`echo $name`
-    echo "INFO: flag $name=$value"
-done
-
-
-# Test OS constant from CommonSetup.sh:
-#
-if [ -z "$OS" ]; then
-    echo "ERROR: OS constant cannot be empty." >&2
-    status=1
-fi
-
-
-# Display the PATTERN_EOL value:
-#
-echo "INFO: PATTERN_EOL="`echo "$PATTERN_EOL" | od -c`
-
-
-# Test PATTERN_EOL with 'grep' for a regular line.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_reg_line_eol"
-set +e
-echo 'regular line' | grep "line${PATTERN_EOL}" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_EOL works for regular line with grep."
-else
-    echo "ERROR: PATTERN_EOL does not work for regular line with grep." >&2
-    status=1
-fi
-
-
-if $isWindows; then
-    # Test PATTERN_EOL with 'grep' for a CR line.
-    #
-    TESTOUT="${TESTCLASSES}/testout.grep_cr_line_eol"
-    set +e
-    echo 'CR line
' | grep "line${PATTERN_EOL}" > "$TESTOUT"
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: PATTERN_EOL works for CR line with grep."
-    else
-        echo "ERROR: PATTERN_EOL does not work for CR line with grep." >&2
-        status=1
-    fi
-fi
-
-
-# Test PATTERN_EOL with 'sed' for a regular line.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_reg_line_eol"
-echo 'regular line' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_EOL works for regular line with sed."
-else
-    echo "ERROR: PATTERN_EOL does not work for regular line with sed." >&2
-    status=1
-fi
-
-
-if $isWindows; then
-    # Test PATTERN_EOL with 'sed' for a CR line.
-    #
-    TESTOUT="${TESTCLASSES}/testout.sed_cr_line_eol"
-    echo 'CR line
' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: PATTERN_EOL works for CR line with sed."
-    else
-        echo "ERROR: PATTERN_EOL does not work for CR line with sed." >&2
-        status=1
-    fi
-fi
-
-
-# Display the PATTERN_WS value:
-#
-echo "INFO: PATTERN_WS="`echo "$PATTERN_WS" | od -c`
-
-
-# Test PATTERN_WS with 'grep' for a blank.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_blank"
-set +e
-echo 'blank: ' | grep "$PATTERN_WS" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for blanks with grep."
-else
-    echo "ERROR: PATTERN_WS does not work for blanks with grep." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'grep' for a tab.
-#
-TESTOUT="${TESTCLASSES}/testout.grep_tab"
-set +e
-echo 'tab:	' | grep "$PATTERN_WS" > "$TESTOUT"
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for tabs with grep."
-else
-    echo "ERROR: PATTERN_WS does not work for tabs with grep." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'sed' for a blank.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_blank"
-echo 'blank: ' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for blanks with sed."
-else
-    echo "ERROR: PATTERN_WS does not work for blanks with sed." >&2
-    status=1
-fi
-
-
-# Test PATTERN_WS with 'sed' for a tab.
-#
-TESTOUT="${TESTCLASSES}/testout.sed_tab"
-echo 'tab:	' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: PATTERN_WS works for tabs with sed."
-else
-    echo "ERROR: PATTERN_WS does not work for tabs with sed." >&2
-    status=1
-fi
-
-
-# Test startApplication and use PORTFILE for coordination
-# The app sleeps for 30 seconds.
-#
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SleeperApplication "${PORTFILE}" 30
-
-
-# Test appJavaPid in "ps" cmd output.
-#
-TESTOUT="${TESTCLASSES}/testout.ps_app"
-set +e
-if $isCygwin; then
-    # On Cygwin, appJavaPid is the Windows pid for the Java process
-    # and appOtherPid is the Cygwin pid for the Java process.
-    ps -p "$appOtherPid" \
-        | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-else
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-fi
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: begin appJavaPid=$appJavaPid in 'ps' cmd output:"
-    cat "$TESTOUT"
-    echo "INFO: end appJavaPid=$appJavaPid in 'ps' cmd output."
-else
-    echo "ERROR: 'ps' cmd should show appJavaPid=$appJavaPid." >&2
-    status=1
-fi
-
-if [ -n "$appOtherPid" ]; then
-    # Test appOtherPid in "ps" cmd output, if we have one.
-    #
-    TESTOUT="${TESTCLASSES}/testout.ps_other"
-    set +e
-    if $isCygwin; then
-        ps -p "$appOtherPid" \
-            | grep "${PATTERN_WS}${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
-    else
-        # output only pid and comm columns to avoid mismatches
-        ps -eo pid,comm \
-            | grep "^${PATTERN_WS}*${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
-    fi
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "INFO: begin appOtherPid=$appOtherPid in 'ps' cmd output:"
-        cat "$TESTOUT"
-        echo "INFO: end appOtherPid=$appOtherPid in 'ps' cmd output."
-    else
-        echo "ERROR: 'ps' cmd should show appOtherPid=$appOtherPid." >&2
-        status=1
-    fi
-fi
-
-
-# Test stopApplication and PORTFILE for coordination
-#
-stopApplication "${PORTFILE}"
-
-
-# Test application still running after stopApplication.
-#
-# stopApplication just lets the app know that it can stop, but the
-# app might still be doing work. This test just demonstrates that
-# fact and doesn't fail if the app is already done.
-#
-TESTOUT="${TESTCLASSES}/testout.after_stop"
-set +e
-if $isCygwin; then
-    # On Cygwin, appJavaPid is the Windows pid for the Java process
-    # and appOtherPid is the Cygwin pid for the Java process.
-    ps -p "$appOtherPid" \
-        | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-else
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-fi
-set -e
-if [ -s "$TESTOUT" ]; then
-    echo "INFO: it is okay for appJavaPid=$appJavaPid to still be running" \
-        "after stopApplication() is called."
-    echo "INFO: begin 'after_stop' output:"
-    cat "$TESTOUT"
-    echo "INFO: end 'after_stop' output."
-fi
-
-
-# Test waitForApplication
-#
-# The app might already be gone so this function shouldn't generate
-# a fatal error in either call.
-#
-waitForApplication
-
-if [ $isWindows = false ]; then
-    # Windows can recycle pids quickly so we can't use this test there
-    TESTOUT="${TESTCLASSES}/testout.after_kill"
-    set +e
-    # output only pid and comm columns to avoid mismatches
-    ps -eo pid,comm \
-        | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
-    set -e
-    if [ -s "$TESTOUT" ]; then
-        echo "ERROR: 'ps' cmd should not show appJavaPid." >&2
-        echo "ERROR: begin 'after_kill' output:" >&2
-        cat "$TESTOUT" >&2
-        echo "ERROR: end 'after_kill' output." >&2
-        status=1
-    else
-        echo "INFO: 'ps' cmd does not show appJavaPid after" \
-            "waitForApplication() is called."
-    fi
-fi
-
-
-# Test killApplication
-#
-# The app is already be gone so this function shouldn't generate
-# a fatal error.
-#
-killApplication
-
-exit $status
--- a/test/tools/launcher/TestSpecialArgs.java	Wed Mar 07 05:37:58 2018 +0000
+++ b/test/tools/launcher/TestSpecialArgs.java	Thu Mar 15 03:52:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -23,12 +23,14 @@
 
 /*
  * @test
- * @bug 7124089 7131021 8042469
- * @summary Checks for MacOSX specific flags are accepted or rejected, and
- *          MacOSX platforms specific environment is consistent.
+ * @bug 7124089 7131021 8042469 8066185
+ * @summary Checks for Launcher special flags, such as MacOSX specific flags,
+ *          and JVM NativeMemoryTracking flags.
  * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java
  * @run main TestSpecialArgs
  */
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -36,10 +38,14 @@
 
 public class TestSpecialArgs extends TestHelper {
 
-    public static void main(String... args) {
+    public static void main(String... args) throws Exception {
+        new TestSpecialArgs().run(args);
+    }
+
+    @Test
+    void testDocking() {
         final Map<String, String> envMap = new HashMap<>();
         envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
-
         TestResult tr = doExec(envMap, javaCmd, "-XstartOnFirstThread", "-version");
         if (isMacOSX) {
             if (!tr.contains("In same thread")) {
@@ -69,140 +75,10 @@
                 throw new RuntimeException("Error: argument was accepted ????");
             }
         }
-
-        /*
-         * test argument : -XX:NativeMemoryTracking=value
-         * A JVM flag, comsumed by the JVM, but requiring launcher
-         * to set an environmental variable if and only if value is supplied.
-         * Test and order:
-         * 1) execute with valid parameter: -XX:NativeMemoryTracking=MyValue
-         *    a) check for correct env variable name: "NMT_LEVEL_" + pid
-         *    b) check that "MyValue" was found in local env.
-         * 2) execute with invalid parameter: -XX:NativeMemoryTracking=
-         *    !) Won't find "NativeMemoryTracking:"
-         *       Code to create env variable not executed.
-         * 3) execute with invalid parameter: -XX:NativeMemoryTracking
-         *    !) Won't find "NativeMemoryTracking:"
-         *       Code to create env variable not executed.
-         * 4) give and invalid value and check to make sure JVM commented
-         */
-        { // NativeMemoryTracking
-            String launcherPidString = "launcher.pid=";
-            String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
-            String NMT_Option_Value = "off";
-            String myClassName = "helloworld";
-            boolean haveLauncherPid = false;
-
-            // === Run the tests ===
-
-            // ---Test 1a
-            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=" + NMT_Option_Value,
-                        "-version");
-
-            // get the PID from the env var we set for the JVM
-            String envVarPid = null;
-            for (String line : tr.testOutput) {
-                if (line.contains(envVarPidString)) {
-                    int sindex = envVarPidString.length();
-                    envVarPid = line.substring(sindex);
-                    break;
-                }
-            }
-            // did we find envVarPid?
-            if (envVarPid == null) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: failed to find env Var Pid in tracking info");
-            }
-            // we think we found the pid string.  min test, not "".
-            if (envVarPid.length() < 1) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
-            }
-
-            /*
-             * On Linux, Launcher Tracking will print the PID.  Use this info
-             * to validate what we got as the PID in the Launcher itself.
-             * Linux is the only one that prints this, and trying to get it
-             * here for win is awful.  So let the linux test make sure we get
-             * the valid pid, and for non-linux, just make sure pid string is
-             * non-zero.
-             */
-            if (isLinux) {
-                // get what the test says is the launcher pid
-                String launcherPid = null;
-                for (String line : tr.testOutput) {
-                    int index = line.indexOf(launcherPidString);
-                    if (index >= 0) {
-                        int sindex = index + launcherPidString.length();
-                        int tindex = sindex + line.substring(sindex).indexOf("'");
-                        System.out.println("DEBUG INFO: sindex = " + sindex);
-                        System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
-                        System.out.println("DEBUG INFO: tindex = " + tindex);
-                        // DEBUG INFO
-                        System.out.println(tr);
-                        launcherPid = line.substring(sindex, tindex);
-                        break;
-                    }
-                }
-                if (launcherPid == null) {
-                    System.out.println(tr);
-                    throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
-                }
-
-                // did we create the env var with the correct pid?
-                if (!launcherPid.equals(envVarPid)) {
-                    System.out.println(tr);
-                    System.out.println("Error: wrong pid in creating env var");
-                    System.out.println("Error Info: launcherPid = " + launcherPid);
-                    System.out.println("Error Info: envVarPid   = " + envVarPid);
-                    throw new RuntimeException("Error: wrong pid in creating env var");
-                }
-            }
-
-
-            // --- Test 1b
-            if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: Valid param failed to set env variable");
-            }
-
-            // --- Test 2
-            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=",
-                        "-version");
-            if (tr.contains("NativeMemoryTracking:")) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
-            }
-            if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: invalid param not checked by JVM");
-            }
-
-            // --- Test 3
-            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking",
-                        "-version");
-            if (tr.contains("NativeMemoryTracking:")) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
-            }
-            if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: invalid param not checked by JVM");
-            }
-            // --- Test 4
-            tr = doExec(envMap,javaCmd, "-XX:NativeMemoryTracking=BADVALUE",
-                        "-version");
-            if (!tr.contains("expecting -XX:NativeMemoryTracking")) {
-                System.out.println(tr);
-                throw new RuntimeException("Error: invalid param did not get JVM Syntax error message");
-            }
-
-        } // NativeMemoryTracking
-
-
         // MacOSX specific tests ensue......
-        if (!isMacOSX)
+        if (!isMacOSX) {
             return;
+        }
         Set<String> envToRemove = new HashSet<>();
         Map<String, String> map = System.getenv();
         for (String s : map.keySet()) {
@@ -225,11 +101,187 @@
                 "APP_ICON_*", "TestAppIcon");
     }
 
-    static void runTest(Set<String> envToRemove, String... args) {
+    void runTest(Set<String> envToRemove, String... args) {
         TestResult tr = doExec(null, envToRemove, args);
         if (!tr.isOK()) {
             System.err.println(tr.toString());
             throw new RuntimeException("Test Fails");
         }
     }
+
+    @Test
+    void testNativeMemoryTracking() {
+        final Map<String, String> envMap = new HashMap<>();
+        envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
+        TestResult tr;
+        /*
+         * test argument : -XX:NativeMemoryTracking=value
+         * A JVM flag, comsumed by the JVM, but requiring launcher
+         * to set an environmental variable if and only if value is supplied.
+         * Test and order:
+         * 1) execute with valid parameter: -XX:NativeMemoryTracking=MyValue
+         *    a) check for correct env variable name: "NMT_LEVEL_" + pid
+         *    b) check that "MyValue" was found in local env.
+         * 2) execute with invalid parameter: -XX:NativeMemoryTracking=
+         *    !) Won't find "NativeMemoryTracking:"
+         *       Code to create env variable not executed.
+         * 3) execute with invalid parameter: -XX:NativeMemoryTracking
+         *    !) Won't find "NativeMemoryTracking:"
+         *       Code to create env variable not executed.
+         * 4) give and invalid value and check to make sure JVM commented
+         */
+        String launcherPidString = "launcher.pid=";
+        String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_";
+        String NMT_Option_Value = "off";
+        String myClassName = "helloworld";
+        boolean haveLauncherPid = false;
+
+        // === Run the tests ===
+        // ---Test 1a
+        tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking=" + NMT_Option_Value,
+                "-version");
+
+        // get the PID from the env var we set for the JVM
+        String envVarPid = null;
+        for (String line : tr.testOutput) {
+            if (line.contains(envVarPidString)) {
+                int sindex = envVarPidString.length();
+                envVarPid = line.substring(sindex);
+                break;
+            }
+        }
+        // did we find envVarPid?
+        if (envVarPid == null) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: failed to find env Var Pid in tracking info");
+        }
+        // we think we found the pid string.  min test, not "".
+        if (envVarPid.length() < 1) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: env Var Pid in tracking info is empty string");
+        }
+
+        /*
+         * On Linux, Launcher Tracking will print the PID.  Use this info
+         * to validate what we got as the PID in the Launcher itself.
+         * Linux is the only one that prints this, and trying to get it
+         * here for win is awful.  So let the linux test make sure we get
+         * the valid pid, and for non-linux, just make sure pid string is
+         * non-zero.
+         */
+        if (isLinux) {
+            // get what the test says is the launcher pid
+            String launcherPid = null;
+            for (String line : tr.testOutput) {
+                int index = line.indexOf(launcherPidString);
+                if (index >= 0) {
+                    int sindex = index + launcherPidString.length();
+                    int tindex = sindex + line.substring(sindex).indexOf("'");
+                    System.out.println("DEBUG INFO: sindex = " + sindex);
+                    System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex));
+                    System.out.println("DEBUG INFO: tindex = " + tindex);
+                    // DEBUG INFO
+                    System.out.println(tr);
+                    launcherPid = line.substring(sindex, tindex);
+                    break;
+                }
+            }
+            if (launcherPid == null) {
+                System.out.println(tr);
+                throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info");
+            }
+
+            // did we create the env var with the correct pid?
+            if (!launcherPid.equals(envVarPid)) {
+                System.out.println(tr);
+                System.out.println("Error: wrong pid in creating env var");
+                System.out.println("Error Info: launcherPid = " + launcherPid);
+                System.out.println("Error Info: envVarPid   = " + envVarPid);
+                throw new RuntimeException("Error: wrong pid in creating env var");
+            }
+        }
+
+        // --- Test 1b
+        if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: Valid param failed to set env variable");
+        }
+
+        // --- Test 2
+        tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking=",
+                "-version");
+        if (tr.contains("NativeMemoryTracking:")) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
+        }
+        if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: invalid param not checked by JVM");
+        }
+
+        // --- Test 3
+        tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking",
+                "-version");
+        if (tr.contains("NativeMemoryTracking:")) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: invalid param caused env variable to be erroneously created");
+        }
+        if (!tr.contains("Syntax error, expecting -XX:NativeMemoryTracking=")) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: invalid param not checked by JVM");
+        }
+        // --- Test 4
+        tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking=BADVALUE",
+                "-version");
+        if (!tr.contains("expecting -XX:NativeMemoryTracking")) {
+            System.out.println(tr);
+            throw new RuntimeException("Error: invalid param did not get JVM Syntax error message");
+        }
+    }
+
+    @Test
+    void testNMArgumentProcessing() throws FileNotFoundException {
+        TestResult tr = null;
+        // the direct invokers of the VM
+        String options[] = {
+            "-version", "-fullversion", "-help", "-?", "-X"
+        };
+        for (String option : options) {
+            tr = doExec(javaCmd, option, "-XX:NativeMemoryTracking=summary");
+            checkTestResult(tr);
+        }
+
+        // create a test jar
+        File jarFile = new File("test.jar");
+        createJar(jarFile, "public static void main(String... args){}");
+
+        // ones that involve main-class of some sort
+        tr = doExec(javaCmd, "-jar", jarFile.getName(),
+                "-XX:NativeMemoryTracking=summary");
+        checkTestResult(tr);
+
+        tr = doExec(javaCmd, "-cp", jarFile.getName(), "Foo",
+                "-XX:NativeMemoryTracking=summary");
+        checkTestResult(tr);
+
+        final Map<String, String> envMap = new HashMap<>();
+        // checkwith CLASSPATH set ie. no -cp or -classpath
+        envMap.put("CLASSPATH", ".");
+        tr = doExec(envMap, javaCmd, "Foo", "-XX:NativeMemoryTracking=summary");
+        checkTestResult(tr);
+
+        // make sure a missing class is handled correctly, because the class
+        // resolution is performed by the JVM.
+        tr = doExec(javaCmd, "AbsentClass", "-XX:NativeMemoryTracking=summary");
+        if (!tr.contains("Error: Could not find or load main class AbsentClass")) {
+            throw new RuntimeException("Test Fails");
+        }
+    }
+
+    void checkTestResult(TestResult tr) {
+        if (!tr.isOK()) {
+            System.err.println(tr.toString());
+            throw new RuntimeException("Test Fails");
+        }
+    }
 }