Merge
authorddehaven
Mon, 05 Dec 2016 08:36:16 -0800
changeset 42734 b9a2deda98ef
parent 42733 fcda8c58dc5b (diff)
parent 42360 5e60b1e45041 (current diff)
child 42735 d9e129a783ab
Merge
jdk/test/java/util/Spliterator/SpliteratorLateBindingFailFastTest.java
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Dec 05 08:36:16 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.*;
@@ -1063,29 +1066,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/native/libawt_lwawt/font/AWTFont.m	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m	Mon Dec 05 08:36:16 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/java/awt/Window.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html	Mon Dec 05 08:36:16 2016 -0800
@@ -534,7 +534,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 +545,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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java	Mon Dec 05 08:36:16 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/TIFFImageReadParam.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java	Mon Dec 05 08:36:16 2016 -0800
@@ -50,7 +50,8 @@
  */
 public final class TIFFImageReadParam extends ImageReadParam {
 
-    private List<TIFFTagSet> allowedTagSets = new ArrayList<TIFFTagSet>(4);
+    private final List<TIFFTagSet> allowedTagSets =
+        new ArrayList<TIFFTagSet>(4);
 
     /**
      * Constructs a {@code TIFFImageReadParam}.  Tags defined by
@@ -72,7 +73,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 +85,9 @@
         if (tagSet == null) {
             throw new IllegalArgumentException("tagSet == null!");
         }
-        allowedTagSets.add(tagSet);
+        if (!allowedTagSets.contains(tagSet)) {
+            allowedTagSets.add(tagSet);
+        }
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Mon Dec 05 08:36:16 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/plaf/metal/MetalFileChooserUI.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java	Mon Dec 05 08:36:16 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/native/libfontmanager/HBShaper.c	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java	Mon Dec 05 08:36:16 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_Frame.cpp	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp	Mon Dec 05 08:36:16 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/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java	Mon Dec 05 08:36:16 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	Mon Dec 05 08:36:16 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();
+        }
+    }
+}
+
--- a/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java	Mon Dec 05 08:36:16 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 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java	Mon Dec 05 08:36:16 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	Mon Dec 05 08:36:16 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/swing/JDialog/Transparency/TransparencyTest.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/test/javax/swing/JDialog/Transparency/TransparencyTest.java	Mon Dec 05 08:36:16 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() {
--- a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java	Mon Dec 05 08:36:16 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	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java	Mon Dec 05 08:36:16 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	Mon Dec 05 08:36:16 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;
+        }
+    }
+}
--- a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Mon Dec 05 12:53:53 2016 +0530
+++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Mon Dec 05 08:36:16 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	Mon Dec 05 08:36:16 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();
+    }
+}