From f5794aaadbf627913d691b9ff5bf5d054c987057 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 15 Nov 2016 08:58:29 -0800 Subject: [PATCH 01/99] 8153208: TIFFImageReadParam: should "contains()" check be appropriate for addAllowedTagSet() method? Do not add a duplicate TIFFTagSet instance and update the spec accordingly. Reviewed-by: prr --- .../javax/imageio/plugins/tiff/TIFFImageReadParam.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java index 1b8821aef1c..e6af9dfe887 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java @@ -50,7 +50,8 @@ import javax.imageio.ImageReadParam; */ public final class TIFFImageReadParam extends ImageReadParam { - private List allowedTagSets = new ArrayList(4); + private final List allowedTagSets = + new ArrayList(4); /** * Constructs a {@code TIFFImageReadParam}. Tags defined by @@ -72,7 +73,8 @@ public final class TIFFImageReadParam extends ImageReadParam { /** * 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 @@ public final class TIFFImageReadParam extends ImageReadParam { if (tagSet == null) { throw new IllegalArgumentException("tagSet == null!"); } - allowedTagSets.add(tagSet); + if (!allowedTagSets.contains(tagSet)) { + allowedTagSets.add(tagSet); + } } /** From 15c92b98a3d49cbdced9e11834542c54f39c6504 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 16 Nov 2016 11:49:52 -0800 Subject: [PATCH 02/99] 8168759: Incorrect vertical positioning of diacritics Reviewed-by: serb --- .../share/native/libfontmanager/HBShaper.c | 2 +- .../font/TextLayout/ArabicDiacriticTest.java | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 95a92f221ad..41cf1864178 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -140,7 +140,7 @@ jboolean storeGVData(JNIEnv* env, 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++; diff --git a/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java new file mode 100644 index 00000000000..e74edf8b8ed --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java @@ -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"); + } + } +} From 67657286e45a35a11f54e94a0de2f0408d8904e7 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 16 Nov 2016 14:27:39 -0800 Subject: [PATCH 03/99] 8167182: Exported elements referring to inaccessible types in jdk.accessibility Reviewed-by: serb, ssadetsky --- .../accessibility/util/AWTEventMonitor.java | 71 +++++++++---------- .../util/AccessibilityEventMonitor.java | 4 +- .../accessibility/util/SwingEventMonitor.java | 4 +- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java index cd3cf14164e..297779d39c8 100644 --- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java +++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AWTEventMonitor.java @@ -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 @@ public class AWTEventMonitor { * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * * @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 @@ public class AWTEventMonitor { * 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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 @@ public class AWTEventMonitor { 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); } } diff --git a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java index 603ba035ae7..e26718d15b5 100644 --- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java +++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/AccessibilityEventMonitor.java @@ -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 @@ public class AccessibilityEventMonitor { * 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(); /** diff --git a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java index bbb0fcb18b3..c5dcda4df3e 100644 --- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java +++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/SwingEventMonitor.java @@ -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 @@ public class SwingEventMonitor extends AWTEventMonitor { * 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} From 26282a374ced7a937c066a1a3a63875c10f4a917 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Thu, 17 Nov 2016 02:31:04 +0300 Subject: [PATCH 04/99] 8169202: [macos] Font substitution does not work for supplementary characters Reviewed-by: serb, prr --- .../native/libawt_lwawt/font/CGGlyphImages.m | 16 ++-- .../libawt_lwawt/font/CoreTextSupport.h | 2 + .../libawt_lwawt/font/CoreTextSupport.m | 32 +++++-- .../font/Fallback/SurrogatesFallbackTest.java | 88 +++++++++++++++++++ 4 files changed, 124 insertions(+), 14 deletions(-) create mode 100644 jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m index 79cdf5bf7a3..1d9269fc57f 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m @@ -591,7 +591,7 @@ CGGI_CreateImageForGlyph 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 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas, 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 NSString *threadLocalLCDCanvasKey = 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 @@ CGGI_FillImagesForGlyphs(jlong *glyphInfos, const AWTStrike *strike, 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 @@ CGGI_CreateGlyphsAndScanForComplexities(jlong *glyphInfos, 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 @@ CGGlyphImages_GetGlyphImagePtrs(jlong glyphInfos[], 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 @@ CGGlyphImages_GetGlyphImagePtrs(jlong glyphInfos[], // 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 @@ CGGlyphImages_GetGlyphImagePtrs(jlong glyphInfos[], 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, diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h index a0ede94846c..cbd3dc5923b 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.h @@ -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. diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m index 1bcd9f55102..5663b3084ac 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/CoreTextSupport.m @@ -103,24 +103,34 @@ void CTS_GetGlyphsAsIntsForCharacters 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 @@ CTFontRef CTS_CopyCTFallbackFontAndGlyphForJavaGlyphCode 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 diff --git a/jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java b/jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java new file mode 100644 index 00000000000..9a87243d898 --- /dev/null +++ b/jdk/test/java/awt/font/Fallback/SurrogatesFallbackTest.java @@ -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 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; + } +} + From 6d895b494d8f52c90bd182e339e1c3192c4f5692 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 17 Nov 2016 11:48:37 +0530 Subject: [PATCH 05/99] 8168657: [PIT] Still, on Windows test always fails: java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java Reviewed-by: serb, rchamyal --- .../unix/UnixMultiResolutionSplashTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java index 26c4f728599..a4c026b7931 100644 --- a/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java +++ b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java @@ -44,9 +44,11 @@ import java.util.Map; 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 { From bd215e318bde236660b6d79934d613b34fd32139 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Thu, 17 Nov 2016 11:57:56 +0530 Subject: [PATCH 06/99] 8169840: [TESTBUG] DisposeDialogNotActivateOwnerTest: Test clashes with another test with a similar name Reviewed-by: serb, aghaisas --- .../DisposeDialogNotActivateOwnerTest.html | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html diff --git a/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html b/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html deleted file mode 100644 index 28ae8dfea74..00000000000 --- a/jdk/test/java/awt/Focus/DisposedWindow/DisposeDialogNotActivateOwnerTest/DisposeDialogNotActivateOwnerTest.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - -DisposeDialogNotActivateOwnerTest - - - -

DisposeDialogNotActivateOwnerTest
Bug ID: 6386592

- -

See the dialog box (usually in upper left corner) for instructions

- - - - From d1743ce9482ff244fc23e1053c66d04dfb2991af Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Thu, 17 Nov 2016 14:14:40 +0530 Subject: [PATCH 07/99] 6614519: [Doc] Description java.awt.dnd.DragSourceContext.getCursor() should be clarified Reviewed-by: serb, ssadetsky --- .../share/classes/java/awt/dnd/DragSourceContext.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java index 7d858548ddb..63ceb3f1706 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java +++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java @@ -279,7 +279,7 @@ public class DragSourceContext } /** - * 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 @@ public class DragSourceContext } /** - * 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; } From 9ebdadb0f06b82cd5c11910b7c6bf696fd23e9bd Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Mon, 21 Nov 2016 17:46:48 +0300 Subject: [PATCH 08/99] 8169719: WrappedPlainView.modelToView() should return Rectangle2D Reviewed-by: prr, serb, ssadetsky --- .../share/classes/javax/swing/text/WrappedPlainView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java index 6bb02264dd3..dde3437adf4 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java @@ -26,6 +26,7 @@ package javax.swing.text; 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 @@ public class WrappedPlainView extends BoxView implements TabExpander { * 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 @@ public class WrappedPlainView extends BoxView implements TabExpander { 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; } From c71d7e10e6ae84a6eb4333350a5a928d7e18e71e Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Mon, 21 Nov 2016 15:04:37 -0800 Subject: [PATCH 09/99] 8170142: Broken links in TIFF metadata format and usage notes Change href attributes to the correct destinations Reviewed-by: prr --- .../javax/imageio/metadata/doc-files/tiff_metadata.html | 6 +++--- .../javax/imageio/plugins/tiff/BaselineTIFFTagSet.java | 2 +- .../classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java | 2 +- .../classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java | 5 +---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html index 2fc49cfec0f..045a1025f08 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html +++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/tiff_metadata.html @@ -534,7 +534,7 @@ Technical Note #2 ZLib "Deflate/Inflate" compression (see note following this table) - + Adobe Photoshop® TIFF Technical Notes (PDF) @@ -545,9 +545,9 @@ Adobe Photoshop® TIFF Technical Notes (PDF) Deflate "Zip-in-TIFF" compression (see note following this table) - + ZLIB Compressed Data Format Specification, - + DEFLATE Compressed Data Format Specification diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java index 8c9ce8eaffa..d6181990e3f 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java @@ -224,7 +224,7 @@ public final class BaselineTIFFTagSet extends TIFFTagSet { * A value to be used with the "Compression" tag. * * @see #TAG_COMPRESSION - * @see DEFLATE specification + * @see DEFLATE specification * @see TIFF Specification Supplement 2 */ public static final int COMPRESSION_DEFLATE = 32946; diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java index 3ecfe500673..07888435588 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/FaxTIFFTagSet.java @@ -29,7 +29,7 @@ import java.util.List; /** * A class representing the extra tags found in a - * TIFF-F (RFC 2036) file. + * TIFF-F (RFC 2036) file. * * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java index 4f77c2926bf..18962ed3816 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java @@ -30,10 +30,7 @@ import java.util.List; /** * 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 - * {@code http://www.remotesensing.org/geotiff/spec/geotiffhome.html} - * . This class does not handle the GeoKeys referenced + * This class does not handle the GeoKeys referenced * from a GeoKeyDirectoryTag as those are not TIFF tags per se. * *

The definitions of the data types referenced by the field From ba274b43ecc68801e20c2c8354fc501d85645364 Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Wed, 23 Nov 2016 14:28:14 +0530 Subject: [PATCH 10/99] 8138771: java.awt.image.AbstractMultiResolutionImage needs customized spec for methods of Image which it implements Reviewed-by: flar, alexsch --- .../image/AbstractMultiResolutionImage.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java index 9d190a92e2c..89c43879ac3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java @@ -64,27 +64,71 @@ import java.awt.Image; 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); From 9d87230fccfa54c409643c67c3cd2fbb2cfb15d0 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 23 Nov 2016 18:48:02 +0300 Subject: [PATCH 11/99] 8140525: AwtFrame::WmShowWindow() may steal focus Reviewed-by: serb, ssadetsky --- .../java.desktop/windows/native/libawt/windows/awt_Frame.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp index 6c8d65a47c7..9bc6366d17b 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp @@ -484,7 +484,10 @@ MsgRouting AwtFrame::WmShowWindow(BOOL show, UINT status) 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 From f04a27dbdcc70479f9945f64939b108ebe03e00f Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 24 Nov 2016 11:58:52 +0530 Subject: [PATCH 12/99] 8048702: Deprecate obsolete classes in javax/swing/plaf/metal/MetalFileChooserUI.java Reviewed-by: serb, alexsch --- .../classes/javax/swing/plaf/metal/MetalFileChooserUI.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java index 91132582193..32db72db408 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java @@ -571,7 +571,9 @@ public class MetalFileChooserUI extends BasicFileChooserUI { /** * 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 @@ public class MetalFileChooserUI extends BasicFileChooserUI { /** * 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 { } From b61b0b8c006df152f014dfcd9d9800638ec371ae Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Thu, 24 Nov 2016 14:11:32 +0530 Subject: [PATCH 13/99] 8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java Reviewed-by: psadhukhan, serb --- .../JRadioButton/8033699/bug8033699.java | 76 ++++++++++++++----- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java index 4b95dc92bb3..a9ad28e7504 100644 --- a/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java +++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java @@ -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 Robot robot; + 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 class bug8033699 { public static void main(String args[]) throws Throwable { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { + changeLAF(); createAndShowGUI(); } }); @@ -84,11 +95,30 @@ public class bug8033699 { // 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 @@ public class bug8033699 { } // 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 @@ public class bug8033699 { } // 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 @@ public class bug8033699 { } // 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 @@ public class bug8033699 { } // 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 @@ public class bug8033699 { }); } - 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 @@ public class bug8033699 { }); } - 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 @@ public class bug8033699 { }); } - 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 @@ public class bug8033699 { }); } - 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"); From 893ec916559516ffe8b5dd139463c77a00b74bf8 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Mon, 28 Nov 2016 10:36:40 +0300 Subject: [PATCH 14/99] 8168135: The issue JDK-8164462 seems not fixed in b140 Reviewed-by: serb --- .../unix/classes/sun/awt/X11/XContentWindow.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java index 85e578b4052..74444b8d2d6 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java @@ -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 @@ public final class XContentWindow extends XWindow { // 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. From 547092cf8d16d7045f651c8008ce7a778b20a5e4 Mon Sep 17 00:00:00 2001 From: Maksim Khramov Date: Mon, 28 Nov 2016 14:36:46 +0300 Subject: [PATCH 15/99] 8167284: [TESTBUG] [PIT] possible regression: javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java Reviewed-by: ssadetsky, yan --- .../FocusTraversal/FocusTraversal.java | 43 +++++-------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java index 4c773c0f7b1..9ab19f7b245 100644 --- a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java +++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java @@ -42,7 +42,6 @@ import javax.swing.JPanel; 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,41 +132,19 @@ public class FocusTraversal { } 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(a, "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(d, "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) From 1ac940c263c5b33c2b0cd5cb17c8aece32fc687f Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 29 Nov 2016 09:54:16 -0800 Subject: [PATCH 16/99] 8167103: Intermittent font loading failure on macOS with JFXPanel application Reviewed-by: serb, psadhukhan --- .../macosx/classes/sun/font/CFontManager.java | 18 +++++++++++++--- .../macosx/native/libawt_lwawt/font/AWTFont.m | 21 +++++++------------ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java index 0c505b28576..45f48328717 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java @@ -141,12 +141,24 @@ public final class CFontManager extends SunFontManager { } } - 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) () -> { + 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) { diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m index d374e5a1241..bca21021347 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m @@ -404,19 +404,14 @@ Java_sun_font_CFontManager_loadNativeDirFonts { 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); } From 1d0671e8dc428eb08d02d7d8572cd31e237ccfee Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Wed, 30 Nov 2016 10:47:57 +0300 Subject: [PATCH 17/99] 8160087: Change IOOBE to warning in the scenarios when it had not being thrown before the JDK-8078514 Reviewed-by: azvegint, alexsch --- .../classes/javax/swing/DefaultRowSorter.java | 31 +++-- .../DefaultRowSorterIOOBEtest.java | 119 ++++++++++++++++++ 2 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 jdk/test/javax/swing/JTable/SorterIOOBEtest/DefaultRowSorterIOOBEtest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java b/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java index 5bc2f0687a9..542e1cb3c16 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java @@ -182,6 +182,8 @@ public abstract class DefaultRowSorter extends RowSorter { */ private int modelRowCount; + // Whether to print warning about JDK-8160087 + private static boolean warning8160087 = true; /** * Creates an empty DefaultRowSorter. @@ -489,10 +491,7 @@ public abstract class DefaultRowSorter extends RowSorter { */ 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 abstract class DefaultRowSorter extends RowSorter { */ 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 keys = getSortKeys(); int keySize = keys.size(); diff --git a/jdk/test/javax/swing/JTable/SorterIOOBEtest/DefaultRowSorterIOOBEtest.java b/jdk/test/javax/swing/JTable/SorterIOOBEtest/DefaultRowSorterIOOBEtest.java new file mode 100644 index 00000000000..fec08479521 --- /dev/null +++ b/jdk/test/javax/swing/JTable/SorterIOOBEtest/DefaultRowSorterIOOBEtest.java @@ -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 { + static List 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 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 { + + @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; + } + } +} From b1fd8970438f2b926da6ae9aa37d9d2f6db41542 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 1 Dec 2016 10:51:36 +0530 Subject: [PATCH 18/99] 7190578: Nimbus: css test for 4936917 fails Reviewed-by: serb, aghaisas --- .../text/html/StyleSheet/bug4936917.java | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java diff --git a/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java b/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java new file mode 100644 index 00000000000..10fe6e867bc --- /dev/null +++ b/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java @@ -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 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 = + "" + + " some text "; + + 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(); + } +} From 0fb83f04d479e964f53e44921363422d7fff04d4 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Fri, 2 Dec 2016 12:45:52 +0300 Subject: [PATCH 19/99] 8169589: [macosx] Activating a JDialog puts to back another dialog Reviewed-by: aivanov, serb --- .../sun/lwawt/macosx/CPlatformWindow.java | 80 +++++++++++++----- .../share/classes/java/awt/Window.java | 4 + .../share/classes/sun/awt/AWTAccessor.java | 6 ++ .../DialogAboveFrameTest.java | 81 +++++++++++++++++++ 4 files changed, 153 insertions(+), 18 deletions(-) create mode 100644 jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index d93b4bbcf21..1750516a84f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -33,11 +33,14 @@ import java.awt.Dialog.ModalityType; 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 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo 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 childWindows = new ArrayList(); - // 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); + final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor(); + final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor(); + + // 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))); + } + // 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])); } - - applyWindowLevel(target); } protected void applyWindowLevel(Window target) { diff --git a/jdk/src/java.desktop/share/classes/java/awt/Window.java b/jdk/src/java.desktop/share/classes/java/awt/Window.java index ed7d63ae154..8d122be3522 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Window.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java @@ -4122,6 +4122,10 @@ public class Window extends Container implements Accessible { public void setTrayIconWindow(Window w, boolean isTrayIconWindow) { w.isTrayIconWindow = isTrayIconWindow; } + + public Window[] getOwnedWindows(Window w) { + return w.getOwnedWindows_NoClientCode(); + } }); // WindowAccessor } // static diff --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index b20d8d62367..29a435c96b9 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -360,6 +360,12 @@ public final class AWTAccessor { * 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); } /** diff --git a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java new file mode 100644 index 00000000000..6db02253f42 --- /dev/null +++ b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java @@ -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(); + } + } +} + From 0bf29180647aca64fe3d9935b419efeb3685dc2c Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 2 Dec 2016 15:22:35 +0530 Subject: [PATCH 20/99] 8169879: [TEST_BUG] javax/swing/text/GlyphPainter2/6427244/bug6427244.java - compilation failed Reviewed-by: psadhukhan, aghaisas --- .../GlyphPainter2/6427244/bug6427244.java | 71 ++++++++++++++----- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java index f6f571aa05e..25066dafe42 100644 --- a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java +++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java @@ -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 @@ public class bug6427244 { 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 @@ public class bug6427244 { } } - 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 @@ public class bug6427244 { return y[0]; } - JFrame jf; - JTextPane tp; - Dimension dim; + private JFrame jf; + private JTextPane tp; + private Dimension dim; + private volatile boolean isCompVisible = false; } From 96fc05b6726cb530d314340e03737a8fa56c2c46 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Tue, 13 Dec 2016 12:35:59 -0800 Subject: [PATCH 21/99] 8169389: Use a bitmap to control StackTraceElement::toString format and save footprint Reviewed-by: dfuchs, mchung --- .../classes/java/lang/StackTraceElement.java | 155 +++++++++--------- .../lang/StackTraceElement/ModuleFrames.java | 26 ++- 2 files changed, 98 insertions(+), 83 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java index 04ba817a553..98536259a92 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java +++ b/jdk/src/java.base/share/classes/java/lang/StackTraceElement.java @@ -30,7 +30,6 @@ import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.VM; import jdk.internal.module.ModuleHashes; -import java.lang.module.ModuleDescriptor.Version; import java.lang.reflect.Layer; import java.lang.reflect.Module; import java.util.HashSet; @@ -51,12 +50,13 @@ import java.util.Set; * @author Josh Bloch */ public final class StackTraceElement implements java.io.Serializable { - // This field is set to the compacted String representation used - // by StackTraceElement::toString and stored in serial form. + + // For Throwables and StackWalker, the VM initially sets this field to a + // reference to the declaring Class. The Class reference is used to + // construct the 'format' bitmap, and then is cleared. // - // This field is of Object type. VM initially sets this field to - // the Class object of the declaring class to build the compacted string. - private Object classOrLoaderModuleClassName; + // For STEs constructed using the public constructors, this field is not used. + private transient Class declaringClassObject; // Normally initialized by VM private String classLoaderName; @@ -66,6 +66,7 @@ public final class StackTraceElement implements java.io.Serializable { private String methodName; private String fileName; private int lineNumber; + private byte format = 0; // Default to show all /** * Creates a stack trace element representing the specified execution @@ -256,9 +257,10 @@ public final class StackTraceElement implements java.io.Serializable { } /** - * Returns a string representation of this stack trace element. The - * format of this string depends on the implementation, but the following - * examples may be regarded as typical: + * Returns a string representation of this stack trace element. + * + * @apiNote The format of this string depends on the implementation, but the + * following examples may be regarded as typical: *