Merge
authorddehaven
Fri, 16 Dec 2016 11:58:17 -0800
changeset 42750 562fee8337a3
parent 42709 d477072ef0e4 (current diff)
parent 42749 91fb907a8732 (diff)
child 42751 38d28e784f44
Merge
--- a/jdk/make/lib/Awt2dLibraries.gmk	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Fri Dec 16 11:58:17 2016 -0800
@@ -418,6 +418,7 @@
     DISABLED_WARNINGS_gcc := format-nonliteral type-limits misleading-indentation, \
     DISABLED_WARNINGS_clang := tautological-compare, \
     DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
+    DISABLED_WARNINGS_microsoft := 4819, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/liblcms/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -681,7 +682,7 @@
     DISABLED_WARNINGS_CXX_solstudio := \
         truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
         hidevf w_novirtualdescr arrowrtn2, \
-    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334, \
+    DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819, \
     MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \
     LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java	Fri Dec 16 11:58:17 2016 -0800
@@ -34,10 +34,18 @@
 
 import sun.lwawt.macosx.LWCToolkit;
 import sun.security.action.GetBooleanAction;
-import sun.security.action.GetPropertyAction;
 
 // MenuBar implementation for Mac L&F
 public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvider {
+
+    static {
+        java.security.AccessController.doPrivileged(
+                (java.security.PrivilegedAction<Void>) () -> {
+            System.loadLibrary("osxui");
+            return null;
+        });
+    }
+
     // Utilities
     public void uninstallUI(final JComponent c) {
         if (fScreenMenuBar != null) {
@@ -134,7 +142,7 @@
     ScreenMenuBar fScreenMenuBar;
     boolean useScreenMenuBar = getScreenMenuBarProperty();
 
-    static boolean getScreenMenuBarProperty() {
+    public static boolean getScreenMenuBarProperty() {
         // Do not allow AWT to set the screen menu bar if it's embedded in another UI toolkit
         if (LWCToolkit.isEmbedded()) return false;
         if (AccessController.doPrivileged(
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java	Fri Dec 16 11:58:17 2016 -0800
@@ -141,12 +141,24 @@
         }
     }
 
-    protected void registerFontsInDir(String dirName, boolean useJavaRasterizer, int fontRank, boolean defer, boolean resolveSymLinks) {
-        loadNativeDirFonts(dirName);
+    protected void registerFontsInDir(final String dirName, boolean useJavaRasterizer,
+                                      int fontRank, boolean defer, boolean resolveSymLinks) {
+
+        String[] files = AccessController.doPrivileged((PrivilegedAction<String[]>) () -> {
+            return new File(dirName).list(getTrueTypeFilter());
+        });
+
+        if (files == null) {
+           return;
+        } else {
+            for (String f : files) {
+                loadNativeDirFonts(dirName+File.separator+f);
+            }
+        }
         super.registerFontsInDir(dirName, useJavaRasterizer, fontRank, defer, resolveSymLinks);
     }
 
-    private native void loadNativeDirFonts(String dirName);
+    private native void loadNativeDirFonts(String fontPath);
     private native void loadNativeFonts();
 
     void registerFont(String fontName, String fontFamilyName) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Dec 16 11:58:17 2016 -0800
@@ -33,11 +33,14 @@
 import java.awt.event.*;
 import java.beans.*;
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
 
 import javax.swing.*;
 
 import sun.awt.*;
 import sun.awt.AWTAccessor.ComponentAccessor;
+import sun.awt.AWTAccessor.WindowAccessor;
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLSurfaceData;
 import sun.lwawt.*;
@@ -1031,6 +1034,11 @@
         return !peer.isSimpleWindow() && target.getFocusableWindowState();
     }
 
+    private boolean isBlocked() {
+        LWWindowPeer blocker = (peer != null) ? peer.getBlocker() : null;
+        return (blocker != null);
+    }
+
     /*
      * An utility method for the support of the auto request focus.
      * Updates the focusable state of the window under certain
@@ -1063,29 +1071,70 @@
         return true;
     }
 
+    private boolean isOneOfOwnersOrSelf(CPlatformWindow window) {
+        while (window != null) {
+            if (this == window) {
+                return true;
+            }
+            window = window.owner;
+        }
+        return false;
+    }
+
+    private CPlatformWindow getRootOwner() {
+        CPlatformWindow rootOwner = this;
+        while (rootOwner.owner != null) {
+            rootOwner = rootOwner.owner;
+        }
+        return rootOwner;
+    }
+
     private void orderAboveSiblings() {
-        if (owner == null) {
-            return;
+        // Recursively pop up the windows from the very bottom, (i.e. root owner) so that
+        // the windows are ordered above their nearest owner; ancestors of the window,
+        // which is going to become 'main window', are placed above their siblings.
+        CPlatformWindow rootOwner = getRootOwner();
+        if (rootOwner.isVisible()) {
+            CWrapper.NSWindow.orderFront(rootOwner.getNSWindowPtr());
         }
+        final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
+        orderAboveSiblingsImpl(windowAccessor.getOwnedWindows(rootOwner.target));
+    }
 
-        // NOTE: the logic will fail if we have a hierarchy like:
-        //       visible root owner
-        //          invisible owner
-        //              visible dialog
-        // However, this is an unlikely scenario for real life apps
-        if (owner.isVisible()) {
-            // Recursively pop up the windows from the very bottom so that only
-            // the very top-most one becomes the main window
-            owner.orderAboveSiblings();
+    private void orderAboveSiblingsImpl(Window[] windows) {
+        ArrayList<Window> childWindows = new ArrayList<Window>();
+
+        final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
+        final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();
 
-            // Order the window to front of the stack of child windows
-            final long nsWindowSelfPtr = getNSWindowPtr();
-            final long nsWindowOwnerPtr = owner.getNSWindowPtr();
-            CWrapper.NSWindow.orderFront(nsWindowOwnerPtr);
-            CWrapper.NSWindow.orderWindow(nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove, nsWindowOwnerPtr);
+        // Go through the list of windows and perform ordering.
+        for (Window w : windows) {
+            final Object p = componentAccessor.getPeer(w);
+            if (p instanceof LWWindowPeer) {
+                CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
+                if (pw != null && pw.isVisible()) {
+                    // If the window is one of ancestors of 'main window' or is going to become main by itself,
+                    // the window should be ordered above its siblings; otherwise the window is just ordered
+                    // above its nearest parent.
+                    if (pw.isOneOfOwnersOrSelf(this)) {
+                        CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
+                    } else {
+                        CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
+                                pw.owner.getNSWindowPtr());
+                    }
+                    pw.applyWindowLevel(w);
+                }
+            }
+            // Retrieve the child windows for each window from the list and store them for future use.
+            // Note: we collect data about child windows even for invisible owners, since they may have
+            // visible children.
+            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
         }
-
-        applyWindowLevel(target);
+        // If some windows, which have just been ordered, have any child windows, let's start new iteration
+        // and order these child windows.
+        if (!childWindows.isEmpty()) {
+            orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
+        }
     }
 
     protected void applyWindowLevel(Window target) {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Dec 16 11:58:17 2016 -0800
@@ -25,6 +25,7 @@
 
 package sun.lwawt.macosx;
 
+import com.apple.laf.AquaMenuBarUI;
 import java.awt.peer.TaskbarPeer;
 import java.awt.*;
 import java.awt.datatransfer.Clipboard;
@@ -43,6 +44,7 @@
 import java.util.*;
 import java.util.concurrent.Callable;
 import java.net.MalformedURLException;
+import javax.swing.UIManager;
 
 import sun.awt.*;
 import sun.awt.datatransfer.DataTransferer;
@@ -935,4 +937,13 @@
     protected PlatformWindow getPlatformWindowUnderMouse() {
         return CPlatformWindow.nativeGetTopmostPlatformWindowUnderMouse();
     }
+
+    @Override
+    public void updateScreenMenuBarUI() {
+        if (AquaMenuBarUI.getScreenMenuBarProperty())  {
+            UIManager.put("MenuBarUI", "com.apple.laf.AquaMenuBarUI");
+        } else {
+            UIManager.put("MenuBarUI", null);
+        }
+    }
 }
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Fri Dec 16 11:58:17 2016 -0800
@@ -430,7 +430,22 @@
     [super dealloc];
 }
 
-// Tests wheather the corresponding Java paltform window is visible or not
+// Tests whether window is blocked by modal dialog/window
+- (BOOL) isBlocked {
+    BOOL isBlocked = NO;
+    
+    JNIEnv *env = [ThreadUtilities getJNIEnv];
+    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+    if (platformWindow != NULL) {
+        static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z");
+        isBlocked = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
+        (*env)->DeleteLocalRef(env, platformWindow);
+    }
+    
+    return isBlocked;
+}
+
+// Tests whether the corresponding Java platform window is visible or not
 + (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
     BOOL isVisible = NO;
 
@@ -454,8 +469,9 @@
 - (void) orderChildWindows:(BOOL)focus {
 AWT_ASSERT_APPKIT_THREAD;
 
-    if (self.isMinimizing) {
+    if (self.isMinimizing || [self isBlocked]) {
         // Do not perform any ordering, if iconify is in progress
+        // or the window is blocked by a modal window
         return;
     }
 
@@ -809,18 +825,20 @@
 
 - (void)sendEvent:(NSEvent *)event {
         if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
-            // Move parent windows to front and make sure that a child window is displayed
-            // in front of its nearest parent.
-            if (self.ownerWindow != nil) {
-                JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
-                jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
-                if (platformWindow != NULL) {
-                    static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
-                    JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
-                    (*env)->DeleteLocalRef(env, platformWindow);
+            if ([self isBlocked]) {
+                // Move parent windows to front and make sure that a child window is displayed
+                // in front of its nearest parent.
+                if (self.ownerWindow != nil) {
+                    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
+                    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+                    if (platformWindow != NULL) {
+                        static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
+                        JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
+                        (*env)->DeleteLocalRef(env, platformWindow);
+                    }
                 }
+                [self orderChildWindows:YES];
             }
-            [self orderChildWindows:YES];
 
             NSPoint p = [NSEvent mouseLocation];
             NSRect frame = [self.nsWindow frame];
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Fri Dec 16 11:58:17 2016 -0800
@@ -115,19 +115,18 @@
             if (keyWindow != nil) {
                 return;
             }
-        }
-        else {
-            static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
-            static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
-            
-            NSUInteger modifiers = [currEvent modifierFlags];
-            jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
-            
-            JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
-        }
+		}
+		
+        static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
+        static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
+
+        NSUInteger modifiers = [currEvent modifierFlags];
+        jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
+
+        JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
     }
     JNF_COCOA_EXIT(env);
-    
+	
 }
 
 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m	Fri Dec 16 11:58:17 2016 -0800
@@ -404,19 +404,14 @@
 {
 JNF_COCOA_ENTER(env);
 
-    NSString *nsFilePath = JNFJavaToNSString(env, filename);
-
-    FSRef iFile;
-    OSStatus status = CreateFSRef(&iFile, nsFilePath);
-
-    if (status == noErr) {
-        ATSFontContainerRef oContainer;
-        status = ATSFontActivateFromFileReference(&iFile, kATSFontContextLocal,
-                                                  kATSFontFormatUnspecified,
-                                                  NULL, kNilOptions,
-                                                  &oContainer);
-    }
-
+    NSString *path = JNFJavaToNSString(env, filename);
+    NSURL *url = [NSURL fileURLWithPath:(NSString *)path];
+    bool res = CTFontManagerRegisterFontsForURL((CFURLRef)url, kCTFontManagerScopeProcess, nil);
+#ifdef DEBUG
+    NSLog(@"path is : %@", (NSString*)path);
+    NSLog(@"url is : %@", (NSString*)url);
+    printf("res is %d\n", res);
+#endif
 JNF_COCOA_EXIT(env);
 }
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m	Fri Dec 16 11:58:17 2016 -0800
@@ -591,7 +591,7 @@
 static inline GlyphInfo *
 CGGI_CreateImageForUnicode
     (CGGI_GlyphCanvas *canvas, const AWTStrike *strike,
-     const CGGI_RenderingMode *mode, const UniChar uniChar)
+     const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar)
 {
     // save the state of the world
     CGContextSaveGState(canvas->context);
@@ -668,7 +668,7 @@
                                         const AWTStrike *strike,
                                         const CGGI_RenderingMode *mode,
                                         jlong glyphInfos[],
-                                        const UniChar uniChars[],
+                                        const UnicodeScalarValue uniChars[],
                                         const CGGlyph glyphs[],
                                         const CFIndex len)
 {
@@ -720,7 +720,7 @@
 static inline void
 CGGI_FillImagesForGlyphs(jlong *glyphInfos, const AWTStrike *strike,
                          const CGGI_RenderingMode *mode,
-                         const UniChar uniChars[], const CGGlyph glyphs[],
+                         const UnicodeScalarValue uniChars[], const CGGlyph glyphs[],
                          const size_t maxWidth, const size_t maxHeight,
                          const CFIndex len)
 {
@@ -767,7 +767,7 @@
 static inline void
 CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
                       const CGGI_RenderingMode *mode,
-                      const UniChar uniChars[], const CGGlyph glyphs[],
+                      const UnicodeScalarValue uniChars[], const CGGlyph glyphs[],
                       CGSize advances[], CGRect bboxes[], const CFIndex len)
 {
     AWTFont *font = strike->fAWTFont;
@@ -817,7 +817,7 @@
                                         const AWTStrike *strike,
                                         const CGGI_RenderingMode *mode,
                                         jint rawGlyphCodes[],
-                                        UniChar uniChars[], CGGlyph glyphs[],
+                                        UnicodeScalarValue uniChars[], CGGlyph glyphs[],
                                         CGSize advances[], CGRect bboxes[],
                                         const CFIndex len)
 {
@@ -860,7 +860,7 @@
         CGRect bboxes[len];
         CGSize advances[len];
         CGGlyph glyphs[len];
-        UniChar uniChars[len];
+        UnicodeScalarValue uniChars[len];
 
         CGGI_CreateGlyphsAndScanForComplexities(glyphInfos, strike, &mode,
                                                 rawGlyphCodes, uniChars, glyphs,
@@ -871,7 +871,7 @@
 
     // just do one malloc, and carve it up for all the buffers
     void *buffer = malloc(sizeof(CGRect) * sizeof(CGSize) *
-                          sizeof(CGGlyph) * sizeof(UniChar) * len);
+                          sizeof(CGGlyph) * sizeof(UnicodeScalarValue) * len);
     if (buffer == NULL) {
         [[NSException exceptionWithName:NSMallocException
             reason:@"Failed to allocate memory for the temporary glyph strike and measurement buffers." userInfo:nil] raise];
@@ -880,7 +880,7 @@
     CGRect *bboxes = (CGRect *)(buffer);
     CGSize *advances = (CGSize *)(bboxes + sizeof(CGRect) * len);
     CGGlyph *glyphs = (CGGlyph *)(advances + sizeof(CGGlyph) * len);
-    UniChar *uniChars = (UniChar *)(glyphs + sizeof(UniChar) * len);
+    UnicodeScalarValue *uniChars = (UnicodeScalarValue *)(glyphs + sizeof(UnicodeScalarValue) * len);
 
     CGGI_CreateGlyphsAndScanForComplexities(glyphInfos, strike, &mode,
                                             rawGlyphCodes, uniChars, glyphs,
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h	Fri Dec 16 11:58:17 2016 -0800
@@ -32,7 +32,9 @@
 #pragma mark --- CoreText Support ---
 
 #define HI_SURROGATE_START 0xD800
+#define HI_SURROGATE_END   0xDBFF
 #define LO_SURROGATE_START 0xDC00
+#define LO_SURROGATE_END   0xDFFF
 
 /*
  *    Transform Unicode characters into glyphs.
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m	Fri Dec 16 11:58:17 2016 -0800
@@ -103,24 +103,34 @@
 
     size_t i;
     for (i = 0; i < count; i++) {
+        UniChar unicode = unicodes[i];
+        UniChar nextUnicode = (i+1) < count ? unicodes[i+1] : 0;
+        bool surrogatePair = unicode >= HI_SURROGATE_START && unicode <= HI_SURROGATE_END
+                             && nextUnicode >= LO_SURROGATE_START && nextUnicode <= LO_SURROGATE_END;
+
         CGGlyph glyph = glyphs[i];
         if (glyph > 0) {
             glyphsAsInts[i] = glyph;
+            if (surrogatePair) i++;
             continue;
         }
 
-        UniChar unicode = unicodes[i];
-        const CTFontRef fallback = JRSFontCreateFallbackFontForCharacters((CTFontRef)font->fFont, &unicode, 1);
+        const CTFontRef fallback = JRSFontCreateFallbackFontForCharacters((CTFontRef)font->fFont, &unicodes[i],
+                                                                          surrogatePair ? 2 : 1);
         if (fallback) {
-            CTFontGetGlyphsForCharacters(fallback, &unicode, &glyph, 1);
+            CTFontGetGlyphsForCharacters(fallback, &unicodes[i], &glyphs[i], surrogatePair ? 2 : 1);
+            glyph = glyphs[i];
             CFRelease(fallback);
         }
 
         if (glyph > 0) {
-            glyphsAsInts[i] = -unicode; // set the glyph code to the negative unicode value
+            int codePoint = surrogatePair ? (((int)(unicode - HI_SURROGATE_START)) << 10)
+                                            + nextUnicode - LO_SURROGATE_START + 0x10000 : unicode;
+            glyphsAsInts[i] = -codePoint; // set the glyph code to the negative unicode value
         } else {
             glyphsAsInts[i] = 0; // CoreText couldn't find a glyph for this character either
         }
+        if (surrogatePair) i++;
     }
 }
 
@@ -158,8 +168,18 @@
         return (CTFontRef)font->fFont;
     }
 
-    UTF16Char character = -glyphCode;
-    return CTS_CopyCTFallbackFontAndGlyphForUnicode(font, &character, glyphRef, 1);
+    int codePoint = -glyphCode;
+    if (codePoint >= 0x10000) {
+        UTF16Char chars[2];
+        CGGlyph glyphs[2];
+        CTS_BreakupUnicodeIntoSurrogatePairs(codePoint, chars);
+        CTFontRef result = CTS_CopyCTFallbackFontAndGlyphForUnicode(font, chars, glyphs, 2);
+        *glyphRef = glyphs[0];
+        return result;
+    } else {
+        UTF16Char character = codePoint;
+        return CTS_CopyCTFallbackFontAndGlyphForUnicode(font, &character, glyphRef, 1);
+    }
 }
 
 // Breakup a 32 bit unicode value into the component surrogate pairs
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Fri Dec 16 11:58:17 2016 -0800
@@ -541,10 +541,10 @@
     }
 
     // Stream position initially at beginning, left at end
-    // if ignoreUnknownFields is true, do not load fields for which
+    // if readUnknownTags is false, do not load fields for which
     // a tag cannot be found in an allowed TagSet.
     public void initialize(ImageInputStream stream, boolean isPrimaryIFD,
-        boolean ignoreUnknownFields) throws IOException {
+        boolean ignoreMetadata, boolean readUnknownTags) throws IOException {
 
         removeTIFFFields();
 
@@ -553,10 +553,16 @@
 
         List<TIFFTagSet> tagSetList = getTagSetList();
 
+        // Configure essential tag variables if this is the primary IFD and
+        // either all metadata are being ignored, or metadata are not being
+        // ignored but both unknown tags are being ignored and the tag set
+        // list does not contain the baseline tags.
         boolean ensureEssentialTags = false;
         TIFFTagSet baselineTagSet = null;
-        if (isPrimaryIFD && ignoreUnknownFields
-            && !tagSetList.contains(BaselineTIFFTagSet.getInstance())) {
+        if (isPrimaryIFD &&
+            (ignoreMetadata ||
+             (!readUnknownTags &&
+              !tagSetList.contains(BaselineTIFFTagSet.getInstance())))) {
             ensureEssentialTags = true;
             initializeEssentialTags();
             baselineTagSet = BaselineTIFFTagSet.getInstance();
@@ -590,9 +596,12 @@
                 tag = baselineTagSet.getTag(tagNumber);
             }
 
-            // Ignore unknown fields, fields with unknown type, and fields
+            // Ignore non-essential fields, unknown fields unless forcibly
+            // being read, fields with unknown type, and fields
             // with count out of int range.
-            if((tag == null && ignoreUnknownFields)
+            if((ignoreMetadata &&
+                (!ensureEssentialTags || !essentialTags.contains(tagNumber)))
+                || (tag == null && !readUnknownTags)
                 || (tag != null && !tag.isDataTypeOK(type))
                 || longCount > Integer.MAX_VALUE) {
                 // Skip the value/offset so as to leave the stream
@@ -701,7 +710,8 @@
                     tagSets.add(tag.getTagSet());
                     TIFFIFD subIFD = new TIFFIFD(tagSets);
 
-                    subIFD.initialize(stream, false, ignoreUnknownFields);
+                    subIFD.initialize(stream, false, ignoreMetadata,
+                                      readUnknownTags);
                     TIFFField f = new TIFFField(tag, type, e.offset, subIFD);
                     addTIFFField(f);
                 } else {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageMetadata.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageMetadata.java	Fri Dec 16 11:58:17 2016 -0800
@@ -82,12 +82,13 @@
     }
 
     public void initializeFromStream(ImageInputStream stream,
-                                     boolean ignoreUnknownFields)
+                                     boolean ignoreMetadata,
+                                     boolean readUnknownTags)
         throws IOException {
-        rootIFD.initialize(stream, true, ignoreUnknownFields);
+        rootIFD.initialize(stream, true, ignoreMetadata, readUnknownTags);
     }
 
-    public void addShortOrLongField(int tagNumber, int value) {
+    public void addShortOrLongField(int tagNumber, long value) {
         TIFFField field = new TIFFField(rootIFD.getTag(tagNumber), value);
         rootIFD.addTIFFField(field);
     }
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageReader.java	Fri Dec 16 11:58:17 2016 -0800
@@ -305,16 +305,19 @@
         try {
             // Create an object to store the image metadata
             List<TIFFTagSet> tagSets;
+            boolean readUnknownTags = false;
             if (imageReadParam instanceof TIFFImageReadParam) {
-                tagSets
-                        = ((TIFFImageReadParam) imageReadParam).getAllowedTagSets();
+                TIFFImageReadParam tp = (TIFFImageReadParam)imageReadParam;
+                tagSets = tp.getAllowedTagSets();
+                readUnknownTags = tp.getReadUnknownTags();
             } else {
                 tagSets = new ArrayList<TIFFTagSet>(1);
                 tagSets.add(BaselineTIFFTagSet.getInstance());
             }
 
             this.imageMetadata = new TIFFImageMetadata(tagSets);
-            imageMetadata.initializeFromStream(stream, ignoreMetadata);
+            imageMetadata.initializeFromStream(stream, ignoreMetadata,
+                                               readUnknownTags);
         } catch (IIOException iioe) {
             throw iioe;
         } catch (IOException ioe) {
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java	Fri Dec 16 11:58:17 2016 -0800
@@ -3015,7 +3015,7 @@
         List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1);
         tagSets.add(BaselineTIFFTagSet.getInstance());
         TIFFIFD rootIFD = new TIFFIFD(tagSets);
-        rootIFD.initialize(stream, true, true);
+        rootIFD.initialize(stream, true, false, false);
         stream.reset();
 
         return rootIFD;
--- a/jdk/src/java.desktop/share/classes/java/awt/CheckboxMenuItem.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/CheckboxMenuItem.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,18 +22,25 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package java.awt;
 
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.awt.peer.CheckboxMenuItemPeer;
-import java.awt.event.*;
-import java.util.EventListener;
-import java.io.ObjectOutputStream;
+import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.io.IOException;
-import javax.accessibility.*;
+import java.io.ObjectOutputStream;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleValue;
+
 import sun.awt.AWTAccessor;
 
-
 /**
  * This class represents a check box that can be included in a menu.
  * Selecting the check box in the menu changes its state from
@@ -43,7 +50,8 @@
  * of {@code CheckBoxMenuItem}:
  * <p>
  * <img src="doc-files/MenuBar-1.gif"
- * alt="Menu labeled Examples, containing items Basic, Simple, Check, and More Examples. The Check item is a CheckBoxMenuItem instance, in the off state."
+ * alt="Menu labeled Examples, containing items Basic, Simple, Check, and More
+ * Examples. The Check item is a CheckBoxMenuItem instance, in the off state."
  * style="float:center; margin: 7px 10px;">
  * <p>
  * The item labeled {@code Check} shows a check box menu item
@@ -84,9 +92,9 @@
     * @see #getState()
     * @see #setState(boolean)
     */
-    boolean state = false;
+    private volatile boolean state;
 
-    transient ItemListener itemListener;
+    private transient volatile ItemListener itemListener;
 
     private static final String base = "chkmenuitem";
     private static int nameCounter = 0;
--- a/jdk/src/java.desktop/share/classes/java/awt/Menu.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Menu.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,15 +22,20 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package java.awt;
 
+import java.awt.event.KeyEvent;
+import java.awt.peer.MenuPeer;
 import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Enumeration;
-import java.awt.peer.MenuPeer;
-import java.awt.event.KeyEvent;
-import javax.accessibility.*;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
 import sun.awt.AWTAccessor;
 
 /**
@@ -78,7 +83,7 @@
      * @serial
      * @see #countItems()
      */
-    Vector<MenuItem> items = new Vector<>();
+    private final Vector<MenuItem> items = new Vector<>();
 
     /**
      * This field indicates whether the menu has the
@@ -92,7 +97,7 @@
      * @serial
      * @see #isTearOff()
      */
-    boolean             tearOff;
+    private final boolean tearOff;
 
     /**
      * This field will be set to {@code true}
@@ -102,7 +107,7 @@
      *
      * @serial
      */
-    boolean             isHelpMenu;
+    volatile boolean isHelpMenu;
 
     private static final String base = "menu";
     private static int nameCounter = 0;
@@ -415,8 +420,8 @@
             if (peer != null) {
                 peer.delItem(index);
                 mi.removeNotify();
-                mi.parent = null;
             }
+            mi.parent = null;
         }
     }
 
--- a/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,16 +22,21 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package java.awt;
 
+import java.awt.event.KeyEvent;
+import java.awt.peer.MenuBarPeer;
 import java.io.IOException;
 import java.io.ObjectInputStream;
+import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Enumeration;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
 import sun.awt.AWTAccessor;
-import java.awt.peer.MenuBarPeer;
-import java.awt.event.KeyEvent;
-import javax.accessibility.*;
 
 /**
  * The {@code MenuBar} class encapsulates the platform's
@@ -94,7 +99,7 @@
      * @serial
      * @see #countMenus()
      */
-    Vector<Menu> menus = new Vector<>();
+    private final Vector<Menu> menus = new Vector<>();
 
     /**
      * This menu is a special menu dedicated to
@@ -106,7 +111,7 @@
      * @see #getHelpMenu()
      * @see #setHelpMenu(Menu)
      */
-    Menu helpMenu;
+    private volatile Menu helpMenu;
 
     private static final String base = "menubar";
     private static int nameCounter = 0;
@@ -252,8 +257,8 @@
             if (peer != null) {
                 peer.delMenu(index);
                 m.removeNotify();
-                m.parent = null;
             }
+            m.parent = null;
             if (helpMenu == m) {
                 helpMenu = null;
                 m.isHelpMenu = false;
--- a/jdk/src/java.desktop/share/classes/java/awt/MenuComponent.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/MenuComponent.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,21 +22,28 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package java.awt;
 
+import java.awt.event.ActionEvent;
 import java.awt.peer.MenuComponentPeer;
-import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.io.ObjectInputStream;
-import sun.awt.AppContext;
-import sun.awt.AWTAccessor;
-import sun.awt.ComponentFactory;
-
-import javax.accessibility.*;
-
 import java.security.AccessControlContext;
 import java.security.AccessController;
 
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+import sun.awt.ComponentFactory;
+
 /**
  * The abstract class {@code MenuComponent} is the superclass
  * of all menu-related components. In this respect, the class
@@ -60,13 +67,13 @@
     }
 
     transient volatile MenuComponentPeer peer;
-    transient MenuContainer parent;
+    transient volatile MenuContainer parent;
 
     /**
      * The {@code AppContext} of the {@code MenuComponent}.
      * This is set in the constructor and never changes.
      */
-    transient AppContext appContext;
+    private transient volatile AppContext appContext;
 
     /**
      * The menu component's font. This value can be
@@ -77,7 +84,7 @@
      * @see #setFont(Font)
      * @see #getFont()
      */
-    volatile Font font;
+    private volatile Font font;
 
     /**
      * The menu component's name, which defaults to {@code null}.
@@ -85,7 +92,7 @@
      * @see #getName()
      * @see #setName(String)
      */
-    private String name;
+    private volatile String name;
 
     /**
      * A variable to indicate whether a name is explicitly set.
@@ -94,14 +101,14 @@
      * @serial
      * @see #setName(String)
      */
-    private boolean nameExplicitlySet = false;
+    private volatile boolean nameExplicitlySet;
 
     /**
      * Defaults to {@code false}.
      * @serial
      * @see #dispatchEvent(AWTEvent)
      */
-    boolean newEventsOnly = false;
+    volatile boolean newEventsOnly;
 
     /*
      * The menu's AccessControlContext.
--- a/jdk/src/java.desktop/share/classes/java/awt/MenuItem.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/MenuItem.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,15 +22,25 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package java.awt;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
 import java.awt.peer.MenuItemPeer;
-import java.awt.event.*;
-import java.util.EventListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-import javax.accessibility.*;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleValue;
+
 import sun.awt.AWTAccessor;
 
 /**
@@ -111,7 +121,7 @@
      * @see #isEnabled()
      * @see #setEnabled(boolean)
      */
-    boolean enabled = true;
+    private volatile boolean enabled = true;
 
     /**
      * {@code label} is the label of a menu item.
@@ -121,7 +131,7 @@
      * @see #getLabel()
      * @see #setLabel(String)
      */
-    String label;
+    volatile String label;
 
     /**
      * This field indicates the command that has been issued
@@ -134,7 +144,7 @@
      * @see #setActionCommand(String)
      * @see #getActionCommand()
      */
-    String actionCommand;
+    private volatile String actionCommand;
 
     /**
      * The eventMask is ONLY set by subclasses via enableEvents.
@@ -144,9 +154,9 @@
      *
      * @serial
      */
-    long eventMask;
+    volatile long eventMask;
 
-    transient ActionListener actionListener;
+    private transient volatile ActionListener actionListener;
 
     /**
      * A sequence of key stokes that ia associated with
@@ -160,7 +170,7 @@
      * @see #setShortcut(MenuShortcut)
      * @see #deleteShortcut()
      */
-    private MenuShortcut shortcut = null;
+    private volatile MenuShortcut shortcut;
 
     private static final String base = "menuitem";
     private static int nameCounter = 0;
--- a/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/PopupMenu.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,9 @@
 package java.awt;
 
 import java.awt.peer.PopupMenuPeer;
-import javax.accessibility.*;
 
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
 
 import sun.awt.AWTAccessor;
 
@@ -48,7 +49,7 @@
     private static final String base = "popup";
     static int nameCounter = 0;
 
-    transient boolean isTrayIconPopup = false;
+    transient volatile boolean isTrayIconPopup;
 
     static {
         AWTAccessor.setPopupMenuAccessor(
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java	Fri Dec 16 11:58:17 2016 -0800
@@ -4122,6 +4122,10 @@
             public void setTrayIconWindow(Window w, boolean isTrayIconWindow) {
                 w.isTrayIconWindow = isTrayIconWindow;
             }
+
+            public Window[] getOwnedWindows(Window w) {
+                return w.getOwnedWindows_NoClientCode();
+            }
         }); // WindowAccessor
     } // static
 
--- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Fri Dec 16 11:58:17 2016 -0800
@@ -279,7 +279,7 @@
     }
 
     /**
-     * Sets the cursor for this drag operation to the specified
+     * Sets the custom cursor for this drag operation to the specified
      * {@code Cursor}.  If the specified {@code Cursor}
      * is {@code null}, the default drag cursor behavior is
      * activated for this drag operation, otherwise it is deactivated.
@@ -298,9 +298,11 @@
     }
 
     /**
-     * Returns the current drag {@code Cursor}.
+     * Returns the current custom drag {@code Cursor}.
      *
-     * @return the current drag {@code Cursor}
+     * @return the current custom drag {@code Cursor}, if it was set
+     *         otherwise returns {@code null}.
+     * @see #setCursor
      */
 
     public Cursor getCursor() { return cursor; }
--- a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java	Fri Dec 16 11:58:17 2016 -0800
@@ -64,27 +64,71 @@
 public abstract class AbstractMultiResolutionImage extends java.awt.Image
         implements MultiResolutionImage {
 
+    /**
+     * This method simply delegates to the same method on the base image and
+     * it is equivalent to: {@code getBaseImage().getWidth(observer)}.
+     *
+     * @return the width of the base image, or -1 if the width is not yet known
+     * @see #getBaseImage()
+     *
+     * @since 9
+     */
     @Override
     public int getWidth(ImageObserver observer) {
         return getBaseImage().getWidth(observer);
     }
 
+    /**
+     * This method simply delegates to the same method on the base image and
+     * it is equivalent to: {@code getBaseImage().getHeight(observer)}.
+     *
+     * @return the height of the base image, or -1 if the height is not yet known
+     * @see #getBaseImage()
+     *
+     * @since 9
+     */
     @Override
     public int getHeight(ImageObserver observer) {
         return getBaseImage().getHeight(observer);
     }
 
+    /**
+     * This method simply delegates to the same method on the base image and
+     * it is equivalent to: {@code getBaseImage().getSource()}.
+     *
+     * @return the image producer that produces the pixels for the base image
+     * @see #getBaseImage()
+     *
+     * @since 9
+     */
     @Override
     public ImageProducer getSource() {
         return getBaseImage().getSource();
     }
 
+    /**
+     * As per the contract of the base {@code Image#getGraphics()} method,
+     * this implementation will always throw {@code UnsupportedOperationException}
+     * since only off-screen images can return a {@code Graphics} object.
+     *
+     * @return throws {@code UnsupportedOperationException}
+     * @throws UnsupportedOperationException this method is not supported
+     */
     @Override
     public Graphics getGraphics() {
         throw new UnsupportedOperationException("getGraphics() not supported"
                 + " on Multi-Resolution Images");
     }
 
+    /**
+     * This method simply delegates to the same method on the base image and
+     * it is equivalent to: {@code getBaseImage().getProperty(name, observer)}.
+     *
+     * @return the value of the named property in the base image
+     * @see #getBaseImage()
+     *
+     * @since 9
+     */
     @Override
     public Object getProperty(String name, ImageObserver observer) {
         return getBaseImage().getProperty(name, observer);
--- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html	Fri Dec 16 11:58:17 2016 -0800
@@ -216,22 +216,27 @@
 
 <h4><a name="MetadataIssuesRead"/>Metadata Issues</h4>
 
-By default all fields in the TIFF image file directory (IFD) are loaded into
-the native image metadata object. In cases where the IFD includes fields which
-contain large amounts of data this could be very inefficient. Which fields
-are loaded may be controlled by setting which TIFF tags the reader is allowed
-to recognize and whether it is ignoring metadata. The reader is informed to
-disregard metadata as usual via the <code>ignoreMetadata</code> parameter of
+By default all recognized fields in the TIFF image file directory (IFD) are
+loaded into the native image metadata object. Which fields are loaded may be
+controlled by setting which TIFF tags the reader is allowed to recognize,
+whether to read fields with unrecognized tags, and whether to ignore all
+metadata. The reader is informed to disregard all metadata as usual via the
+<code>ignoreMetadata</code> parameter of
 <code>ImageReader.setInput(Object,boolean,boolean)</code>. It is
 informed of which <a href="../../plugins/tiff/TIFFTag.html">TIFFTag</a>s to
 recognize or not to recognize via
-<code>TIFFImageReadParam.addAllowedTagSet(TIFFTagSet)</code>
-and
+<code>TIFFImageReadParam.addAllowedTagSet(TIFFTagSet)</code> and
 <code>TIFFImageReadParam.removeAllowedTagSet(TIFFTagSet)</code>.
-If <code>ignoreMetadata</code> is <code>true</code>, then the reader will
-load into the native image metadata object only those fields which have a
-<code>TIFFTag</code> contained in the one of the allowed
-<code>TIFFTagSet</code>s.
+If <code>ignoreMetadata</code> is <code>true</code>, then only metadata
+essential to reading the image will be loaded into the native image metadata
+object. If <code>ignoreMetadata</code> is <code>false</code>, then the reader
+will by default load into the native image metadata object only those fields
+which are either essential to reading the image or have a <code>TIFFTag</code>
+contained in the one of the allowed <code>TIFFTagSet</code>s. Reading of
+fields with tags not in the allowed <code>TIFFTagSet</code>s may be forced
+by passing in a <code>TIFFImageReadParam</code> on which
+<code>TIFFImageReadParam.setReadUnknownTags(boolean)</code> has been
+invoked with parameter <code>true</code>.
 
 <p>Use of a <a href="../../plugins/tiff/TIFFDirectory.html">TIFFDirectory</a>
 object may simplify gaining access to metadata values. An instance of
@@ -534,7 +539,7 @@
 <tr>
 <td>ZLib</td>
 <td>"Deflate/Inflate" compression (see note following this table)</td>
-<td><a href="http://partners.adobe.com/asn/developer/pdfs/tn/TIFFphotoshop.pdf">
+<td><a href="http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf">
 Adobe Photoshop&#174; TIFF Technical Notes</a> (PDF)</td>
 </tr>
 <tr>
@@ -545,9 +550,9 @@
 <tr>
 <td>Deflate</td>
 <td>"Zip-in-TIFF" compression (see note following this table)</td>
-<td><a href="http://www.isi.edu/in-notes/rfc1950.txt">
+<td><a href="https://tools.ietf.org/html/rfc1950">
 ZLIB Compressed Data Format Specification</a>,
-<a href="http://www.isi.edu/in-notes/rfc1951.txt">
+<a href="https://tools.ietf.org/html/rfc1951">
 DEFLATE Compressed Data Format Specification</a></td>
 </tr>
 <tr>
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java	Fri Dec 16 11:58:17 2016 -0800
@@ -224,7 +224,7 @@
      * A value to be used with the "Compression" tag.
      *
      * @see #TAG_COMPRESSION
-     * @see <a href="http://www.isi.edu/in-notes/rfc1951.txt">DEFLATE specification</a>
+     * @see <a href="https://tools.ietf.org/html/rfc1951">DEFLATE specification</a>
      * @see <a href="http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf"> TIFF Specification Supplement 2</a>
      */
     public static final int COMPRESSION_DEFLATE = 32946;
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java	Fri Dec 16 11:58:17 2016 -0800
@@ -29,7 +29,7 @@
 
 /**
  * A class representing the extra tags found in a
- * <a href="http://tools.ietf.org/html/rfc2306"> TIFF-F</a> (RFC 2036) file.
+ * <a href="http://tools.ietf.org/html/rfc2306.html">TIFF-F</a> (RFC 2036) file.
  *
  * @since 9
  */
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java	Fri Dec 16 11:58:17 2016 -0800
@@ -30,10 +30,7 @@
 /**
  * A class representing the tags found in a GeoTIFF IFD.  GeoTIFF is a
  * standard for annotating georeferenced or geocoded raster imagery.
- * The GeoTIFF specification may be found at <a
- * href="http://www.remotesensing.org/geotiff/spec/geotiffhome.html">
- * {@code http://www.remotesensing.org/geotiff/spec/geotiffhome.html}
- * </a>. This class does <i>not</i> handle the <i>GeoKey</i>s referenced
+ * This class does <i>not</i> handle the <i>GeoKey</i>s referenced
  * from a <i>GeoKeyDirectoryTag</i> as those are not TIFF tags per se.
  *
  * <p>The definitions of the data types referenced by the field
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Fri Dec 16 11:58:17 2016 -0800
@@ -263,14 +263,16 @@
  */
 public final class TIFFField implements Cloneable {
 
-    private static final String[] typeNames = {
+    private static final long MAX_UINT32 = 0xffffffffL;
+
+    private static final String[] TYPE_NAMES = {
         null,
         "Byte", "Ascii", "Short", "Long", "Rational",
         "SByte", "Undefined", "SShort", "SLong", "SRational",
         "Float", "Double", "IFDPointer"
     };
 
-    private static final boolean[] isIntegral = {
+    private static final boolean[] IS_INTEGRAL = {
         false,
         true, false, true, true, false,
         true, true, true, true, false,
@@ -544,6 +546,9 @@
      * @throws IllegalArgumentException if {@code data} is an instance of
      * a class incompatible with the specified type.
      * @throws IllegalArgumentException if the size of the data array is wrong.
+     * @throws IllegalArgumentException if the type of the data array is
+     * {@code TIFF_LONG}, {@code TIFF_RATIONAL}, or {@code TIFF_IFD_POINTER}
+     * and any of the elements is negative or greater than {@code 0xffffffff}.
      */
     public TIFFField(TIFFTag tag, int type, int count, Object data) {
         if(tag == null) {
@@ -587,15 +592,50 @@
         case TIFFTag.TIFF_LONG:
             isDataArrayCorrect = data instanceof long[]
                 && ((long[])data).length == count;
+            if (isDataArrayCorrect) {
+                for (long datum : (long[])data) {
+                    if (datum < 0) {
+                        throw new IllegalArgumentException
+                            ("Negative value supplied for TIFF_LONG");
+                    }
+                    if (datum > MAX_UINT32) {
+                        throw new IllegalArgumentException
+                            ("Too large value supplied for TIFF_LONG");
+                    }
+                }
+            }
             break;
         case TIFFTag.TIFF_IFD_POINTER:
             isDataArrayCorrect = data instanceof long[]
                 && ((long[])data).length == 1;
+            if (((long[])data)[0] < 0) {
+                throw new IllegalArgumentException
+                    ("Negative value supplied for TIFF_IFD_POINTER");
+            }
+            if (((long[])data)[0] > MAX_UINT32) {
+                throw new IllegalArgumentException
+                    ("Too large value supplied for TIFF_IFD_POINTER");
+            }
             break;
         case TIFFTag.TIFF_RATIONAL:
             isDataArrayCorrect = data instanceof long[][]
-                && ((long[][])data).length == count
-                && ((long[][])data)[0].length == 2;
+                && ((long[][])data).length == count;
+            if (isDataArrayCorrect) {
+                for (long[] datum : (long[][])data) {
+                    if (datum.length != 2) {
+                        isDataArrayCorrect = false;
+                        break;
+                    }
+                    if (datum[0] < 0 || datum[1] < 0) {
+                        throw new IllegalArgumentException
+                            ("Negative value supplied for TIFF_RATIONAL");
+                    }
+                    if (datum[0] > MAX_UINT32 || datum[1] > MAX_UINT32) {
+                        throw new IllegalArgumentException
+                            ("Too large value supplied for TIFF_RATIONAL");
+                    }
+                }
+            }
             break;
         case TIFFTag.TIFF_SSHORT:
             isDataArrayCorrect = data instanceof short[]
@@ -607,8 +647,15 @@
             break;
         case TIFFTag.TIFF_SRATIONAL:
             isDataArrayCorrect = data instanceof int[][]
-                && ((int[][])data).length == count
-                && ((int[][])data)[0].length == 2;
+                && ((int[][])data).length == count;
+            if (isDataArrayCorrect) {
+                for (int[] datum : (int[][])data) {
+                    if (datum.length != 2) {
+                        isDataArrayCorrect = false;
+                        break;
+                    }
+                }
+            }
             break;
         case TIFFTag.TIFF_FLOAT:
             isDataArrayCorrect = data instanceof float[]
@@ -658,27 +705,32 @@
 
     /**
      * Constructs a {@code TIFFField} with a single non-negative integral
-     * value.
-     * The field will have type
-     * {@link TIFFTag#TIFF_SHORT  TIFF_SHORT} if
-     * {@code val < 65536} and type
-     * {@link TIFFTag#TIFF_LONG TIFF_LONG} otherwise.  The count
-     * of the field will be unity.
+     * value. The field will have type {@link TIFFTag#TIFF_SHORT TIFF_SHORT}
+     * if {@code value} is in {@code [0,0xffff]}, and type
+     * {@link TIFFTag#TIFF_LONG TIFF_LONG} if {@code value} is in
+     * {@code [0x10000,0xffffffff]}. The count of the field will be unity.
      *
      * @param tag The tag to associate with this field.
      * @param value The value to associate with this field.
      * @throws NullPointerException if {@code tag == null}.
-     * @throws IllegalArgumentException if the derived type is unacceptable
-     * for the supplied {@code TIFFTag}.
-     * @throws IllegalArgumentException if {@code value < 0}.
+     * @throws IllegalArgumentException if {@code value} is not in
+     * {@code [0,0xffffffff]}.
+     * @throws IllegalArgumentException if {@code value} is in
+     * {@code [0,0xffff]} and {@code TIFF_SHORT} is an unacceptable type
+     * for the {@code TIFFTag}, or if {@code value} is in
+     * {@code [0x10000,0xffffffff]} and {@code TIFF_LONG} is an unacceptable
+     * type for the {@code TIFFTag}.
      */
-    public TIFFField(TIFFTag tag, int value) {
+    public TIFFField(TIFFTag tag, long value) {
         if(tag == null) {
             throw new NullPointerException("tag == null!");
         }
         if (value < 0) {
             throw new IllegalArgumentException("value < 0!");
         }
+        if (value > MAX_UINT32) {
+            throw new IllegalArgumentException("value > 0xffffffff!");
+        }
 
         this.tag = tag;
         this.tagNumber = tag.getNumber();
@@ -687,7 +739,8 @@
         if (value < 65536) {
             if (!tag.isDataTypeOK(TIFFTag.TIFF_SHORT)) {
                 throw new IllegalArgumentException("Illegal data type "
-                    + TIFFTag.TIFF_SHORT + " for " + tag.getName() + " tag");
+                    + getTypeName(TIFFTag.TIFF_SHORT) + " for tag "
+                    + "\"" + tag.getName() + "\"");
             }
             this.type = TIFFTag.TIFF_SHORT;
             char[] cdata = new char[1];
@@ -696,7 +749,8 @@
         } else {
             if (!tag.isDataTypeOK(TIFFTag.TIFF_LONG)) {
                 throw new IllegalArgumentException("Illegal data type "
-                    + TIFFTag.TIFF_LONG + " for " + tag.getName() + " tag");
+                    + getTypeName(TIFFTag.TIFF_LONG) + " for tag "
+                    + "\"" + tag.getName() + "\"");
             }
             this.type = TIFFTag.TIFF_LONG;
             long[] ldata = new long[1];
@@ -799,7 +853,7 @@
             throw new IllegalArgumentException("Unknown data type "+dataType);
         }
 
-        return typeNames[dataType];
+        return TYPE_NAMES[dataType];
     }
 
     /**
@@ -812,7 +866,7 @@
      */
     public static int getTypeByName(String typeName) {
         for (int i = TIFFTag.MIN_DATATYPE; i <= TIFFTag.MAX_DATATYPE; i++) {
-            if (typeName.equals(typeNames[i])) {
+            if (typeName.equals(TYPE_NAMES[i])) {
                 return i;
             }
         }
@@ -887,7 +941,7 @@
      * @return Whether the field type is integral.
      */
     public boolean isIntegral() {
-        return isIntegral[type];
+        return IS_INTEGRAL[type];
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java	Fri Dec 16 11:58:17 2016 -0800
@@ -46,11 +46,18 @@
  * {@code ExifParentTIFFTagSet}, and {@code GeoTIFFTagSet}
  * are included.
  *
+ * <p> Forcing reading of fields corresponding to {@code TIFFTag}s
+ * not in any of the allowed {@code TIFFTagSet}s may be effected via
+ * {@link #setReadUnknownTags setReadUnknownTags}.
+ *
  * @since 9
  */
 public final class TIFFImageReadParam extends ImageReadParam {
 
-    private List<TIFFTagSet> allowedTagSets = new ArrayList<TIFFTagSet>(4);
+    private final List<TIFFTagSet> allowedTagSets =
+        new ArrayList<TIFFTagSet>(4);
+
+    private boolean readUnknownTags = false;
 
     /**
      * Constructs a {@code TIFFImageReadParam}.  Tags defined by
@@ -72,7 +79,8 @@
 
     /**
      * Adds a {@code TIFFTagSet} object to the list of allowed
-     * tag sets.
+     * tag sets.  Attempting to add a duplicate object to the list
+     * has no effect.
      *
      * @param tagSet a {@code TIFFTagSet}.
      *
@@ -83,7 +91,9 @@
         if (tagSet == null) {
             throw new IllegalArgumentException("tagSet == null!");
         }
-        allowedTagSets.add(tagSet);
+        if (!allowedTagSets.contains(tagSet)) {
+            allowedTagSets.add(tagSet);
+        }
     }
 
     /**
@@ -113,4 +123,27 @@
     public List<TIFFTagSet> getAllowedTagSets() {
         return allowedTagSets;
     }
+
+    /**
+     * Set whether to read fields corresponding to {@code TIFFTag}s not in
+     * the allowed {@code TIFFTagSet}s. The default setting is {@code false}.
+     * If the TIFF {@code ImageReader} is ignoring metadata, then a setting
+     * of {@code true} is overridden as all metadata are ignored except those
+     * essential to reading the image itself.
+     *
+     * @param readUnknownTags Whether to read fields of unrecognized tags
+     */
+    public void setReadUnknownTags(boolean readUnknownTags) {
+        this.readUnknownTags = readUnknownTags;
+    }
+
+    /**
+     * Retrieve the setting of whether to read fields corresponding to unknown
+     * {@code TIFFTag}s.
+     *
+     * @return Whether to read fields of unrecognized tags
+     */
+    public boolean getReadUnknownTags() {
+        return readUnknownTags;
+    }
 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Fri Dec 16 11:58:17 2016 -0800
@@ -182,6 +182,8 @@
      */
     private int modelRowCount;
 
+    // Whether to print warning about JDK-8160087
+    private static boolean warning8160087 = true;
 
     /**
      * Creates an empty <code>DefaultRowSorter</code>.
@@ -489,10 +491,7 @@
      */
     public int convertRowIndexToView(int index) {
         if (modelToView == null) {
-            if (index < 0 || index >= modelRowCount) {
-                throw new IndexOutOfBoundsException("Invalid index");
-            }
-            return index;
+            return convertUnsortedUnfiltered(index);
         }
         return modelToView[index];
     }
@@ -504,14 +503,30 @@
      */
     public int convertRowIndexToModel(int index) {
         if (viewToModel == null) {
-            if (index < 0 || index >= modelRowCount) {
-                throw new IndexOutOfBoundsException("Invalid index");
-            }
-            return index;
+            return convertUnsortedUnfiltered(index);
         }
         return viewToModel[index].modelIndex;
     }
 
+    private int convertUnsortedUnfiltered(int index) {
+        if (index < 0 || index >= modelRowCount) {
+            if(index >= modelRowCount &&
+                                      index < getModelWrapper().getRowCount()) {
+                // 8160087
+                if(warning8160087) {
+                    warning8160087 = false;
+                    System.err.println("WARNING: row index is bigger than " +
+                            "sorter's row count. Most likely this is a wrong " +
+                            "sorter usage.");
+                }
+            } else {
+                throw new IndexOutOfBoundsException("Invalid index");
+            }
+        }
+        return index;
+    }
+
+
     private boolean isUnsorted() {
         List<? extends SortKey> keys = getSortKeys();
         int keySize = keys.size();
--- a/jdk/src/java.desktop/share/classes/javax/swing/JMenuBar.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JMenuBar.java	Fri Dec 16 11:58:17 2016 -0800
@@ -27,6 +27,7 @@
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.Insets;
+import java.awt.Toolkit;
 import java.awt.event.*;
 import java.beans.JavaBean;
 import java.beans.BeanProperty;
@@ -41,6 +42,8 @@
 import javax.swing.plaf.*;
 import javax.accessibility.*;
 
+import sun.awt.SunToolkit;
+
 /**
  * An implementation of a menu bar. You add <code>JMenu</code> objects to the
  * menu bar to construct a menu. When the user selects a <code>JMenu</code>
@@ -144,6 +147,10 @@
      * @see JComponent#updateUI
      */
     public void updateUI() {
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        if (tk instanceof SunToolkit) {
+            ((SunToolkit)tk).updateScreenMenuBarUI();
+        }
         setUI((MenuBarUI)UIManager.getUI(this));
     }
 
--- a/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JViewport.java	Fri Dec 16 11:58:17 2016 -0800
@@ -47,6 +47,7 @@
 import java.util.Collections;
 
 import sun.awt.AWTAccessor;
+import sun.swing.SwingUtilities2;
 
 /**
  * The "viewport" or "porthole" through which you see the underlying
@@ -1034,9 +1035,16 @@
     private boolean isBlitting() {
         Component view = getView();
         return (scrollMode == BLIT_SCROLL_MODE) &&
-               (view instanceof JComponent) && view.isOpaque();
+               (view instanceof JComponent) && view.isOpaque() && !isFPScale();
     }
 
+    private boolean isFPScale() {
+        GraphicsConfiguration gc = getGraphicsConfiguration();
+        if (gc != null) {
+            return SwingUtilities2.isFloatingPointScale(gc.getDefaultTransform());
+        }
+        return false;
+    }
 
     /**
      * Returns the <code>JViewport</code>'s one child or <code>null</code>.
--- a/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Fri Dec 16 11:58:17 2016 -0800
@@ -45,7 +45,11 @@
 import sun.security.action.GetPropertyAction;
 
 import com.sun.java.swing.SwingUtilities3;
+import java.awt.geom.AffineTransform;
+import sun.java2d.SunGraphics2D;
+import sun.java2d.pipe.Region;
 import sun.swing.SwingAccessor;
+import sun.swing.SwingUtilities2;
 import sun.swing.SwingUtilities2.RepaintListener;
 
 /**
@@ -1517,9 +1521,12 @@
             // standard Image buffer.
             boolean paintCompleted = false;
             Image offscreen;
+            int sw = w + 1;
+            int sh = h + 1;
+
             if (repaintManager.useVolatileDoubleBuffer() &&
                 (offscreen = getValidImage(repaintManager.
-                getVolatileOffscreenBuffer(bufferComponent, w, h))) != null) {
+                getVolatileOffscreenBuffer(bufferComponent, sw, sh))) != null) {
                 VolatileImage vImage = (java.awt.image.VolatileImage)offscreen;
                 GraphicsConfiguration gc = bufferComponent.
                                             getGraphicsConfiguration();
@@ -1529,7 +1536,7 @@
                                    VolatileImage.IMAGE_INCOMPATIBLE) {
                         repaintManager.resetVolatileDoubleBuffer(gc);
                         offscreen = repaintManager.getVolatileOffscreenBuffer(
-                            bufferComponent,w, h);
+                            bufferComponent, sw, sh);
                         vImage = (java.awt.image.VolatileImage)offscreen;
                     }
                     paintDoubleBuffered(paintingComponent, vImage, g, x, y,
@@ -1589,8 +1596,18 @@
          * Paints a portion of a component to an offscreen buffer.
          */
         protected void paintDoubleBuffered(JComponent c, Image image,
-                            Graphics g, int clipX, int clipY,
-                            int clipW, int clipH) {
+                Graphics g, int clipX, int clipY,
+                int clipW, int clipH) {
+            if (image instanceof VolatileImage && isPixelsCopying(c, g)) {
+                paintDoubleBufferedFPScales(c, image, g, clipX, clipY, clipW, clipH);
+            } else {
+                paintDoubleBufferedImpl(c, image, g, clipX, clipY, clipW, clipH);
+            }
+        }
+
+        private void paintDoubleBufferedImpl(JComponent c, Image image,
+                                             Graphics g, int clipX, int clipY,
+                                             int clipW, int clipH) {
             Graphics osg = image.getGraphics();
             int bw = Math.min(clipW, image.getWidth(null));
             int bh = Math.min(clipH, image.getHeight(null));
@@ -1629,6 +1646,76 @@
             }
         }
 
+        private void paintDoubleBufferedFPScales(JComponent c, Image image,
+                                                 Graphics g, int clipX, int clipY,
+                                                 int clipW, int clipH) {
+            Graphics osg = image.getGraphics();
+            Graphics2D g2d = (Graphics2D) g;
+            Graphics2D osg2d = (Graphics2D) osg;
+
+            AffineTransform identity = new AffineTransform();
+            int bw = Math.min(clipW, image.getWidth(null));
+            int bh = Math.min(clipH, image.getHeight(null));
+            int x, y, maxx, maxy;
+
+            AffineTransform tx = g2d.getTransform();
+            double scaleX = tx.getScaleX();
+            double scaleY = tx.getScaleY();
+            double trX = tx.getTranslateX();
+            double trY = tx.getTranslateY();
+
+            boolean translucent = volatileBufferType != Transparency.OPAQUE;
+            Composite oldComposite = g2d.getComposite();
+
+            try {
+                for (x = clipX, maxx = clipX + clipW; x < maxx; x += bw) {
+                    for (y = clipY, maxy = clipY + clipH; y < maxy; y += bh) {
+
+                        // draw x, y, bw, bh
+                        int pixelx1 = Region.clipRound(x * scaleX + trX);
+                        int pixely1 = Region.clipRound(y * scaleY + trY);
+                        int pixelx2 = Region.clipRound((x + bw) * scaleX + trX);
+                        int pixely2 = Region.clipRound((y + bh) * scaleY + trY);
+                        int pixelw = pixelx2 - pixelx1;
+                        int pixelh = pixely2 - pixely1;
+
+                        osg2d.setTransform(identity);
+                        if (translucent) {
+                            final Color oldBg = g2d.getBackground();
+                            g2d.setBackground(c.getBackground());
+                            g2d.clearRect(pixelx1, pixely1, pixelw, pixelh);
+                            g2d.setBackground(oldBg);
+                        }
+
+                        osg2d.setClip(0, 0, pixelw, pixelh);
+                        osg2d.translate(trX - pixelx1, trY - pixely1);
+                        osg2d.scale(scaleX, scaleY);
+                        c.paintToOffscreen(osg, x, y, bw, bh, maxx, maxy);
+
+                        g2d.setTransform(identity);
+                        g2d.setClip(pixelx1, pixely1, pixelw, pixelh);
+                        AffineTransform stx = new AffineTransform();
+                        stx.translate(pixelx1, pixely1);
+                        stx.scale(scaleX, scaleY);
+                        g2d.setTransform(stx);
+
+                        if (translucent) {
+                            g2d.setComposite(AlphaComposite.Src);
+                        }
+
+                        g2d.drawImage(image, 0, 0, c);
+
+                        if (translucent) {
+                            g2d.setComposite(oldComposite);
+                        }
+                        g2d.setTransform(tx);
+                    }
+                }
+            } finally {
+                osg.dispose();
+            }
+        }
+
         /**
          * If <code>image</code> is non-null with a positive size it
          * is returned, otherwise null is returned.
@@ -1671,9 +1758,33 @@
          */
         protected void dispose() {
         }
+
+        private boolean isPixelsCopying(JComponent c, Graphics g) {
+
+            AffineTransform tx = getTransform(g);
+            GraphicsConfiguration gc = c.getGraphicsConfiguration();
+
+            if (tx == null || gc == null
+                    || !SwingUtilities2.isFloatingPointScale(tx)) {
+                return false;
+            }
+
+            AffineTransform gcTx = gc.getDefaultTransform();
+
+            return gcTx.getScaleX() == tx.getScaleX()
+                    && gcTx.getScaleY() == tx.getScaleY();
+        }
+
+        private static AffineTransform getTransform(Graphics g) {
+            if (g instanceof SunGraphics2D) {
+                return ((SunGraphics2D) g).transform;
+            } else if (g instanceof Graphics2D) {
+                return ((Graphics2D) g).getTransform();
+            }
+            return null;
+        }
     }
 
-
     private class DoubleBufferInfo {
         public Image image;
         public Dimension size;
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Fri Dec 16 11:58:17 2016 -0800
@@ -571,7 +571,9 @@
 
     /**
      * Obsolete class, not used in this version.
+     * @deprecated As of JDK version 9. Obsolete class.
      */
+    @Deprecated(since = "9")
     protected class SingleClickListener extends MouseAdapter {
         /**
          * Constructs an instance of {@code SingleClickListener}.
@@ -584,7 +586,9 @@
 
     /**
      * Obsolete class, not used in this version.
+     * @deprecated As of JDK version 9. Obsolete class.
      */
+    @Deprecated(since = "9")
     @SuppressWarnings("serial") // Superclass is not serializable across versions
     protected class FileRenderer extends DefaultListCellRenderer  {
     }
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Fri Dec 16 11:58:17 2016 -0800
@@ -26,6 +26,7 @@
 
 import java.awt.*;
 import java.awt.font.FontRenderContext;
+import java.awt.geom.Rectangle2D;
 import java.lang.ref.SoftReference;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -750,7 +751,6 @@
          *   valid location in the associated document
          * @see View#modelToView
          */
-        @SuppressWarnings("deprecation")
         public Shape modelToView(int pos, Shape a, Position.Bias b)
                 throws BadLocationException {
             Rectangle alloc = a.getBounds();
@@ -777,9 +777,11 @@
             if (pos > p0) {
                 Segment segment = SegmentCache.getSharedSegment();
                 loadText(segment, p0, pos);
-                alloc.x += Utilities.getTabbedTextWidth(segment, metrics,
-                        alloc.x, WrappedPlainView.this, p0);
+                float x = alloc.x;
+                x += Utilities.getTabbedTextWidth(segment, metrics, x,
+                                                  WrappedPlainView.this, p0);
                 SegmentCache.releaseSharedSegment(segment);
+                return new Rectangle2D.Float(x, alloc.y, alloc.width, alloc.height);
             }
             return alloc;
         }
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java	Fri Dec 16 11:58:17 2016 -0800
@@ -360,6 +360,12 @@
          * Marks the specified window as an utility window for TrayIcon.
          */
         void setTrayIconWindow(Window w, boolean isTrayIconWindow);
+
+        /**
+         * Return an array containing all the windows this
+         * window currently owns.
+         */
+        Window[] getOwnedWindows(Window w);
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1857,6 +1857,9 @@
         return time == null ? -1 : time;
     }
 
+    public void updateScreenMenuBarUI() {
+    }
+
     // Cosntant alpha
     public boolean isWindowOpacitySupported() {
         return false;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java	Fri Dec 16 11:58:17 2016 -0800
@@ -3101,10 +3101,10 @@
             if (scaleX == 1 && scaleY == 1) {
                 return null;
             }
-            sx1 = Region.clipScale(sx1, scaleX);
-            sx2 = Region.clipScale(sx2, scaleX);
-            sy1 = Region.clipScale(sy1, scaleY);
-            sy2 = Region.clipScale(sy2, scaleY);
+            sx1 = Region.clipRound(sx1 * scaleX);
+            sx2 = Region.clipRound(sx2 * scaleX);
+            sy1 = Region.clipRound(sy1 * scaleY);
+            sy2 = Region.clipRound(sy2 * scaleY);
 
             AffineTransform tx = null;
             if (xform != null) {
--- a/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java	Fri Dec 16 11:58:17 2016 -0800
@@ -305,6 +305,12 @@
             int startY = (int)Math.floor(y * scaleY);
             int width  = (int)Math.ceil((x + w) * scaleX) - startX;
             int height = (int)Math.ceil((y + h) * scaleY) - startY;
+            if (startX + width > linestride) {
+                width = linestride - startX;
+            }
+            if (startY + height > bbImage.getHeight()) {
+                height = bbImage.getHeight() - startY;
+            }
 
             for (int i = 0; i < height; i++) {
                 int from = (startY + i) * linestride + startX;
--- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java	Fri Dec 16 11:58:17 2016 -0800
@@ -33,6 +33,7 @@
 import java.awt.geom.Rectangle2D;
 import java.awt.geom.AffineTransform;
 import static java.awt.geom.AffineTransform.TYPE_FLIP;
+import static java.awt.geom.AffineTransform.TYPE_MASK_SCALE;
 import static java.awt.geom.AffineTransform.TYPE_TRANSLATION;
 import java.awt.print.PrinterGraphics;
 import java.text.BreakIterator;
@@ -2162,6 +2163,19 @@
         return false;
     }
 
+    public static boolean isFloatingPointScale(AffineTransform tx) {
+        int type = tx.getType() & ~(TYPE_FLIP | TYPE_TRANSLATION);
+        if (type == 0) {
+            return false;
+        } else if ((type & ~TYPE_MASK_SCALE) == 0) {
+            double scaleX = tx.getScaleX();
+            double scaleY = tx.getScaleY();
+            return (scaleX != (int) scaleX) || (scaleY != (int) scaleY);
+        } else {
+            return false;
+        }
+    }
+
     /**
      * Returns the client property for the given key if it is set; otherwise
      * returns the {@L&F} property.
--- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Fri Dec 16 11:58:17 2016 -0800
@@ -140,7 +140,7 @@
         indices[storei] = baseIndex + cluster;
         glyphs[storei] = (unsigned int)(glyphInfo[i].codepoint | slot);
         positions[storei*2] = startX + x + glyphPos[i].x_offset * scale;
-        positions[(storei*2)+1] = startY + y + glyphPos[i].y_offset * scale;
+        positions[(storei*2)+1] = startY + y - glyphPos[i].y_offset * scale;
         x += glyphPos[i].x_advance * scale;
         y += glyphPos[i].y_advance * scale;
         storei++;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -123,15 +123,26 @@
             // Change in the size of the content window means, well, change of the size
             // Change in the location of the content window means change in insets
             boolean needHandleResize = !(newBounds.equals(getBounds()));
+            boolean needPaint = width <= 0 || height <= 0;
             reshape(newBounds);
             if (needHandleResize) {
                 insLog.fine("Sending RESIZED");
                 handleResize(newBounds);
             }
+            if (needPaint) {
+                postPaintEvent(target, 0, 0, newBounds.width, newBounds.height);
+            }
         } finally {
             XToolkit.awtUnlock();
         }
-        validateSurface();
+    }
+
+    @Override
+    public void handleExposeEvent(XEvent xev) {
+        if (width <= 0 || height <= 0) {
+            return;
+        }
+        super.handleExposeEvent(xev);
     }
 
     // NOTE: This method may be called by privileged threads.
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Fri Dec 16 11:58:17 2016 -0800
@@ -251,7 +251,8 @@
     m_bPauseDestroy = FALSE;
 
     m_MessagesProcessing = 0;
-    m_wheelRotationAmount = 0;
+    m_wheelRotationAmountX = 0;
+    m_wheelRotationAmountY = 0;
     if (!sm_PrimaryDynamicTableBuilt) {
         // do it once.
         AwtComponent::BuildPrimaryDynamicTable();
@@ -1208,6 +1209,7 @@
         WIN_MSG(WM_XBUTTONDOWN)
         WIN_MSG(WM_XBUTTONUP)
         WIN_MSG(WM_MOUSEWHEEL)
+        WIN_MSG(WM_MOUSEHWHEEL)
         WIN_MSG(WM_PARENTNOTIFY)
         WIN_MSG(WM_ENTERMENULOOP)
         WIN_MSG(WM_EXITMENULOOP)
@@ -1639,6 +1641,7 @@
       case WM_XBUTTONUP:
       case WM_MOUSEMOVE:
       case WM_MOUSEWHEEL:
+      case WM_MOUSEHWHEEL:
       case WM_AWT_MOUSEENTER:
       case WM_AWT_MOUSEEXIT:
           curPos = ::GetMessagePos();
@@ -1708,10 +1711,12 @@
           case WM_AWT_MOUSEEXIT:
               mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
               break;
-          case  WM_MOUSEWHEEL:
+          case WM_MOUSEWHEEL:
+          case WM_MOUSEHWHEEL:
               mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
                                 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
-                                GET_WHEEL_DELTA_WPARAM(wParam));
+                                GET_WHEEL_DELTA_WPARAM(wParam),
+                                switchMessage == WM_MOUSEHWHEEL);
               break;
           }
           break;
@@ -2078,13 +2083,15 @@
 
 MsgRouting AwtComponent::WmSetFocus(HWND hWndLostFocus)
 {
-    m_wheelRotationAmount = 0;
+    m_wheelRotationAmountX = 0;
+    m_wheelRotationAmountY = 0;
     return mrDoDefault;
 }
 
 MsgRouting AwtComponent::WmKillFocus(HWND hWndGotFocus)
 {
-    m_wheelRotationAmount = 0;
+    m_wheelRotationAmountX = 0;
+    m_wheelRotationAmountY = 0;
     return mrDoDefault;
 }
 
@@ -2461,7 +2468,7 @@
 }
 
 MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y,
-                                      int wheelRotation)
+                                      int wheelRotation, BOOL isHorizontal)
 {
     // convert coordinates to be Component-relative, not screen relative
     // for wheeling when outside the window, this works similar to
@@ -2475,42 +2482,54 @@
 
     // set some defaults
     jint scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
-    jint scrollLines = 3;
+    jint scrollUnits = 3;
 
     BOOL result;
-    UINT platformLines;
-
-    m_wheelRotationAmount += wheelRotation;
+    UINT platformUnits;
+    jint roundedWheelRotation;
+    jdouble preciseWheelRotation;
 
     // AWT interprets wheel rotation differently than win32, so we need to
     // decode wheel amount.
-    jint roundedWheelRotation = m_wheelRotationAmount / (-1 * WHEEL_DELTA);
-    jdouble preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA);
+    jint modifiers = GetJavaModifiers();
+    if (isHorizontal) {
+        modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
+        m_wheelRotationAmountX += wheelRotation;
+        roundedWheelRotation = m_wheelRotationAmountX / (WHEEL_DELTA);
+        preciseWheelRotation = (jdouble) wheelRotation / (WHEEL_DELTA);
+        result = ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
+                                        &platformUnits, 0);
+    } else {
+        m_wheelRotationAmountY += wheelRotation;
+        roundedWheelRotation = m_wheelRotationAmountY / (-1 * WHEEL_DELTA);
+        preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA);
+        result = ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
+                                        &platformUnits, 0);
+    }
 
     MSG msg;
-    result = ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
-                                    &platformLines, 0);
     InitMessage(&msg, lastMessage, MAKEWPARAM(flags, wheelRotation),
                 MAKELPARAM(x, y));
 
     if (result) {
-        if (platformLines == WHEEL_PAGESCROLL) {
+        if (platformUnits == WHEEL_PAGESCROLL) {
             scrollType = java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL;
-            scrollLines = 1;
+            scrollUnits = 1;
         }
         else {
             scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
-            scrollLines = platformLines;
+            scrollUnits = platformUnits;
         }
     }
 
     DTRACE_PRINTLN("calling SendMouseWheelEvent");
 
     SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, ::JVM_CurrentTimeMillis(NULL, 0),
-                        eventPt.x, eventPt.y, GetJavaModifiers(), 0, 0, scrollType,
-                        scrollLines, roundedWheelRotation, preciseWheelRotation, &msg);
-
-    m_wheelRotationAmount %= WHEEL_DELTA;
+                        eventPt.x, eventPt.y, modifiers, 0, 0, scrollType,
+                        scrollUnits, roundedWheelRotation, preciseWheelRotation, &msg);
+
+    m_wheelRotationAmountX %= WHEEL_DELTA;
+    m_wheelRotationAmountY %= WHEEL_DELTA;
     // this message could be propagated up to the parent chain
     // by the mouse message post processors
     return mrConsume;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Fri Dec 16 11:58:17 2016 -0800
@@ -522,7 +522,7 @@
     virtual MsgRouting WmMouseMove(UINT flags, int x, int y);
     virtual MsgRouting WmMouseExit(UINT flags, int x, int y);
     virtual MsgRouting WmMouseWheel(UINT flags, int x, int y,
-                                    int wheelRotation);
+                                    int wheelRotation, BOOL isHorizontal);
     virtual MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button);
     virtual MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button);
     virtual MsgRouting WmWindowPosChanging(LPARAM windowPos);
@@ -824,7 +824,8 @@
     int windowMoveLockPosCY;
 
     // 6524352: support finer-resolution
-    int m_wheelRotationAmount;
+    int m_wheelRotationAmountX;
+    int m_wheelRotationAmountY;
 
     BOOL deadKeyActive;
 
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Dialog.cpp	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Dialog.cpp	Fri Dec 16 11:58:17 2016 -0800
@@ -240,6 +240,7 @@
             (wParam == WM_RBUTTONDOWN) ||
             (wParam == WM_MOUSEACTIVATE) ||
             (wParam == WM_MOUSEWHEEL) ||
+            (wParam == WM_MOUSEHWHEEL) ||
             (wParam == WM_NCLBUTTONDOWN) ||
             (wParam == WM_NCMBUTTONDOWN) ||
             (wParam == WM_NCRBUTTONDOWN))
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp	Fri Dec 16 11:58:17 2016 -0800
@@ -484,7 +484,10 @@
             if (fgProcessID != ::GetCurrentProcessId()) {
                 AwtWindow* window = (AwtWindow*)GetComponent(GetHWnd());
 
-                if (window != NULL && window->IsFocusableWindow() && window->IsAutoRequestFocus() &&
+                if (window != NULL &&
+                    window->IsFocusableWindow() &&
+                    window->IsAutoRequestFocus() &&
+                    !::IsWindowVisible(GetHWnd()) && // the window is really showing
                     !::IsWindow(GetModalBlocker(GetHWnd())))
                 {
                     // When the Java process is not allowed to set the foreground window
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Fri Dec 16 11:58:17 2016 -0800
@@ -1590,7 +1590,7 @@
      * the mouse, not the Component with the input focus.
      */
 
-    if (msg.message == WM_MOUSEWHEEL) {
+    if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) {
             //i.e. mouse is over client area for this window
             DWORD hWndForWheelProcess;
             DWORD hWndForWheelThread = ::GetWindowThreadProcessId(hWndForWheel, &hWndForWheelProcess);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awtmsg.h	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awtmsg.h	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,10 @@
 #define WM_MOUSEWHEEL                   0x020A
 #endif //WM_MOUSEWHEEL
 
+#ifndef WM_MOUSEHWHEEL
+#define WM_MOUSEHWHEEL                  0x020E
+#endif //WM_MOUSEHWHEEL
+
 #ifndef WHEEL_DELTA
 #define WHEEL_DELTA                     120
 #endif //WHEEL_DELTA
@@ -54,12 +58,16 @@
 #endif //WHEEL_PAGESCROLL
 
 #ifndef SPI_GETWHEELSCROLLLINES
-#define SPI_GETWHEELSCROLLLINES         104
+#define SPI_GETWHEELSCROLLLINES         0x0068
 #endif //SPI_GETWHEELSCROLLLINES
 
+#ifndef SPI_GETWHEELSCROLLCHARS
+#define SPI_GETWHEELSCROLLCHARS         0x006C
+#endif //SPI_GETWHEELSCROLLCHARS
+
 #ifndef SM_MOUSEWHEELPRESENT
 #define SM_MOUSEWHEELPRESENT            75
-#endif //SPI_GETWHEELSCROLLLINES
+#endif //SM_MOUSEWHEELPRESENT
 
 #ifndef COLOR_HOTLIGHT
 #define COLOR_HOTLIGHT                  26
--- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,8 @@
 
 package com.sun.java.accessibility.util;
 
-import java.util.*;
 import java.awt.*;
 import java.awt.event.*;
-import javax.accessibility.*;
 import javax.swing.*;
 import javax.swing.event.*;
 import sun.awt.AWTPermissions;
@@ -55,7 +53,7 @@
      * @deprecated This field is unused; to get the component with focus use the
      * getComponentWithFocus method.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected Component componentWithFocus = null;
 
     static private Component componentWithFocus_private = null;
@@ -69,7 +67,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected ComponentListener     componentListener     = null;
 
     static private ComponentListener componentListener_private = null;
@@ -82,7 +80,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected ContainerListener     containerListener     = null;
 
     static private ContainerListener containerListener_private = null;
@@ -95,7 +93,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected FocusListener         focusListener         = null;
 
     static private FocusListener focusListener_private = null;
@@ -108,7 +106,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected KeyListener           keyListener           = null;
 
     static private KeyListener keyListener_private = null;
@@ -121,7 +119,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected MouseListener         mouseListener         = null;
 
     static private MouseListener mouseListener_private = null;
@@ -134,7 +132,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected MouseMotionListener   mouseMotionListener   = null;
 
     static private MouseMotionListener mouseMotionListener_private = null;
@@ -147,7 +145,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected WindowListener        windowListener        = null;
 
     static private WindowListener windowListener_private = null;
@@ -162,7 +160,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected ActionListener        actionListener        = null;
 
     static private ActionListener actionListener_private = null;
@@ -175,7 +173,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected AdjustmentListener    adjustmentListener    = null;
 
     static private AdjustmentListener adjustmentListener_private = null;
@@ -188,7 +186,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected ItemListener          itemListener          = null;
 
     static private ItemListener itemListener_private = null;
@@ -201,7 +199,7 @@
      *
      * @deprecated This field is unused.
      */
-    @Deprecated
+    @Deprecated(since="8", forRemoval=true)
     static protected TextListener          textListener          = null;
 
     static private TextListener textListener_private = null;
@@ -212,13 +210,8 @@
      * This listener calls the other registered listeners when an event
      * occurs.  By doing things this way, the actual number of listeners
      * installed on a component instance is drastically reduced.
-     *
-     * @deprecated This field is unused.
      */
-    @Deprecated
-    static protected AWTEventsListener awtListener = new AWTEventsListener();
-
-    static private final AWTEventsListener awtListener_private = new AWTEventsListener();
+    static private final AWTEventsListener awtListener = new AWTEventsListener();
 
     /**
      * Returns the component that currently has keyboard focus.  The return
@@ -253,7 +246,7 @@
     static public void addComponentListener(ComponentListener l) {
         if (componentListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.COMPONENT);
+            awtListener.installListeners(EventID.COMPONENT);
         }
         componentListener_private = AWTEventMulticaster.add(componentListener_private, l);
     }
@@ -268,7 +261,7 @@
     static public void removeComponentListener(ComponentListener l) {
         componentListener_private = AWTEventMulticaster.remove(componentListener_private, l);
         if (componentListener_private == null) {
-            awtListener_private.removeListeners(EventID.COMPONENT);
+            awtListener.removeListeners(EventID.COMPONENT);
         }
     }
 
@@ -335,7 +328,7 @@
     static public void addKeyListener(KeyListener l) {
         if (keyListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.KEY);
+            awtListener.installListeners(EventID.KEY);
         }
         keyListener_private = AWTEventMulticaster.add(keyListener_private, l);
     }
@@ -350,7 +343,7 @@
     static public void removeKeyListener(KeyListener l) {
         keyListener_private = AWTEventMulticaster.remove(keyListener_private, l);
         if (keyListener_private == null)  {
-            awtListener_private.removeListeners(EventID.KEY);
+            awtListener.removeListeners(EventID.KEY);
         }
     }
 
@@ -367,7 +360,7 @@
     static public void addMouseListener(MouseListener l) {
         if (mouseListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.MOUSE);
+            awtListener.installListeners(EventID.MOUSE);
         }
         mouseListener_private = AWTEventMulticaster.add(mouseListener_private, l);
     }
@@ -382,7 +375,7 @@
     static public void removeMouseListener(MouseListener l) {
         mouseListener_private = AWTEventMulticaster.remove(mouseListener_private, l);
         if (mouseListener_private == null) {
-            awtListener_private.removeListeners(EventID.MOUSE);
+            awtListener.removeListeners(EventID.MOUSE);
         }
     }
 
@@ -399,7 +392,7 @@
     static public void addMouseMotionListener(MouseMotionListener l) {
         if (mouseMotionListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.MOTION);
+            awtListener.installListeners(EventID.MOTION);
         }
         mouseMotionListener_private = AWTEventMulticaster.add(mouseMotionListener_private, l);
     }
@@ -414,7 +407,7 @@
     static public void removeMouseMotionListener(MouseMotionListener l) {
         mouseMotionListener_private = AWTEventMulticaster.remove(mouseMotionListener_private, l);
         if (mouseMotionListener_private == null) {
-            awtListener_private.removeListeners(EventID.MOTION);
+            awtListener.removeListeners(EventID.MOTION);
         }
     }
 
@@ -431,7 +424,7 @@
     static public void addWindowListener(WindowListener l) {
         if (windowListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.WINDOW);
+            awtListener.installListeners(EventID.WINDOW);
         }
         windowListener_private = AWTEventMulticaster.add(windowListener_private, l);
     }
@@ -446,7 +439,7 @@
     static public void removeWindowListener(WindowListener l) {
         windowListener_private = AWTEventMulticaster.remove(windowListener_private, l);
         if (windowListener_private == null) {
-            awtListener_private.removeListeners(EventID.WINDOW);
+            awtListener.removeListeners(EventID.WINDOW);
         }
     }
 
@@ -463,7 +456,7 @@
     static public void addActionListener(ActionListener l) {
         if (actionListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.ACTION);
+            awtListener.installListeners(EventID.ACTION);
         }
         actionListener_private = AWTEventMulticaster.add(actionListener_private, l);
     }
@@ -478,7 +471,7 @@
     static public void removeActionListener(ActionListener l) {
         actionListener_private = AWTEventMulticaster.remove(actionListener_private, l);
         if (actionListener_private == null) {
-            awtListener_private.removeListeners(EventID.ACTION);
+            awtListener.removeListeners(EventID.ACTION);
         }
     }
 
@@ -496,7 +489,7 @@
     static public void addAdjustmentListener(AdjustmentListener l) {
         if (adjustmentListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.ADJUSTMENT);
+            awtListener.installListeners(EventID.ADJUSTMENT);
         }
         adjustmentListener_private = AWTEventMulticaster.add(adjustmentListener_private, l);
     }
@@ -511,7 +504,7 @@
     static public void removeAdjustmentListener(AdjustmentListener l) {
         adjustmentListener_private = AWTEventMulticaster.remove(adjustmentListener_private, l);
         if (adjustmentListener_private == null) {
-            awtListener_private.removeListeners(EventID.ADJUSTMENT);
+            awtListener.removeListeners(EventID.ADJUSTMENT);
         }
     }
 
@@ -528,7 +521,7 @@
     static public void addItemListener(ItemListener l) {
         if (itemListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.ITEM);
+            awtListener.installListeners(EventID.ITEM);
         }
         itemListener_private = AWTEventMulticaster.add(itemListener_private, l);
     }
@@ -543,7 +536,7 @@
     static public void removeItemListener(ItemListener l) {
         itemListener_private = AWTEventMulticaster.remove(itemListener_private, l);
         if (itemListener_private == null) {
-            awtListener_private.removeListeners(EventID.ITEM);
+            awtListener.removeListeners(EventID.ITEM);
         }
     }
 
@@ -560,7 +553,7 @@
     static public void addTextListener(TextListener l) {
         if (textListener_private == null) {
             checkInstallPermission();
-            awtListener_private.installListeners(EventID.TEXT);
+            awtListener.installListeners(EventID.TEXT);
         }
         textListener_private = AWTEventMulticaster.add(textListener_private, l);
     }
@@ -575,7 +568,7 @@
     static public void removeTextListener(TextListener l) {
         textListener_private = AWTEventMulticaster.remove(textListener_private, l);
         if (textListener_private == null) {
-            awtListener_private.removeListeners(EventID.TEXT);
+            awtListener.removeListeners(EventID.TEXT);
         }
     }
 
--- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,7 @@
      * occurs.  By doing things this way, the actual number of listeners
      * installed on a component instance is drastically reduced.
      */
-    static protected final AccessibilityEventListener accessibilityListener =
+    static private final AccessibilityEventListener accessibilityListener =
         new AccessibilityEventListener();
 
     /**
--- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
      * occurs.  By doing things this way, the actual number of listeners
      * installed on a component instance is drastically reduced.
      */
-    static protected final SwingEventListener swingListener = new SwingEventListener();
+    static private final SwingEventListener swingListener = new SwingEventListener();
 
     /**
      * Adds the specified listener to receive all {@link EventID#ANCESTOR ANCESTOR}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,81 @@
+/*
+ * 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 8169589
+ * @summary Activating a dialog puts to back another dialog owned by the same frame
+ * @author Dmitry Markov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main DialogAboveFrameTest
+ */
+
+import java.awt.Color;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class DialogAboveFrameTest {
+    public static void main(String[] args) {
+        Robot robot = Util.createRobot();
+
+        Frame frame = new Frame("Frame");
+        frame.setBackground(Color.BLUE);
+        frame.setBounds(200, 50, 300, 300);
+        frame.setVisible(true);
+
+        Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
+        dialog1.setBackground(Color.RED);
+        dialog1.setBounds(100, 100, 200, 200);
+        dialog1.setVisible(true);
+
+        Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
+        dialog2.setBackground(Color.GREEN);
+        dialog2.setBounds(400, 100, 200, 200);
+        dialog2.setVisible(true);
+
+        Util.waitForIdle(robot);
+
+        Util.clickOnComp(dialog2, robot);
+        Util.waitForIdle(robot);
+
+        Point point = dialog1.getLocationOnScreen();
+        int x = point.x + (int)(dialog1.getWidth() * 0.9);
+        int y = point.y + (int)(dialog1.getHeight() * 0.9);
+
+        try {
+            if (!robot.getPixelColor(x, y).equals(dialog1.getBackground())) {
+                throw new RuntimeException("Test FAILED: Dialog is behind the frame");
+            }
+        } finally {
+            frame.dispose();
+            dialog1.dispose();
+            dialog2.dispose();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Menu/WrongParentAfterRemoveMenu/WrongParentAfterRemoveMenu.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,126 @@
+/*
+ * 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.awt.Frame;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.PopupMenu;
+import java.awt.Window;
+
+/**
+ * @test
+ * @bug 8165769
+ * @key headful
+ */
+public final class WrongParentAfterRemoveMenu {
+
+    public static void main(final String[] args) {
+        testMenuBar();
+        testComponent();
+        testFrame();
+    }
+
+    private static void testFrame() {
+        // peer exists
+        Frame frame = new Frame();
+        try {
+            frame.pack();
+            PopupMenu popupMenu = new PopupMenu();
+            frame.add(popupMenu);
+            checkParent(popupMenu, frame);
+            frame.remove(popupMenu);
+            checkParent(popupMenu, null);
+        } finally {
+            frame.dispose();
+        }
+        // peer is null
+        frame = new Frame();
+        PopupMenu popupMenu = new PopupMenu();
+        frame.add(popupMenu);
+        checkParent(popupMenu, frame);
+        frame.remove(popupMenu);
+        checkParent(popupMenu, null);
+    }
+
+    private static void testComponent() {
+        // peer exists
+        Window w = new Window(null);
+        try {
+            w.pack();
+            PopupMenu popupMenu = new PopupMenu();
+            w.add(popupMenu);
+            checkParent(popupMenu, w);
+            w.remove(popupMenu);
+            checkParent(popupMenu, null);
+        } finally {
+            w.dispose();
+        }
+        // peer is null
+        w = new Window(null);
+        PopupMenu popupMenu = new PopupMenu();
+        w.add(popupMenu);
+        checkParent(popupMenu, w);
+        w.remove(popupMenu);
+        checkParent(popupMenu, null);
+    }
+
+    private static void testMenuBar() {
+        // peer exists
+        MenuBar mb = new MenuBar();
+        try {
+            mb.addNotify();
+            Menu m1 = new Menu();
+            Menu m2 = new Menu();
+            m1.add(m2);
+            mb.add(m1);
+            checkParent(m1, mb);
+            checkParent(m2, m1);
+            m1.remove(m2);
+            checkParent(m2, null);
+            mb.remove(m1);
+            checkParent(m1, null);
+        } finally {
+            mb.removeNotify();
+        }
+        // peer is null
+        mb = new MenuBar();
+        Menu m1 = new Menu();
+        Menu m2 = new Menu();
+        m1.add(m2);
+        mb.add(m1);
+        checkParent(m1, mb);
+        checkParent(m2, m1);
+        m1.remove(m2);
+        checkParent(m2, null);
+        mb.remove(m1);
+        checkParent(m1, null);
+    }
+
+    private static void checkParent(final Menu menu, final Object parent) {
+        if (menu.getParent() != parent) {
+            System.err.println("Expected: " + parent);
+            System.err.println("Actual: " + menu.getParent());
+            throw new RuntimeException("Wrong parent");
+        }
+    }
+}
--- a/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -44,9 +44,11 @@
 import javax.imageio.ImageIO;
 
 /**
- * @test @bug 8145174 8151787
+ * @test
+ * @bug 8145174 8151787 8168657
  * @summary HiDPI splash screen support on Linux
  * @modules java.desktop/sun.java2d
+ * @requires (os.family == "linux")
  * @run main UnixMultiResolutionSplashTest
  */
 public class UnixMultiResolutionSplashTest {
--- a/jdk/test/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java	Fri Dec 16 11:58:17 2016 -0800
@@ -25,6 +25,7 @@
   test
   @bug 6242241
   @summary Tests basic DnD functionality in an applet
+  @requires (os.family == "windows")
   @author Your Name: Alexey Utkin area=dnd
   @run applet/manual=yesno DnDFileGroupDescriptor.html
 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2016 JetBrains s.r.o.
+ * 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 8169202
+ * @summary verify font fallback for surrogate pairs on macOS
+ * @requires os.family == "mac"
+ */
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.font.GlyphVector;
+import java.awt.image.BufferedImage;
+import java.util.function.Consumer;
+
+public class SurrogatesFallbackTest {
+    private static final int CHARACTER = 0x1d400; // MATHEMATICAL BOLD CAPITAL A
+    private static final Font FONT = new Font("Menlo", // expected to fallback to STIXGeneral for the character above
+                                              Font.PLAIN,
+                                              12);
+    private static final int IMAGE_WIDTH = 20;
+    private static final int IMAGE_HEIGHT = 20;
+    private static final int GLYPH_X = 5;
+    private static final int GLYPH_Y = 15;
+
+    public static void main(String[] args) {
+        BufferedImage noGlyph = createImage(g -> {});
+        BufferedImage missingGlyph = createImage(g -> {
+            GlyphVector gv = FONT.createGlyphVector(g.getFontRenderContext(), new int[]{FONT.getMissingGlyphCode()});
+            g.drawGlyphVector(gv, GLYPH_X, GLYPH_Y);
+        });
+        BufferedImage surrogateCharGlyph = createImage(g -> {
+            g.setFont(FONT);
+            g.drawString(new String(Character.toChars(CHARACTER)), GLYPH_X, GLYPH_Y);
+        });
+
+        if (imagesAreEqual(surrogateCharGlyph, noGlyph)) {
+            throw new RuntimeException("Character was not rendered");
+        }
+        if (imagesAreEqual(surrogateCharGlyph, missingGlyph)) {
+            throw new RuntimeException("Character is rendered as missing");
+        }
+    }
+
+    private static BufferedImage createImage(Consumer<Graphics2D> drawing) {
+        BufferedImage image = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = image.createGraphics();
+        g.setColor(Color.white);
+        g.fillRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
+        g.setColor(Color.black);
+        drawing.accept(g);
+        g.dispose();
+        return image;
+    }
+
+    private static boolean imagesAreEqual(BufferedImage i1, BufferedImage i2) {
+        if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) return false;
+        for (int i = 0; i < i1.getWidth(); i++) {
+            for (int j = 0; j < i1.getHeight(); j++) {
+                if (i1.getRGB(i, j) != i2.getRGB(i, j)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,95 @@
+/*
+ * 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
+ */
+
+/* @test
+ * @summary verify Arab Diacritic Positioning
+ * @bug 8168759
+ */
+
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.util.Locale;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+public class ArabicDiacriticTest {
+
+    static final String SAMPLE =
+     "\u0627\u0644\u0639\u064e\u0631\u064e\u0628\u0650\u064a\u064e\u0651\u0629";
+
+    static final String STR1 = "\u0644\u0639\u064e\u0629";
+    static final String STR2 = "\u0644\u0639\u0629";
+
+    static JFrame frame;
+    static final String FONT = "DejaVu Sans";
+
+    public static void main(String args[]) throws Exception {
+        showText(); // for a human
+        measureText(); // for the test harness
+        Thread.sleep(5000);
+        frame.dispose();
+    }
+
+    static void showText() {
+        SwingUtilities.invokeLater(() -> {
+            frame = new JFrame();
+            JLabel label = new JLabel(SAMPLE);
+            Font font = new Font(FONT, Font.PLAIN, 36);
+            label.setFont(font);
+            frame.setLayout(new GridLayout(3,1));
+            frame.add(label);
+            label = new JLabel(STR1);
+            label.setFont(font);
+            frame.add(label);
+            label = new JLabel(STR2);
+            label.setFont(font);
+            frame.add(label);
+            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+            frame.pack();
+            frame.setLocationRelativeTo(null);
+            frame.setVisible(true);
+        });
+    }
+
+    static void measureText() {
+        Font font = new Font(FONT, Font.PLAIN, 36);
+        if (!font.getFamily(Locale.ENGLISH).equals(FONT)) {
+            return;
+        }
+        FontRenderContext frc = new FontRenderContext(null, false, false);
+        TextLayout tl1 = new TextLayout(STR1, font, frc);
+        TextLayout tl2 = new TextLayout(STR2, font, frc);
+        Rectangle r1 = tl1.getPixelBounds(frc, 0f, 0f);
+        Rectangle r2 = tl2.getPixelBounds(frc, 0f, 0f);
+        if (r1.height > r2.height) {
+            System.out.println(font);
+            System.out.println(r1);
+            System.out.println(r2);
+            throw new RuntimeException("BAD BOUNDS");
+        }
+    }
+}
--- a/jdk/test/javax/imageio/plugins/tiff/MultiPageImageTIFFFieldTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/MultiPageImageTIFFFieldTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -223,7 +223,7 @@
         ImageReader reader = getTIFFReader();
 
         ImageInputStream s = ImageIO.createImageInputStream(new File(FILENAME));
-        reader.setInput(s, false, true);
+        reader.setInput(s, false, false);
 
         int ni = reader.getNumImages(true);
         check(ni == 2, "invalid number of images");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/ReadUnknownTagsTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,269 @@
+/*
+ * 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     8154058
+ * @author  a.stepanov
+ * @summary Some checks for ignoring metadata
+ * @run     main ReadUnknownTagsTest
+ */
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import javax.imageio.*;
+import javax.imageio.metadata.*;
+
+import javax.imageio.stream.*;
+import javax.imageio.plugins.tiff.*;
+
+
+public class ReadUnknownTagsTest {
+
+    private final static int SZ = 50;
+    private final static Color C = Color.RED;
+
+    private final static int DESCRIPTION_TAG =
+        BaselineTIFFTagSet.TAG_IMAGE_DESCRIPTION;
+    private final static String DESCRIPTION = "A Test Image";
+
+    private final static int FAX_TAG = FaxTIFFTagSet.TAG_CLEAN_FAX_DATA;
+    private final static short FAX_DATA =
+        FaxTIFFTagSet.CLEAN_FAX_DATA_ERRORS_UNCORRECTED;
+
+    private final boolean ignoreMetadata;
+    private final boolean readUnknownTags;
+
+    public ReadUnknownTagsTest(boolean ignoreMetadata,
+        boolean readUnknownTags) {
+        this.ignoreMetadata = ignoreMetadata;
+        this.readUnknownTags = readUnknownTags;
+    }
+
+    private ImageWriter getTIFFWriter() {
+
+        java.util.Iterator<ImageWriter> writers =
+            ImageIO.getImageWritersByFormatName("TIFF");
+        if (!writers.hasNext()) {
+            throw new RuntimeException("No writers available for TIFF format");
+        }
+        return writers.next();
+    }
+
+    private ImageReader getTIFFReader() {
+
+        java.util.Iterator<ImageReader> readers =
+            ImageIO.getImageReadersByFormatName("TIFF");
+        if (!readers.hasNext()) {
+            throw new RuntimeException("No readers available for TIFF format");
+        }
+        return readers.next();
+    }
+
+
+    private void writeImage() throws Exception {
+
+        String fn = "test-" + ignoreMetadata + ".tiff";
+        OutputStream s = new BufferedOutputStream(new FileOutputStream(fn));
+        try (ImageOutputStream ios = ImageIO.createImageOutputStream(s)) {
+
+            ImageWriter writer = getTIFFWriter();
+            writer.setOutput(ios);
+
+            BufferedImage img = new BufferedImage(SZ, SZ,
+                BufferedImage.TYPE_INT_RGB);
+            Graphics g = img.getGraphics();
+            g.setColor(C);
+            g.fillRect(0, 0, SZ, SZ);
+            g.dispose();
+
+            ImageWriteParam param = writer.getDefaultWriteParam();
+
+            IIOMetadata md = writer.getDefaultImageMetadata(
+                    new ImageTypeSpecifier(img), param);
+
+            TIFFDirectory dir = TIFFDirectory.createFromMetadata(md);
+
+            TIFFTag descTag =
+                BaselineTIFFTagSet.getInstance().getTag(DESCRIPTION_TAG);
+            dir.addTIFFField(new TIFFField(descTag, TIFFTag.TIFF_ASCII, 1,
+                new String[] {DESCRIPTION}));
+
+            TIFFTag faxTag = FaxTIFFTagSet.getInstance().getTag(FAX_TAG);
+            dir.addTIFFField(new TIFFField(faxTag, FAX_DATA));
+
+            writer.write(new IIOImage(img, null, dir.getAsMetadata()));
+
+            ios.flush();
+            writer.dispose();
+        }
+        s.close();
+    }
+
+    private void readAndCheckImage() throws Exception {
+
+        ImageReader reader = getTIFFReader();
+
+        String fn = "test-" + ignoreMetadata + ".tiff";
+        ImageInputStream s = ImageIO.createImageInputStream(new File(fn));
+
+        reader.setInput(s, false, ignoreMetadata);
+
+        int ni = reader.getNumImages(true);
+        check(ni == 1, "invalid number of images");
+
+
+        TIFFImageReadParam param = new TIFFImageReadParam();
+        // fax data are allowed by default
+        param.removeAllowedTagSet(FaxTIFFTagSet.getInstance());
+
+        // readUnknownTags setting
+        if (param.getReadUnknownTags()) {
+            throw new RuntimeException("Default readUnknownTags is not false");
+        }
+        param.setReadUnknownTags(readUnknownTags);
+        if (param.getReadUnknownTags() != readUnknownTags) {
+            throw new RuntimeException("Incorrect readUnknownTags setting "
+                + "\"" + readUnknownTags + "\"");
+        }
+
+        // read images and metadata
+        IIOImage i = reader.readAll(0, param);
+        BufferedImage bi = (BufferedImage) i.getRenderedImage();
+
+        check(bi.getWidth()  == SZ, "invalid width");
+        check(bi.getHeight() == SZ, "invalid height");
+        Color c = new Color(bi.getRGB(SZ / 2, SZ / 2));
+        check(c.equals(C), "invalid color");
+
+        IIOMetadata metadata = i.getMetadata();
+
+        //
+        // Verify presence of image metadata
+        //
+        if (metadata == null) {
+            throw new RuntimeException("No image metadata retrieved");
+        }
+
+        TIFFDirectory dir = TIFFDirectory.createFromMetadata(metadata);
+
+        //
+        // Verify presence of essential ImageWidth field regardless of
+        // settings of ignoreMetadata and readUnknownTags
+        //
+        int failures = 0;
+        if (!dir.containsTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH)) {
+            System.err.println("Metadata is missing essential ImageWidth tag");
+            failures++;
+        } else {
+            TIFFField widthField =
+                dir.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
+            System.out.printf("ImageWidth: %d%n", widthField.getAsLong(0));
+        }
+
+        //
+        // Verify presence of non-essential baseline ImageDescription field
+        // if and only if ignoreMetadata == false
+        //
+        boolean hasDescription = dir.containsTIFFField(DESCRIPTION_TAG);
+        System.out.println("ImageDescription (" + !ignoreMetadata + "): "
+            + hasDescription);
+        if (ignoreMetadata && hasDescription) {
+            System.err.println
+                ("Description metadata present despite ignoreMetadata");
+            failures++;
+        } else if (!ignoreMetadata && !hasDescription) {
+            System.err.println
+                ("Description metadata absent despite !ignoreMetadata");
+            failures++;
+        }
+
+        //
+        // Verify presence of CleanFaxData field if and only if
+        // ignoreMetadata == false and readUnknownTags == true
+        //
+        boolean shouldHaveFaxField = !ignoreMetadata && readUnknownTags;
+        boolean hasFaxField = dir.containsTIFFField(FAX_TAG);
+        System.out.println("CleanFaxData (" + shouldHaveFaxField + "): "
+            + hasFaxField);
+
+        if (ignoreMetadata) {
+            if (hasFaxField) {
+                System.err.println
+                    ("Fax metadata present despite ignoreMetadata");
+                failures++;
+            }
+        } else { // !ignoreMetadata
+            if (!readUnknownTags && hasFaxField) {
+                System.err.println
+                    ("Fax metadata present despite !readUnknownTags");
+                failures++;
+            } else if (readUnknownTags && !hasFaxField) {
+                System.err.println
+                    ("Fax metadata absent despite readUnknownTags");
+                failures++;
+            }
+        }
+
+        if (failures > 0) {
+            throw new RuntimeException("Test failed for ignoreMetadata "
+                + ignoreMetadata + " and readUnknownTags " + readUnknownTags);
+        }
+    }
+
+    public void run() {
+        try {
+            writeImage();
+            readAndCheckImage();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void check(boolean ok, String msg) {
+        if (!ok) { throw new RuntimeException(msg); }
+    }
+
+    public static void main(String[] args) {
+        int failures = 0;
+
+        System.out.println();
+        for (boolean ignoreMetadata : new boolean[] {false, true}) {
+            for (boolean readUnknownTags : new boolean[] {false, true}) {
+                try {
+                    System.out.printf
+                        ("ignoreMetadata: %s, readUnknownTags: %s%n",
+                        ignoreMetadata, readUnknownTags);
+                    (new ReadUnknownTagsTest(ignoreMetadata,
+                        readUnknownTags)).run();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    failures++;
+                } finally {
+                    System.out.println();
+                }
+            }
+        }
+    }
+}
--- a/jdk/test/javax/imageio/plugins/tiff/TIFFDirectoryTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFDirectoryTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -154,7 +154,7 @@
             "must return null TIFFField");
 
         long offset = 4L;
-        long a[] = {Long.MIN_VALUE, 0, Long.MAX_VALUE};
+        long a[] = {0, Integer.MAX_VALUE, (1 << 32) - 1};
         int v = 100500;
         TIFFField
                 f1 = new TIFFField(tag1, type, offset, d),
--- a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug     8152183 8149562
+ * @bug     8152183 8149562 8169725 8169728
  * @author  a.stepanov
  * @summary Some checks for TIFFField methods
  * @run     main TIFFFieldTest
@@ -65,7 +65,26 @@
         ok = false;
         try { new TIFFField(tag, -1); }
         catch (IllegalArgumentException e) { ok = true; }
-        check(ok, CONSTRUCT + "invalid count");
+        check(ok, CONSTRUCT + "negative value");
+
+        ok = false;
+        try { new TIFFField(tag, 1L << 32); }
+        catch (IllegalArgumentException e) { ok = true; }
+        check(ok, CONSTRUCT + "value > 0xffffffff");
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_SHORT);
+            new TIFFField(t, 0x10000);
+        } catch (IllegalArgumentException e) { ok = true; }
+        check(ok, CONSTRUCT + "value 0x10000 incompatible with TIFF_SHORT");
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_LONG);
+            new TIFFField(t, 0xffff);
+        } catch (IllegalArgumentException e) { ok = true; }
+        check(ok, CONSTRUCT + "value 0xffff incompatible with TIFF_LONG");
 
         // check value type recognition
         int v = 1 << 16;
@@ -152,6 +171,94 @@
         check((f.getDirectory() == null) && !f.hasDirectory(),
             "must not have directory");
 
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_RATIONAL);
+            long[][] tiffRationals = new long[6][3];
+            new TIFFField(t, TIFFTag.TIFF_RATIONAL, tiffRationals.length,
+                tiffRationals);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_SRATIONAL);
+            int[][] tiffSRationals = new int[6][3];
+            new TIFFField(t, TIFFTag.TIFF_SRATIONAL, tiffSRationals.length,
+                tiffSRationals);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_LONG);
+            long[] tiffLongs = new long[] {0, -7, 10};
+            new TIFFField(t, TIFFTag.TIFF_LONG, tiffLongs.length,
+                tiffLongs);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_LONG);
+            long[] tiffLongs = new long[] {0, 7, 0x100000000L};
+            new TIFFField(t, TIFFTag.TIFF_LONG, tiffLongs.length,
+                tiffLongs);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_IFD_POINTER);
+            long[] tiffLongs = new long[] {-7};
+            new TIFFField(t, TIFFTag.TIFF_IFD_POINTER, tiffLongs.length,
+                tiffLongs);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_IFD_POINTER);
+            long[] tiffLongs = new long[] {0x100000000L};
+            new TIFFField(t, TIFFTag.TIFF_IFD_POINTER, tiffLongs.length,
+                tiffLongs);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_RATIONAL);
+            long[][] tiffRationals = new long[][] {
+                {10, 2},
+                {1, -3},
+                {4,  7}
+            };
+            new TIFFField(t, TIFFTag.TIFF_RATIONAL, tiffRationals.length,
+                tiffRationals);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
+        ok = false;
+        try {
+            TIFFTag t = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_RATIONAL);
+            long[][] tiffRationals = new long[][] {
+                {10, 2},
+                {0x100000000L, 3},
+                {4,  7}
+            };
+            new TIFFField(t, TIFFTag.TIFF_RATIONAL, tiffRationals.length,
+                tiffRationals);
+        } catch (IllegalArgumentException e) {
+            ok = true;
+        }
+
         // constructor: TIFFField(tag, type, offset, dir)
         List<TIFFTag> tags = new ArrayList<>();
         tags.add(tag);
--- a/jdk/test/javax/imageio/plugins/tiff/TIFFImageReadParamTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFImageReadParamTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -159,7 +159,7 @@
         ImageReader reader = getTIFFReader();
 
         ImageInputStream s = ImageIO.createImageInputStream(new File(FILENAME));
-        reader.setInput(s, false, true);
+        reader.setInput(s, false, false);
 
         int ni = reader.getNumImages(true);
         check(ni == 1, "invalid number of images: " + ni);
--- a/jdk/test/javax/print/PrintServiceLookup/GetPrintServices.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/print/PrintServiceLookup/GetPrintServices.java	Fri Dec 16 11:58:17 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,30 +29,37 @@
 
 /*
  * @test
- * @bug 8013810
- * @summary Test that print service returned without filter are of the same class as with name filter
+ * @bug 8013810 8025439
+ * @summary Test that print service returned without filter are of the same class
+ *          as with name filter
  */
 public class GetPrintServices {
 
-  public static void main(String[] args) throws Exception {
-    for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
-      String serviceName = service.getName();
-      PrintService serviceByName = lookupByName(serviceName);
-      if (!service.equals(serviceByName)) {
-        throw new RuntimeException("NOK " + serviceName
+    public static void main(String[] args) throws Exception {
+        for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
+            String serviceName = service.getName();
+            PrinterName name = service.getAttribute(PrinterName.class);
+            String printerName = name.getValue();
+
+            PrintService serviceByName = lookupByName(printerName);
+            System.out.println("service " + service);
+            System.out.println("serviceByName " + serviceByName);
+            if (!service.equals(serviceByName)) {
+                throw new RuntimeException("NOK " + serviceName
                                    + " expected: " + service.getClass().getName()
                                    + " got: " + serviceByName.getClass().getName());
-      }
+            }
+        }
+        System.out.println("Test PASSED");
     }
-    System.out.println("Test PASSED");
-  }
 
-  private static PrintService lookupByName(String name) {
-    AttributeSet attributes = new HashAttributeSet();
-    attributes.add(new PrinterName(name, null));
-    for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
-      return service;
+    private static PrintService lookupByName(String name) {
+        AttributeSet attributes = new HashAttributeSet();
+        attributes.add(new PrinterName(name, null));
+        for (PrintService service :
+             PrintServiceLookup.lookupPrintServices(null, attributes)) {
+            return service;
+        }
+        return null;
     }
-    return null;
-  }
 }
--- a/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -26,7 +26,7 @@
   * @summary Test to check JComboBox does not lose its ability to invoke
   * registerd ActionListener in case of exception in ActionListener
   * @run main ActionListenerExceptionTest
-  */
+ */
 
 import java.awt.AWTEvent;
 import java.awt.AWTException;
@@ -44,6 +44,7 @@
 import javax.swing.JComponent;
 import javax.swing.JFrame;
 import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
 
 public class ActionListenerExceptionTest {
@@ -133,7 +134,11 @@
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 Object comp = combo.getUI().getAccessibleChild(combo, 0);
-                JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
+                int i = 0;
+                JComponent scrollPane;
+                do {
+                    scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(i++);
+                } while (!(scrollPane instanceof JScrollPane));
 
                 menuItemHeight = scrollPane.getSize().height / TOTAL_MENU_ITEMS;
                 yPos = scrollPane.getLocationOnScreen().y + menuItemHeight / 2;
--- a/jdk/test/javax/swing/JDialog/Transparency/TransparencyTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/JDialog/Transparency/TransparencyTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -24,10 +24,12 @@
  /*
  @test
  @key headful
- @bug 8062946
+ @bug 8062946 8159906
  @summary Verify Transparency upon iconify/deiconify sequence
  @run main TransparencyTest
  */
+import java.awt.GraphicsEnvironment;
+import java.awt.GraphicsDevice;
 import java.awt.Color;
 import java.awt.Point;
 import java.awt.Robot;
@@ -43,7 +45,7 @@
     private static final int WIDTH = 250;
     private static final int HEIGHT = 250;
     private static final float OPACITY = 0.60f;
-    private static Point dlgPos;
+    private static volatile Point dlgPos;
 
     public static void createAndShowGUI() {
         frame = new JFrame("JFrame");
@@ -67,6 +69,14 @@
 
     public static void main(String[] args) throws Exception {
 
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        GraphicsDevice gd = ge.getDefaultScreenDevice();
+        GraphicsDevice.WindowTranslucency mode = GraphicsDevice.WindowTranslucency.TRANSLUCENT;
+        boolean translucencyCheck = gd.isWindowTranslucencySupported(mode);
+        if(!translucencyCheck) {
+            return;
+    }
+
         Robot robot = new Robot();
         // create a GUI
         SwingUtilities.invokeAndWait(new Runnable() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JLightweightFrame/JLightweightFrameRoundTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,87 @@
+/*
+ * 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 8170387
+ * @summary JLightweightFrame#syncCopyBuffer() may throw IOOBE
+ * @modules java.desktop/sun.swing
+ * @run main JLightweightFrameRoundTest
+ */
+
+import sun.swing.JLightweightFrame;
+import sun.swing.LightweightContent;
+
+import javax.swing.*;
+
+public class JLightweightFrameRoundTest {
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            JLightweightFrame jLightweightFrame = new JLightweightFrame();
+            jLightweightFrame.setContent(new XLightweightContent());
+            jLightweightFrame.setSize(600, 600);
+            jLightweightFrame.notifyDisplayChanged(1.0001, 1.0001);
+        });
+    }
+
+    static class XLightweightContent implements LightweightContent {
+        @Override
+        public JComponent getComponent() {
+            return new JPanel();
+        }
+
+        @Override
+        public void paintLock() {}
+
+        @Override
+        public void paintUnlock() {}
+
+        @Override
+        public void imageBufferReset(int[] data, int x, int y, int width,
+                                     int height, int linestride,
+                                     double scaleX,
+                                     double scaleY) {}
+
+        @Override
+        public void imageReshaped(int x, int y, int width, int height) {}
+
+        @Override
+        public void imageUpdated(int dirtyX, int dirtyY, int dirtyWidth,
+                                 int dirtyHeight) {}
+
+        @Override
+        public void focusGrabbed() {}
+
+        @Override
+        public void focusUngrabbed() {}
+
+        @Override
+        public void preferredSizeChanged(int width, int height) {}
+
+        @Override
+        public void maximumSizeChanged(int width, int height) {}
+
+        @Override
+        public void minimumSizeChanged(int width, int height) {}
+    }
+}
--- a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Fri Dec 16 11:58:17 2016 -0800
@@ -26,22 +26,31 @@
  * @key headful
  * @library ../../regtesthelpers
  * @build Util
- * @bug 8033699 8154043
+ * @bug 8033699 8154043 8167160
  * @summary  Incorrect radio button behavior when pressing tab key
- * @author Vivi An
  * @run main bug8033699
  */
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.event.*;
-import java.awt.*;
+import java.awt.KeyboardFocusManager;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
 
 public class bug8033699 {
+
+    private static JFrame mainFrame;
     private static Robot robot;
-
     private static JButton btnStart;
-    private static ButtonGroup btnGrp;
     private static JButton btnEnd;
     private static JButton btnMiddle;
     private static JRadioButton radioBtn1;
@@ -51,7 +60,9 @@
 
     public static void main(String args[]) throws Throwable {
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
+                changeLAF();
                 createAndShowGUI();
             }
         });
@@ -84,11 +95,30 @@
 
         // down key circle back to first button in grouped radio button
         runTest8();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                mainFrame.dispose();
+            }
+        });
+    }
+
+    private static void changeLAF() {
+        String currentLAF = UIManager.getLookAndFeel().toString();
+        System.out.println(currentLAF);
+        currentLAF = currentLAF.toLowerCase();
+        if (currentLAF.contains("aqua") || currentLAF.contains("nimbus")) {
+            try {
+                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
     }
 
     private static void createAndShowGUI() {
-        JFrame mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
-
+        mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
         btnStart = new JButton("Start");
         btnEnd = new JButton("End");
         btnMiddle = new JButton("Middle");
@@ -132,12 +162,13 @@
     }
 
     // Radio button Group as a single component when traversing through tab key
-    private static void runTest1() throws Exception{
+    private static void runTest1() throws Exception {
         hitKey(robot, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_TAB);
 
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
                     System.out.println("Radio Button Group Go To Next Component through Tab Key failed");
@@ -148,9 +179,10 @@
     }
 
     // Non-Grouped Radio button as a single component when traversing through tab key
-    private static void runTest2() throws Exception{
+    private static void runTest2() throws Exception {
         hitKey(robot, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) {
                     System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed");
@@ -161,11 +193,12 @@
     }
 
     // Non-Grouped Radio button and Group Radio button as a single component when traversing through shift-tab key
-    private static void runTest3() throws Exception{
+    private static void runTest3() throws Exception {
         hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
         hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
                     System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed");
@@ -176,10 +209,11 @@
     }
 
     // Using arrow key to move focus in radio button group
-    private static void runTest4() throws Exception{
+    private static void runTest4() throws Exception {
         hitKey(robot, KeyEvent.VK_DOWN);
         hitKey(robot, KeyEvent.VK_RIGHT);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
                     System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed");
@@ -189,10 +223,11 @@
         });
     }
 
-    private static void runTest5() throws Exception{
+    private static void runTest5() throws Exception {
         hitKey(robot, KeyEvent.VK_UP);
         hitKey(robot, KeyEvent.VK_LEFT);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
                     System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed");
@@ -202,10 +237,11 @@
         });
     }
 
-    private static void runTest6() throws Exception{
+    private static void runTest6() throws Exception {
         hitKey(robot, KeyEvent.VK_UP);
         hitKey(robot, KeyEvent.VK_UP);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) {
                     System.out.println("Radio button Group Circle Back To First Button Test");
@@ -215,9 +251,10 @@
         });
     }
 
-    private static void runTest7() throws Exception{
+    private static void runTest7() throws Exception {
         hitKey(robot, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) {
                     System.out.println("Separate Component added in button group layout");
@@ -227,9 +264,10 @@
         });
     }
 
-    private static void runTest8() throws Exception{
+    private static void runTest8() throws Exception {
         hitKey(robot, KeyEvent.VK_TAB);
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
                     System.out.println("Separate Component added in button group layout");
--- a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java	Fri Dec 16 11:58:17 2016 -0800
@@ -42,7 +42,6 @@
 import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.KeyStroke;
-import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
@@ -133,43 +132,21 @@
     }
 
     private static void runTestCase() throws Exception {
-        LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
         focusOn(a);
-        if (isExcludedLookAndFeel(lookAndFeel)) {
-            robot.keyPress(KeyEvent.VK_ENTER);
-            robot.keyRelease(KeyEvent.VK_ENTER);
-            robot.waitForIdle();
-            isFocusOwner(b, "forward");
-            robot.keyPress(KeyEvent.VK_SHIFT);
-            robot.keyPress(KeyEvent.VK_TAB);
-            robot.keyRelease(KeyEvent.VK_TAB);
-            robot.keyRelease(KeyEvent.VK_SHIFT);
-            robot.waitForIdle();
-            isFocusOwner(a, "backward");
-
-        } else {
 
-            robot.keyPress(KeyEvent.VK_ENTER);
-            robot.keyRelease(KeyEvent.VK_ENTER);
-            robot.waitForIdle();
-            isFocusOwner(next, "forward");
-            robot.keyPress(KeyEvent.VK_SHIFT);
-            robot.keyPress(KeyEvent.VK_TAB);
-            robot.keyRelease(KeyEvent.VK_TAB);
-            robot.keyRelease(KeyEvent.VK_SHIFT);
-            robot.waitForIdle();
-            isFocusOwner(d, "backward");
-        }
+        robot.keyPress(KeyEvent.VK_ENTER);
+        robot.keyRelease(KeyEvent.VK_ENTER);
+        robot.waitForIdle();
+        isFocusOwner(next, "forward");
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_TAB);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.waitForIdle();
+        isFocusOwner(a, "backward");
 
     }
 
-    private static boolean isExcludedLookAndFeel(LookAndFeel lookAndFeel) {
-
-        return lookAndFeel.toString().toLowerCase().contains("aqua")
-                || lookAndFeel.toString().toLowerCase().contains("nimbus")
-                || lookAndFeel.toString().toLowerCase().contains("gtk");
-    }
-
     private static void focusOn(Component component)
             throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/SorterIOOBEtest/DefaultRowSorterIOOBEtest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,119 @@
+/*
+ * 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 8160087
+ * @summary Change IOOBE to warning in the scenarios when it had not being
+ *          thrown before the JDK-8078514
+ * @run main/othervm DefaultRowSorterIOOBEtest
+ */
+
+import javax.swing.*;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableRowSorter;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultRowSorterIOOBEtest extends TableRowSorter<TableModel> {
+    static List<String> rows = new ArrayList<>();
+
+    static TableModel tableModel = new AbstractTableModel() {
+
+        @Override
+        public int getRowCount() {
+            return rows.size();
+        }
+
+        @Override
+        public int getColumnCount() {
+            return 1;
+        }
+
+        @Override
+        public Object getValueAt(int rowIndex, int columnIndex) {
+            return rows.get(rowIndex);
+        }
+    };
+
+    public static void main(String[] args) {
+        DefaultRowSorter<TableModel, Integer> sorter =
+            new DefaultRowSorter<>() {
+            {
+                setModelWrapper(new SorterModelWrapper());
+            }
+        };
+
+        PrintStream err = System.err;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(10000) {
+            @Override
+            public synchronized void write(byte[] b, int off, int len) {
+                super.write(b, off, len);
+                err.print(new String(b, off, len));
+            }
+        };
+        System.setErr(new PrintStream(bos));
+
+        rows.add("New");
+
+        sorter.convertRowIndexToView(0);
+        sorter.convertRowIndexToModel(0);
+
+        String out = new String(bos.toByteArray());
+        if(out.indexOf("WARNING:") < 0) {
+            throw new RuntimeException("No warnings found");
+        }
+    }
+
+    static class SorterModelWrapper extends
+                            DefaultRowSorter.ModelWrapper<TableModel, Integer> {
+
+        @Override
+        public TableModel getModel() {
+            return tableModel;
+        }
+
+        @Override
+        public int getColumnCount() {
+            return tableModel.getColumnCount();
+        }
+
+        @Override
+        public int getRowCount() {
+            return tableModel.getRowCount();
+        }
+
+        @Override
+        public Object getValueAt(int row, int column) {
+            return tableModel.getValueAt(row, column);
+        }
+
+        @Override
+        public Integer getIdentifier(int row) {
+            return row;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/RepaintManager/8162350/RepaintManagerFPUIScaleTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,223 @@
+/*
+ * 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.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BaseMultiResolutionImage;
+import java.awt.image.BufferedImage;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+/*
+ * @test
+ * @bug 8162350
+ * @summary RepaintManager shifts repainted region when the floating point UI scale is used
+ * @run main/manual/othervm -Dsun.java2d.uiScale=1.5 RepaintManagerFPUIScaleTest
+ */
+public class RepaintManagerFPUIScaleTest {
+
+    private static volatile boolean testResult = false;
+    private static volatile CountDownLatch countDownLatch;
+    private static final String INSTRUCTIONS = "INSTRUCTIONS:\n"
+            + "Check JScrollPane correctly repaints the view"
+            + " when UI scale has floating point value:\n"
+            + "\n"
+            + "1. Scroll down the JScrollPane\n"
+            + "2. Select some values\n"
+            + "If the scrolled selected value is painted without artifacts,"
+            + "press PASS, else press FAIL.";
+
+    public static void main(String args[]) throws Exception {
+
+        countDownLatch = new CountDownLatch(1);
+
+        SwingUtilities.invokeLater(RepaintManagerFPUIScaleTest::createUI);
+        countDownLatch.await(15, TimeUnit.MINUTES);
+
+        if (!testResult) {
+            throw new RuntimeException("Test fails!");
+        }
+    }
+
+    private static void createUI() {
+
+        final JFrame mainFrame = new JFrame("Motif L&F icons test");
+        GridBagLayout layout = new GridBagLayout();
+        JPanel mainControlPanel = new JPanel(layout);
+        JPanel resultButtonPanel = new JPanel(layout);
+
+        GridBagConstraints gbc = new GridBagConstraints();
+
+        JComponent testPanel = createComponent();
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(testPanel, gbc);
+
+        JTextArea instructionTextArea = new JTextArea();
+        instructionTextArea.setText(INSTRUCTIONS);
+        instructionTextArea.setEditable(false);
+        instructionTextArea.setBackground(Color.white);
+
+        gbc.gridx = 0;
+        gbc.gridy = 1;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        mainControlPanel.add(instructionTextArea, gbc);
+
+        JButton passButton = new JButton("Pass");
+        passButton.setActionCommand("Pass");
+        passButton.addActionListener((ActionEvent e) -> {
+            testResult = true;
+            mainFrame.dispose();
+            countDownLatch.countDown();
+
+        });
+
+        JButton failButton = new JButton("Fail");
+        failButton.setActionCommand("Fail");
+        failButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+
+        gbc.gridx = 0;
+        gbc.gridy = 0;
+        resultButtonPanel.add(passButton, gbc);
+
+        gbc.gridx = 1;
+        gbc.gridy = 0;
+        resultButtonPanel.add(failButton, gbc);
+
+        gbc.gridx = 0;
+        gbc.gridy = 2;
+        mainControlPanel.add(resultButtonPanel, gbc);
+
+        mainFrame.add(mainControlPanel);
+        mainFrame.pack();
+
+        mainFrame.addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                mainFrame.dispose();
+                countDownLatch.countDown();
+            }
+        });
+        mainFrame.setVisible(true);
+    }
+
+    private static JComponent createComponent() {
+
+        int N = 100;
+        String[] data = new String[N];
+        for (int i = 0; i < N; i++) {
+            data[i] = "Floating point test List Item: " + i;
+        }
+        JList list = new JList(data);
+        list.setCellRenderer(new TestListCellRenderer());
+
+        JScrollPane scrollPane = new JScrollPane(list);
+        return scrollPane;
+    }
+
+    private static Color[] COLORS = {
+        Color.RED, Color.ORANGE, Color.GREEN, Color.BLUE, Color.GRAY
+    };
+
+    private static Image createTestImage(int width, int height, int colorindex) {
+
+        Color color = COLORS[colorindex % COLORS.length];
+
+        AffineTransform tx = GraphicsEnvironment
+                .getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice()
+                .getDefaultConfiguration()
+                .getDefaultTransform();
+
+        Image baseImage = createTestImage(width, height, 1, 1, color);
+        Image rvImage = createTestImage(width, height, tx.getScaleX(), tx.getScaleY(), color);
+
+        return new BaseMultiResolutionImage(baseImage, rvImage);
+    }
+
+    private static Image createTestImage(int w, int h,
+            double scaleX, double scaleY, Color color) {
+
+        int width = (int) Math.ceil(scaleX * w);
+        int height = (int) Math.ceil(scaleY * h);
+        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+        Graphics2D g = img.createGraphics();
+        g.setColor(Color.WHITE);
+        g.fillRect(0, 0, width, height);
+        g.scale(scaleX, scaleY);
+        g.setColor(color);
+        int d = 1;
+        int d2 = 2 * d;
+        g.drawLine(d, h / 2, w - d2, h / 2);
+        g.drawLine(w / 2, d, w / 2, h - d2);
+        g.drawRect(d, d, w - d2, h - d2);
+        g.dispose();
+
+        return img;
+    }
+
+    static class TestListCellRenderer extends DefaultListCellRenderer {
+
+        public Component getListCellRendererComponent(
+                JList list,
+                Object value,
+                int index,
+                boolean isSelected,
+                boolean cellHasFocus) {
+            Component retValue = super.getListCellRendererComponent(
+                    list, value, index, isSelected, cellHasFocus
+            );
+            setIcon(new ImageIcon(createTestImage(20, 10, index)));
+            return retValue;
+        }
+    }
+}
--- a/jdk/test/javax/swing/plaf/basic/BasicScrollPaneUI/8166591/TooMuchWheelRotationEventsTest.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/plaf/basic/BasicScrollPaneUI/8166591/TooMuchWheelRotationEventsTest.java	Fri Dec 16 11:58:17 2016 -0800
@@ -44,20 +44,20 @@
  * @key headful
  * @summary [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra
  *    is very fast (Trackpad, Retina only)
+ * @requires (os.family == "windows" | os.family == "mac")
  * @run main/manual/othervm TooMuchWheelRotationEventsTest
  */
 public class TooMuchWheelRotationEventsTest {
 
     private static volatile boolean testResult = false;
     private static volatile CountDownLatch countDownLatch;
-    private static final String INSTRUCTIONS = "INSTRUCTIONS:\n"
-            + "Try to check the issue on Mac OS X 10.12 Sierra with trackpad"
-            + " on Retina display.\n"
+    private static final String INSTRUCTIONS = " INSTRUCTIONS:\n"
+            + " Try to check the issue with trackpad\n"
             + "\n"
-            + "If the trackpad is not supported, press PASS\n"
+            + " If the trackpad is not supported, press PASS\n"
             + "\n"
-            + "Use the trackpad to slightly scroll the JTextArea horizontally and vertically.\n"
-            + "If the text area is scrolled too fast press FAIL, else press PASS.";
+            + " Use the trackpad to slightly scroll the JTextArea horizontally and vertically.\n"
+            + " If the text area is scrolled too fast press FAIL, else press PASS.";
 
     public static void main(String args[]) throws Exception {
         countDownLatch = new CountDownLatch(1);
@@ -138,6 +138,7 @@
                 countDownLatch.countDown();
             }
         });
+        mainFrame.setLocationRelativeTo(null);
         mainFrame.setVisible(true);
     }
 
--- a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Fri Dec 16 19:15:37 2016 +0000
+++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Fri Dec 16 11:58:17 2016 -0800
@@ -23,7 +23,7 @@
  */
 
 /* @test
-   @bug 6427244 8144240 8166003
+   @bug 6427244 8144240 8166003 8169879
    @summary Test that pressing HOME correctly moves caret in I18N document.
    @author Sergey Groznyh
    @library ../../../regtesthelpers
@@ -69,10 +69,12 @@
         bug6427244 t = new bug6427244();
         for (String space: SPACES) {
             t.init(space);
-            t.runAllTests();
+            t.testCaretPosition();
         }
 
         System.out.println("OK");
+        // Dispose the test interface upon completion
+        t.destroyTestInterface();
     }
 
     void init(final String space) {
@@ -113,29 +115,65 @@
         }
     }
 
-    void blockTillDisplayed(JComponent comp) {
-        if(comp != null) {
-            while (!comp.isVisible()) {
-                try {
+    void destroyTestInterface() {
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    // Dispose the frame
+                    jf.dispose();
+                 }
+            });
+        } catch (Exception ex) {
+            // No-op
+        }
+    }
+
+    void blockTillDisplayed(JComponent comp) throws Exception {
+        while (comp != null && isCompVisible == false) {
+            try {
+                SwingUtilities.invokeAndWait(new Runnable() {
+                    @Override
+                    public void run() {
+                        isCompVisible = comp.isVisible();
+                     }
+                });
+
+                if (isCompVisible == false) {
+                    // A short wait for component to be visible
                     Thread.sleep(1000);
-                } catch (InterruptedException ie) {
-                    /* No-op */
                 }
+            } catch (InterruptedException ex) {
+                // No-op. Thread resumed from sleep
+            } catch (Exception ex) {
+                throw new RuntimeException(ex);
             }
         }
     }
 
     public void testCaretPosition() {
-        Point p = tp.getLocationOnScreen();
-        // the right-top corner position
-        p.x += (dim.width - 5);
-        p.y += 5;
-        ROBOT.mouseMove(p.x, p.y);
+        final Point p[] = new Point[1];
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    p[0] = tp.getLocationOnScreen();
+
+                    // the right-top corner position
+                    p[0].x += (dim.width - 5);
+                    p[0].y += 5;
+                }
+            });
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+        ROBOT.mouseMove(p[0].x, p[0].y);
         ROBOT.clickMouse();
         ROBOT.hitKey(KeyEvent.VK_HOME);
         ROBOT.waitForIdle();
         // this will fail if caret moves out of the 1st line.
         if (getCaretOrdinate() != 0) {
+            // Dispose the test interface upon completion
+            destroyTestInterface();
             throw new RuntimeException("Test Failed.");
         }
     }
@@ -162,7 +200,8 @@
         return y[0];
     }
 
-    JFrame jf;
-    JTextPane tp;
-    Dimension dim;
+    private JFrame jf;
+    private JTextPane tp;
+    private Dimension dim;
+    private volatile boolean isCompVisible = false;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java	Fri Dec 16 11:58:17 2016 -0800
@@ -0,0 +1,121 @@
+/*
+ * 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 4936917 7190578
+   @summary  Tests if background is correctly painted when <BODY> has css margins
+   @author Denis Sharypov
+   @library ../../../regtesthelpers
+   @run main bug4936917
+*/
+
+
+
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Robot;
+import java.util.Timer;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+
+public class bug4936917 {
+
+    private boolean passed = false;
+    private Timer timer;
+    private JEditorPane editorPane;
+    private static JFrame f;
+    private volatile Point p = null;
+
+    private String text =
+                "<html><head><style>" +
+                "body {background-color: #cccccc; margin-top: 36.000000pt;}" +
+                "</style></head>" +
+                "<body> some text </body></html>";
+
+    public void init() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                editorPane = new JEditorPane("text/html", "");
+                editorPane.setEditable(false);
+                editorPane.setMargin(new java.awt.Insets(0, 0, 0, 0));
+                editorPane.setText(text);
+
+                f = new JFrame();
+                f.getContentPane().add(editorPane);
+                f.setSize(600, 400);
+                f.setVisible(true);
+            }
+        });
+        blockTillDisplayed(editorPane);
+        Robot robot  = new Robot();
+        robot.waitForIdle();
+
+        int x0 = p.x + 15 ;
+        int y = p.y + 15;
+        int match = 0;
+        int nonmatch = 0;
+
+        passed = true;
+        for (int x = x0; x < x0 + 10; x++) {
+            System.out.println("color ("+x+"," + y +")=" + robot.getPixelColor(x,y));
+            if (!robot.getPixelColor(x, y).equals(new Color(0xcc, 0xcc, 0xcc))) {
+                nonmatch++;
+            } else match++;
+        }
+        if (nonmatch > match) {
+            passed = false;
+        }
+    }
+
+    void blockTillDisplayed(JComponent comp) throws Exception {
+        while (p == null) {
+            try {
+                SwingUtilities.invokeAndWait(() -> {
+                    p = comp.getLocationOnScreen();
+                });
+            } catch (IllegalStateException e) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ie) {
+                }
+            }
+        }
+    }
+
+    public void destroy() throws Exception {
+        SwingUtilities.invokeAndWait(()->f.dispose());
+        if(!passed) {
+            throw new RuntimeException("Test failed.");
+        }
+    }
+
+
+    public static void main(String args[]) throws Exception {
+            bug4936917 test = new bug4936917();
+            test.init();
+            test.destroy();
+    }
+}