From e28bb07a3d328939b068fbff6826e0632da6d215 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Fri, 13 May 2016 14:25:29 +0300 Subject: [PATCH 01/87] 8080729: [macosx] java 7 and 8 JDialogs on multiscreen jump to parent frame on focus Reviewed-by: ant, denis --- .../sun/lwawt/macosx/CPlatformWindow.java | 37 ++----- .../sun/lwawt/macosx/CWarningWindow.java | 15 +-- .../native/libawt_lwawt/awt/AWTWindow.h | 2 + .../native/libawt_lwawt/awt/AWTWindow.m | 102 ++++++++++++++++++ .../WindowJumpingTest/WindowJumpingTest.java | 86 +++++++++++++++ 5 files changed, 201 insertions(+), 41 deletions(-) create mode 100644 jdk/test/java/awt/Window/WindowJumpingTest/WindowJumpingTest.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 f0d0a22b3bc..5fcc2384e3c 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 @@ -430,9 +430,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override // PlatformWindow public void dispose() { - if (owner != null) { - CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr()); - } contentView.dispose(); nativeDispose(getNSWindowPtr()); CPlatformWindow.super.dispose(); @@ -527,26 +524,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo public void setVisible(boolean visible) { final long nsWindowPtr = getNSWindowPtr(); - // Process parent-child relationship when hiding - final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); - if (!visible) { - // Unparent my children - for (Window w : target.getOwnedWindows()) { - WindowPeer p = acc.getPeer(w); - if (p instanceof LWWindowPeer) { - CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow(); - if (pw != null && pw.isVisible()) { - CWrapper.NSWindow.removeChildWindow(nsWindowPtr, pw.getNSWindowPtr()); - } - } - } - - // Unparent myself - if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), nsWindowPtr); - } - } - // Configure stuff updateIconImages(); updateFocusabilityForAutoRequestFocus(false); @@ -619,20 +596,22 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo updateFocusabilityForAutoRequestFocus(true); // Manage parent-child relationship when showing + final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); + if (visible) { - // Add myself as a child + // Order myself above my parent if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); + CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr()); applyWindowLevel(target); } - // Add my own children to myself + // Order my own children above myself for (Window w : target.getOwnedWindows()) { final Object p = acc.getPeer(w); if (p instanceof LWWindowPeer) { CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow(); if (pw != null && pw.isVisible()) { - CWrapper.NSWindow.addChildWindow(nsWindowPtr, pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove); + CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr); pw.applyWindowLevel(w); } } @@ -1052,8 +1031,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // Order the window to front of the stack of child windows final long nsWindowSelfPtr = getNSWindowPtr(); final long nsWindowOwnerPtr = owner.getNSWindowPtr(); - CWrapper.NSWindow.removeChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr); - CWrapper.NSWindow.addChildWindow(nsWindowOwnerPtr, nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove); + CWrapper.NSWindow.orderFront(nsWindowOwnerPtr); + CWrapper.NSWindow.orderWindow(nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove, nsWindowOwnerPtr); } applyWindowLevel(target); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java index 28a4b657e55..ee44dbf09c9 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java @@ -206,15 +206,6 @@ public final class CWarningWindow extends CPlatformWindow synchronized (lock) { final long nsWindowPtr = getNSWindowPtr(); - // Process parent-child relationship when hiding - if (!visible) { - // Unparent myself - if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.removeChildWindow( - owner.getNSWindowPtr(), nsWindowPtr); - } - } - // Actually show or hide the window if (visible) { CWrapper.NSWindow.orderFront(nsWindowPtr); @@ -226,10 +217,10 @@ public final class CWarningWindow extends CPlatformWindow // Manage parent-child relationship when showing if (visible) { - // Add myself as a child + // Order myself above my parent if (owner != null && owner.isVisible()) { - CWrapper.NSWindow.addChildWindow(owner.getNSWindowPtr(), - nsWindowPtr, CWrapper.NSWindow.NSWindowAbove); + CWrapper.NSWindow.orderWindow(nsWindowPtr, + CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr()); // do not allow security warning to be obscured by other windows applyWindowLevel(ownerWindow); diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h index d1bb8c64c43..d48fe7628b9 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h @@ -46,6 +46,7 @@ AWTWindow *ownerWindow; jint preFullScreenLevel; NSRect standardFrame; + BOOL isMinimizing; } // An instance of either AWTWindow_Normal or AWTWindow_Panel @@ -60,6 +61,7 @@ @property (nonatomic) BOOL isEnabled; @property (nonatomic) jint preFullScreenLevel; @property (nonatomic) NSRect standardFrame; +@property (nonatomic) BOOL isMinimizing; - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow ownerWindow:owner diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index eff112a9634..efde3e10678 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -180,6 +180,7 @@ AWT_NS_WINDOW_IMPLEMENTATION @synthesize ownerWindow; @synthesize preFullScreenLevel; @synthesize standardFrame; +@synthesize isMinimizing; - (void) updateMinMaxSize:(BOOL)resizable { if (resizable) { @@ -304,6 +305,7 @@ AWT_ASSERT_APPKIT_THREAD; [self.nsWindow release]; // the property retains the object already self.isEnabled = YES; + self.isMinimizing = NO; self.javaPlatformWindow = platformWindow; self.styleBits = bits; self.ownerWindow = owner; @@ -423,6 +425,68 @@ AWT_ASSERT_APPKIT_THREAD; [super dealloc]; } +// Tests wheather the corresponding Java paltform window is visible or not ++ (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window { + BOOL isVisible = NO; + + if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) { + AWTWindow *awtWindow = (AWTWindow *)[window delegate]; + [AWTToolkit eventCountPlusPlus]; + + JNIEnv *env = [ThreadUtilities getJNIEnv]; + jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env]; + if (platformWindow != NULL) { + static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z"); + isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO; + (*env)->DeleteLocalRef(env, platformWindow); + + } + } + return isVisible; +} + +// Orders window's childs based on the current focus state +- (void) orderChildWindows:(BOOL)focus { +AWT_ASSERT_APPKIT_THREAD; + + if (self.isMinimizing) { + // Do not perform any ordering, if iconify is in progress + return; + } + + NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator]; + NSWindow *window; + while ((window = [windowEnumerator nextObject]) != nil) { + if ([AWTWindow isJavaPlatformWindowVisible:window]) { + AWTWindow *awtWindow = (AWTWindow *)[window delegate]; + AWTWindow *owner = awtWindow.ownerWindow; + if (IS(awtWindow.styleBits, ALWAYS_ON_TOP)) { + // Do not order 'always on top' windows + continue; + } + while (awtWindow.ownerWindow != nil) { + if (awtWindow.ownerWindow == self) { + if (focus) { + // Move the childWindow to floating level + // so it will appear in front of its + // parent which owns the focus + [window setLevel:NSFloatingWindowLevel]; + } else { + // Focus owner has changed, move the childWindow + // back to normal window level + [window setLevel:NSNormalWindowLevel]; + } + // The childWindow should be displayed in front of + // its nearest parentWindow + [window orderWindow:NSWindowAbove relativeTo:[owner.nsWindow windowNumber]]; + break; + } + awtWindow = awtWindow.ownerWindow; + } + } + } +} + // NSWindow overrides - (BOOL) canBecomeKeyWindow { AWT_ASSERT_APPKIT_THREAD; @@ -511,6 +575,30 @@ AWT_ASSERT_APPKIT_THREAD; return [self standardFrame]; } +// Hides/shows window's childs during iconify/de-iconify operation +- (void) iconifyChildWindows:(BOOL)iconify { +AWT_ASSERT_APPKIT_THREAD; + + NSEnumerator *windowEnumerator = [[NSApp windows]objectEnumerator]; + NSWindow *window; + while ((window = [windowEnumerator nextObject]) != nil) { + if ([AWTWindow isJavaPlatformWindowVisible:window]) { + AWTWindow *awtWindow = (AWTWindow *)[window delegate]; + while (awtWindow.ownerWindow != nil) { + if (awtWindow.ownerWindow == self) { + if (iconify) { + [window orderOut:window]; + } else { + [window orderFront:window]; + } + break; + } + awtWindow = awtWindow.ownerWindow; + } + } + } +} + - (void) _deliverIconify:(BOOL)iconify { AWT_ASSERT_APPKIT_THREAD; @@ -524,16 +612,28 @@ AWT_ASSERT_APPKIT_THREAD; } } +- (void)windowWillMiniaturize:(NSNotification *)notification { +AWT_ASSERT_APPKIT_THREAD; + + self.isMinimizing = YES; + // Excplicitly make myself a key window to avoid possible + // negative visual effects during iconify operation + [self.nsWindow makeKeyAndOrderFront:self.nsWindow]; + [self iconifyChildWindows:YES]; +} + - (void)windowDidMiniaturize:(NSNotification *)notification { AWT_ASSERT_APPKIT_THREAD; [self _deliverIconify:JNI_TRUE]; + self.isMinimizing = NO; } - (void)windowDidDeminiaturize:(NSNotification *)notification { AWT_ASSERT_APPKIT_THREAD; [self _deliverIconify:JNI_FALSE]; + [self iconifyChildWindows:NO]; } - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite { @@ -579,6 +679,7 @@ AWT_ASSERT_APPKIT_THREAD; [AWTWindow setLastKeyWindow:nil]; [self _deliverWindowFocusEvent:YES oppositeWindow: opposite]; + [self orderChildWindows:YES]; } - (void) windowDidResignKey: (NSNotification *) notification { @@ -606,6 +707,7 @@ AWT_ASSERT_APPKIT_THREAD; } [self _deliverWindowFocusEvent:NO oppositeWindow: opposite]; + [self orderChildWindows:NO]; } - (void) windowDidBecomeMain: (NSNotification *) notification { diff --git a/jdk/test/java/awt/Window/WindowJumpingTest/WindowJumpingTest.java b/jdk/test/java/awt/Window/WindowJumpingTest/WindowJumpingTest.java new file mode 100644 index 00000000000..f2e210053e7 --- /dev/null +++ b/jdk/test/java/awt/Window/WindowJumpingTest/WindowJumpingTest.java @@ -0,0 +1,86 @@ +/* + * 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 8080729 + * @summary Dialogs on multiscreen jump to parent frame on focus gain + * @author Dmitry Markov + * @library ../../regtesthelpers + * @build Util + * @run main WindowJumpingTest + */ +import java.awt.*; + +import test.java.awt.regtesthelpers.Util; + +public class WindowJumpingTest { + public static void main(String[] args) throws AWTException { + Robot r = Util.createRobot(); + + GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices(); + if (graphicsDevices.length < 2) { + System.out.println("This is multi-screen test... Skipping!"); + return; + } + + Frame frame = new Frame("Frame", graphicsDevices[0].getDefaultConfiguration()); + frame.setSize(400, 300); + frame.setVisible(true); + Util.waitForIdle(r); + + Dialog dialog = new Dialog(frame, "Dialog", false, graphicsDevices[1].getDefaultConfiguration()); + dialog.setSize(400, 300); + dialog.setVisible(true); + Util.waitForIdle(r); + + checkGraphicsDevice(frame, graphicsDevices[0]); + checkGraphicsDevice(dialog, graphicsDevices[1]); + + Util.clickOnComp(frame, r); + Util.waitForIdle(r); + + checkGraphicsDevice(frame, graphicsDevices[0]); + checkGraphicsDevice(dialog, graphicsDevices[1]); + + Util.clickOnComp(dialog, r); + Util.waitForIdle(r); + + checkGraphicsDevice(frame, graphicsDevices[0]); + checkGraphicsDevice(dialog, graphicsDevices[1]); + + dialog.dispose(); + frame.dispose(); + } + + private static void checkGraphicsDevice(Window window, GraphicsDevice graphicsDevice) { + GraphicsDevice actualGraphicsDevice = window.getGraphicsConfiguration().getDevice(); + + if (!actualGraphicsDevice.equals(graphicsDevice)) { + System.err.println("Expected screen: " + graphicsDevice); + System.err.println("Actual screen: "+ actualGraphicsDevice); + throw new RuntimeException("Test FAILED: " + window + " is displayed on wrong screen"); + } + } +} + From 4f8ad614982422ccf36cd387c5ae2e284b7610b8 Mon Sep 17 00:00:00 2001 From: Mikhail Cherkasov Date: Fri, 13 May 2016 14:30:59 +0300 Subject: [PATCH 02/87] 8078268: javax.swing.text.html.parser.Parser parseScript incorrectly optimized Reviewed-by: alexp, aivanov --- .../javax/swing/text/html/parser/Parser.java | 100 +- .../parser/Parser/8078268/bug8078268.java | 72 + .../html/parser/Parser/8078268/slowparse.html | 3539 +++++++++++++++++ 3 files changed, 3667 insertions(+), 44 deletions(-) create mode 100644 jdk/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java create mode 100644 jdk/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java index d178ae4516c..9aa36bf39b2 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/Parser.java @@ -2084,57 +2084,69 @@ class Parser implements DTDConstants { while (true) { int i = 0; while (!insideComment && i < SCRIPT_END_TAG.length - && (SCRIPT_END_TAG[i] == ch - || SCRIPT_END_TAG_UPPER_CASE[i] == ch)) { + && (SCRIPT_END_TAG[i] == ch + || SCRIPT_END_TAG_UPPER_CASE[i] == ch)) { charsToAdd[i] = (char) ch; ch = readCh(); i++; } if (i == SCRIPT_END_TAG.length) { - - /* '' tag detected */ - /* Here, ch == the first character after */ return; - } else { - - /* To account for extra read()'s that happened */ - for (int j = 0; j < i; j++) { - addString(charsToAdd[j]); - } - - switch (ch) { - case -1: - error("eof.script"); - return; - case '\n': - ln++; - ch = readCh(); - lfCount++; - addString('\n'); - break; - case '\r': - ln++; - if ((ch = readCh()) == '\n') { - ch = readCh(); - crlfCount++; - } else { - crCount++; - } - addString('\n'); - break; - default: - addString(ch); - String str = new String(getChars(0, strpos)); - if (!insideComment && str.endsWith(START_COMMENT)) { - insideComment = true; - } - if (insideComment && str.endsWith(END_COMMENT)) { - insideComment = false; - } - ch = readCh(); - break; - } // switch } + + if (!insideComment && i == 1 && charsToAdd[0] == START_COMMENT.charAt(0)) { + // it isn't end script tag, but may be it's start comment tag? + while (i < START_COMMENT.length() + && START_COMMENT.charAt(i) == ch) { + charsToAdd[i] = (char) ch; + ch = readCh(); + i++; + } + if (i == START_COMMENT.length()) { + insideComment = true; + } + } + if (insideComment) { + while (i < END_COMMENT.length() + && END_COMMENT.charAt(i) == ch) { + charsToAdd[i] = (char) ch; + ch = readCh(); + i++; + } + if (i == END_COMMENT.length()) { + insideComment = false; + } + } + + /* To account for extra read()'s that happened */ + for (int j = 0; j < i; j++) { + addString(charsToAdd[j]); + } + switch (ch) { + case -1: + error("eof.script"); + return; + case '\n': + ln++; + ch = readCh(); + lfCount++; + addString('\n'); + break; + case '\r': + ln++; + if ((ch = readCh()) == '\n') { + ch = readCh(); + crlfCount++; + } else { + crCount++; + } + addString('\n'); + break; + default: + addString(ch); + ch = readCh(); + break; + } // switch } // while } diff --git a/jdk/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java b/jdk/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java new file mode 100644 index 00000000000..216919b2137 --- /dev/null +++ b/jdk/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +*/ + + +import java.io.File; +import java.io.FileReader; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import javax.swing.text.html.HTMLEditorKit; + +/* @test + @bug 8078268 + @summary javax.swing.text.html.parser.Parser parseScript incorrectly optimized + @author Mikhail Cherkasov + @run main bug8078268 +*/ +public class bug8078268 { + static volatile boolean parsingDone = false; + static volatile Exception exception; + + public static void main(String[] args) throws Exception { + long s = System.currentTimeMillis(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + HTMLEditorKit htmlKit = new HTMLEditorKit(); + Document doc = htmlKit.createDefaultDocument(); + try { + htmlKit.read(new FileReader(getDirURL() + "slowparse.html"), doc, 0); + parsingDone = true; + } catch (Exception e) { + exception = e; + } + } + }); + while (!parsingDone && exception == null && System.currentTimeMillis() - s < 5_000) { + Thread.sleep(200); + } + final long took = System.currentTimeMillis() - s; + if (exception != null) { + throw exception; + } + if (took > 5_000) { + throw new RuntimeException("Parsing takes too long."); + } + } + + static String getDirURL() { + return new File(System.getProperty("test.src", ".")).getAbsolutePath() + + File.separator; + } +} diff --git a/jdk/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html b/jdk/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html new file mode 100644 index 00000000000..e6c446c4900 --- /dev/null +++ b/jdk/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html @@ -0,0 +1,3539 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> + var b = 2; + + + + + From 5f037c972f88f80f595562474be4921396752172 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 13 May 2016 18:08:54 +0300 Subject: [PATCH 03/87] 8156583: Typo in the spec of javax.sound.sampled.AudioFormat.Encoding.toString() Reviewed-by: prr --- .../share/classes/javax/sound/sampled/AudioFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java index 39264aacf84..5728d6287cf 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java @@ -633,7 +633,7 @@ public class AudioFormat { * {@code String} is the same name that was passed to the constructor. * For the predefined encodings, the name is similar to the encoding's * variable (field) name. For example, {@code PCM_SIGNED.toString()} - * returns the name "pcm_signed". + * returns the name "PCM_SIGNED". * * @return the encoding name */ From b71deff4e2ef865391e5bcec1f19b120f02379b5 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Mon, 16 May 2016 18:12:53 +0300 Subject: [PATCH 04/87] 8041694: JFileChooser removes trailing spaces in the selected directory name Reviewed-by: serb, ssadetsky --- .../swing/plaf/basic/BasicFileChooserUI.java | 11 -- .../JFileChooser/8041694/bug8041694.java | 121 ++++++++++++++++++ 2 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 jdk/test/javax/swing/JFileChooser/8041694/bug8041694.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java index 6125786cd66..d58a5286f65 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java @@ -1050,17 +1050,6 @@ public class BasicFileChooserUI extends FileChooserUI { FileSystemView fs = chooser.getFileSystemView(); File dir = chooser.getCurrentDirectory(); - if (filename != null) { - // Remove whitespaces from end of filename - int i = filename.length() - 1; - - while (i >=0 && filename.charAt(i) <= ' ') { - i--; - } - - filename = filename.substring(0, i + 1); - } - if (filename == null || filename.length() == 0) { // no file selected, multiple selection off, therefore cancel the approve action resetGlobFilter(); diff --git a/jdk/test/javax/swing/JFileChooser/8041694/bug8041694.java b/jdk/test/javax/swing/JFileChooser/8041694/bug8041694.java new file mode 100644 index 00000000000..d24016b4a82 --- /dev/null +++ b/jdk/test/javax/swing/JFileChooser/8041694/bug8041694.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 8041694 + @summary JFileChooser removes trailing spaces in the selected directory name + @author Anton Litvinov + @library ../../../../lib/testlibrary + @build jdk.testlibrary.OSInfo + @run main bug8041694 + */ + +import java.awt.AWTException; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.concurrent.CountDownLatch; +import javax.swing.JFileChooser; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.metal.MetalLookAndFeel; + +import jdk.testlibrary.OSInfo; + +public class bug8041694 { + private static volatile File dir1; + private static File dir2; + private static volatile File selectedDir; + + private static void runTest() { + try { + // Set Metal L&F to make the test compatible with OS X. + UIManager.setLookAndFeel(new MetalLookAndFeel()); + Robot robot = new Robot(); + + dir1 = Files.createTempDirectory("bug8041694").toFile(); + if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) { + dir2 = new File(String.format( + "\\\\?\\%s\\d ", dir1.getAbsolutePath().replace('/', '\\'))); + } else { + dir2 = new File(dir1.getAbsolutePath() + File.separator + "d "); + } + dir2.mkdir(); + + final CountDownLatch fChooserClosedSignal = new CountDownLatch(1); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + JFileChooser fChooser = new JFileChooser(dir1); + fChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + if (fChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { + selectedDir = fChooser.getSelectedFile(); + } + } finally { + fChooserClosedSignal.countDown(); + } + } + }); + + robot.setAutoDelay(50); + robot.delay(1000); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_D); + robot.keyRelease(KeyEvent.VK_D); + robot.keyPress(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_SPACE); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + + fChooserClosedSignal.await(); + if (selectedDir == null) { + throw new RuntimeException("No directory was selected in JFileChooser."); + } + System.out.println(String.format( + "The selected directory is '%s'.", selectedDir.getAbsolutePath())); + if (selectedDir.getName().equals("d")) { + throw new RuntimeException( + "JFileChooser removed trailing spaces in the selected directory name."); + } else if (!selectedDir.getName().equals("d ")) { + throw new RuntimeException("The selected directory name is not the expected 'd '."); + } + } catch (UnsupportedLookAndFeelException | AWTException | IOException | InterruptedException e) { + throw new RuntimeException(e); + } finally { + if (dir2 != null) { + dir2.delete(); + } + if (dir1 != null) { + dir1.delete(); + } + } + } + + public static void main(String[] args) { + runTest(); + } +} From 337966337618b50cf1b2ccd9fb1959b96c19ff33 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Tue, 17 May 2016 14:31:12 +0300 Subject: [PATCH 05/87] 8046031: UI of Java Web Start app isn't updated when changing Windows theme Reviewed-by: alexsch, serb --- .../java/swing/plaf/windows/DesktopProperty.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java index ab6aa617222..4e55f2a8990 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.beans.*; import java.lang.ref.*; import javax.swing.*; import javax.swing.plaf.*; +import sun.awt.AppContext; /** * Wrapper for a value from the desktop. The value is lazily looked up, and @@ -41,10 +42,8 @@ import javax.swing.plaf.*; // NOTE: Don't rely on this class staying in this location. It is likely // to move to a different package in the future. public class DesktopProperty implements UIDefaults.ActiveValue { - /** - * Indicates if an updateUI call is pending. - */ - private static boolean updatePending; + private static final StringBuilder DESKTOP_PROPERTY_UPDATE_PENDING_KEY = + new StringBuilder("DesktopPropertyUpdatePending"); /** * ReferenceQueue of unreferenced WeakPCLs. @@ -86,14 +85,16 @@ public class DesktopProperty implements UIDefaults.ActiveValue { * Sets whether or not an updateUI call is pending. */ private static synchronized void setUpdatePending(boolean update) { - updatePending = update; + AppContext.getAppContext() + .put(DESKTOP_PROPERTY_UPDATE_PENDING_KEY, update); } /** * Returns true if a UI update is pending. */ private static synchronized boolean isUpdatePending() { - return updatePending; + return Boolean.TRUE.equals(AppContext.getAppContext() + .get(DESKTOP_PROPERTY_UPDATE_PENDING_KEY)); } /** From 6986e9dcadeda9f3915491d48bd6b9dd976ebeed Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Tue, 17 May 2016 21:50:13 +0300 Subject: [PATCH 06/87] 6477756: GraphicsDevice.getConfigurations() is slow taking 3 or more seconds Reviewed-by: prr, serb --- .../windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp index 970f061267c..c5fd2dfd880 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp @@ -929,6 +929,9 @@ Java_sun_awt_Win32GraphicsDevice_initIDs(JNIEnv *env, jclass cls) // Only want to call this once per session make_uns_ordered_dither_array(img_oda_alpha, 256); + // workaround JDK-6477756, ignore return value to keep dll in memory + JDK_LoadSystemLibrary("opengl32.dll"); + CATCH_BAD_ALLOC; } From c0fd256a5eb7eb2a404f9cf7d3481267adb98198 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 18 May 2016 11:33:04 +0530 Subject: [PATCH 07/87] 6529030: Java Printing: Print range > Selection gets enabled Reviewed-by: prr, jgodinez --- .../classes/sun/awt/windows/WPrinterJob.java | 14 +- .../PrintDlgSelectionAttribTest.java | 153 ++++++++++++++++++ 2 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/awt/print/PrinterJob/PrintDlgSelectionAttribTest.java diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java index 89c28502411..457393aeb5d 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java @@ -1852,12 +1852,14 @@ public final class WPrinterJob extends RasterPrinterJob setCollateAttrib(SheetCollate.UNCOLLATED, attributes); } - if ((flags & PD_PAGENUMS) != 0) { - attributes.add(SunPageSelection.RANGE); - } else if ((flags & PD_SELECTION) != 0) { - attributes.add(SunPageSelection.SELECTION); - } else { - attributes.add(SunPageSelection.ALL); + if ((flags & PD_NOSELECTION) != PD_NOSELECTION) { + if ((flags & PD_PAGENUMS) != 0) { + attributes.add(SunPageSelection.RANGE); + } else if ((flags & PD_SELECTION) != 0) { + attributes.add(SunPageSelection.SELECTION); + } else { + attributes.add(SunPageSelection.ALL); + } } if ((fields & DM_ORIENTATION) != 0) { diff --git a/jdk/test/java/awt/print/PrinterJob/PrintDlgSelectionAttribTest.java b/jdk/test/java/awt/print/PrinterJob/PrintDlgSelectionAttribTest.java new file mode 100644 index 00000000000..8640038eacb --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/PrintDlgSelectionAttribTest.java @@ -0,0 +1,153 @@ +/* + * 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 6529030 + * @summary Verifies if Java Printing: Selection radiobutton gets enabled. + * @requires (os.family == "windows") + * @run main/manual PrintDlgSelectionAttribTest + */ +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.print.Printable; +import java.awt.print.PageFormat; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class PrintDlgSelectionAttribTest { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static PrinterJob printJob; + + public static void print() { + + // Set working printable to print pages + printJob.setPrintable(new Printable() { + public int print(Graphics graphics, PageFormat pageFormat, + int pageIndex) throws PrinterException { + return NO_SUCH_PAGE; + } + }); + + // Display Print dialog + if (!printJob.printDialog()) { + System.out.println("\tPrinting canceled by user"); + return; + } + + try { + printJob.print(); + } catch (PrinterException e) { + } + } + + public static void printTest() { + printJob = PrinterJob.getPrinterJob(); + System.out.println(" -=- Starting printing #1 -=-"); + print(); + System.out.println(" -=- Starting printing #2 -=-"); + print(); + } + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(PrintDlgSelectionAttribTest::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("" + + "Selection radio button is enabled in print dialog"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Visual inspection of print dialog is required.\n" + + " Initially, a print dialog will be shown.\n " + + " Please verify Selection radio button is disabled.\n" + + " Press OK. Then 2nd print dialog will be shown.\n" + + " Please verify the Selection radio button is disabled\n" + + " in 2nd print dialog. If disabled, press PASS else press fail"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + } +} From 2de846fa4544faa923802f692c846fb300f3cd42 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Wed, 18 May 2016 15:51:19 +0300 Subject: [PATCH 08/87] 8136998: JComboBox prevents wheel mouse scrolling of JScrollPane Reviewed-by: serb, alexp --- .../swing/plaf/basic/BasicComboBoxUI.java | 22 +-- .../swing/plaf/basic/BasicComboPopup.java | 11 +- .../swing/JComboBox/8136998/bug8136998.java | 141 ++++++++++++++++++ 3 files changed, 153 insertions(+), 21 deletions(-) create mode 100644 jdk/test/javax/swing/JComboBox/8136998/bug8136998.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java index e08c8a3045f..b7f2ff6207b 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -150,8 +150,6 @@ public class BasicComboBoxUI extends ComboBoxUI { */ protected KeyListener popupKeyListener; - private MouseWheelListener mouseWheelListener; - // This is used for knowing when to cache the minimum preferred size. // If the data in the list changes, the cached value get marked for recalc. // Added to the current JComboBox model @@ -415,10 +413,6 @@ public class BasicComboBoxUI extends ComboBoxUI { comboBox.getModel().addListDataListener( listDataListener ); } } - - if ((mouseWheelListener = createMouseWheelListener()) != null) { - comboBox.addMouseWheelListener(mouseWheelListener); - } } /** @@ -465,9 +459,6 @@ public class BasicComboBoxUI extends ComboBoxUI { comboBox.getModel().removeListDataListener( listDataListener ); } } - if (mouseWheelListener != null) { - comboBox.removeMouseWheelListener(mouseWheelListener); - } } /** @@ -581,10 +572,6 @@ public class BasicComboBoxUI extends ComboBoxUI { return handler; } - private MouseWheelListener createMouseWheelListener() { - return getHandler(); - } - // // end UI Initialization //====================== @@ -1737,8 +1724,7 @@ public class BasicComboBoxUI extends ComboBoxUI { // private class Handler implements ActionListener, FocusListener, KeyListener, LayoutManager, - ListDataListener, PropertyChangeListener, - MouseWheelListener { + ListDataListener, PropertyChangeListener { // // PropertyChangeListener // @@ -2026,10 +2012,6 @@ public class BasicComboBoxUI extends ComboBoxUI { } } } - - public void mouseWheelMoved(MouseWheelEvent e) { - e.consume(); - } } class DefaultKeySelectionManager implements JComboBox.KeySelectionManager, UIResource { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java index 3b3d33cc9d7..63a54b7caa7 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -379,17 +379,26 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup { // PopupMenuListeners. protected void firePopupMenuWillBecomeVisible() { + if (scrollerMouseWheelListener != null) { + comboBox.addMouseWheelListener(scrollerMouseWheelListener); + } super.firePopupMenuWillBecomeVisible(); // comboBox.firePopupMenuWillBecomeVisible() is called from BasicComboPopup.show() method // to let the user change the popup menu from the PopupMenuListener.popupMenuWillBecomeVisible() } protected void firePopupMenuWillBecomeInvisible() { + if (scrollerMouseWheelListener != null) { + comboBox.removeMouseWheelListener(scrollerMouseWheelListener); + } super.firePopupMenuWillBecomeInvisible(); comboBox.firePopupMenuWillBecomeInvisible(); } protected void firePopupMenuCanceled() { + if (scrollerMouseWheelListener != null) { + comboBox.removeMouseWheelListener(scrollerMouseWheelListener); + } super.firePopupMenuCanceled(); comboBox.firePopupMenuCanceled(); } diff --git a/jdk/test/javax/swing/JComboBox/8136998/bug8136998.java b/jdk/test/javax/swing/JComboBox/8136998/bug8136998.java new file mode 100644 index 00000000000..e7d9e0ac465 --- /dev/null +++ b/jdk/test/javax/swing/JComboBox/8136998/bug8136998.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.WindowConstants; + +/* @test + * @bug 8136998 + * @summary Checks that JComboBox does not prevent mouse-wheel scrolling JScrollPane. + * @library ../../regtesthelpers + * @build Util + * @run main bug8136998 + * @author Alexey Ivanov + */ +public class bug8136998 { + + private static final String[] ITEMS = new String[] { + "A", "B", "C", "D", "E", "F" + }; + + private final Robot robot; + + private JFrame frame; + private JComboBox comboBox; + private JScrollPane scrollPane; + + public static void main(String[] args) throws Exception { + iterateLookAndFeels(new bug8136998()); + } + + protected static void iterateLookAndFeels(final bug8136998 test) throws Exception { + LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); + for (LookAndFeelInfo info : lafInfo) { + try { + UIManager.setLookAndFeel(info.getClassName()); + System.out.println("Look and Feel: " + info.getClassName()); + test.runTest(); + } catch (UnsupportedLookAndFeelException e) { + System.out.println("Skipping unsupported LaF: " + info); + } + } + } + + public bug8136998() throws AWTException { + robot = new Robot(); + robot.setAutoDelay(200); + } + + private void setupUI() { + frame = new JFrame(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + comboBox = new JComboBox<>(ITEMS); + + JPanel scrollable = new JPanel(); + scrollable.setLayout(new BoxLayout(scrollable, BoxLayout.Y_AXIS)); + + scrollable.add(Box.createVerticalStrut(200)); + scrollable.add(comboBox); + scrollable.add(Box.createVerticalStrut(200)); + + scrollPane = new JScrollPane(scrollable); + + frame.add(scrollPane); + + frame.setSize(100, 200); + frame.setVisible(true); + } + + public void runTest() throws Exception { + try { + SwingUtilities.invokeAndWait(this::setupUI); + + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> + scrollPane.getViewport().scrollRectToVisible(comboBox.getBounds()) + ); + robot.waitForIdle(); + + // Move mouse pointer to the center of the combo box + Point p = comboBox.getLocationOnScreen(); + Dimension d = comboBox.getSize(); + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + + // The currently visible rectangle in scrollPane + Rectangle viewRect0 = Util.invokeOnEDT(scrollPane.getViewport()::getViewRect); + + // Scroll the scrollPane with mouse wheel + robot.mouseWheel(1); + robot.waitForIdle(); + + // The updated rectangle + Rectangle viewRect1 = Util.invokeOnEDT(scrollPane.getViewport()::getViewRect); + + if (viewRect0.y == viewRect1.y) { + throw new RuntimeException("Mouse wheel should have scrolled the JScrollPane"); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + + System.out.println("Test passed"); + } +} From 49f26d74b4bc25d86a3fe980c3ef8b60e97c83c0 Mon Sep 17 00:00:00 2001 From: Mikhail Cherkasov Date: Wed, 18 May 2016 18:35:54 +0300 Subject: [PATCH 09/87] 6882559: new JEditorPane("text/plain","") fails for null context class loader Reviewed-by: serb, aivanov --- .../classes/javax/swing/JEditorPane.java | 8 ++-- .../swing/JEditorPane/6882559/bug6882559.java | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 jdk/test/javax/swing/JEditorPane/6882559/bug6882559.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java index 3211d572c1c..39e1312a545 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java @@ -1186,7 +1186,7 @@ public class JEditorPane extends JTextComponent { if (k == null) { // try to dynamically load the support String classname = getKitTypeRegistry().get(type); - ClassLoader loader = getKitLoaderRegistry().get(type); + ClassLoader loader = getKitLoaderRegistry().get(type).orElse(null); try { Class c; if (loader != null) { @@ -1243,7 +1243,7 @@ public class JEditorPane extends JTextComponent { */ public static void registerEditorKitForContentType(String type, String classname, ClassLoader loader) { getKitTypeRegistry().put(type, classname); - getKitLoaderRegistry().put(type, loader); + getKitLoaderRegistry().put(type, Optional.ofNullable(loader)); getKitRegisty().remove(type); } @@ -1268,10 +1268,10 @@ public class JEditorPane extends JTextComponent { return tmp; } - private static Hashtable getKitLoaderRegistry() { + private static Hashtable> getKitLoaderRegistry() { loadDefaultKitsIfNecessary(); @SuppressWarnings("unchecked") - Hashtable tmp = + Hashtable> tmp = (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey); return tmp; } diff --git a/jdk/test/javax/swing/JEditorPane/6882559/bug6882559.java b/jdk/test/javax/swing/JEditorPane/6882559/bug6882559.java new file mode 100644 index 00000000000..5bcd041aebd --- /dev/null +++ b/jdk/test/javax/swing/JEditorPane/6882559/bug6882559.java @@ -0,0 +1,41 @@ +/* + * 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 6882559 + @summary new JEditorPane("text/plain","") fails for null context class loader + @author Mikhail Cherkasov + @run main bug6882559 +*/ + +import javax.swing.*; + + +public class bug6882559 { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + Thread.currentThread().setContextClassLoader(null); + new javax.swing.JEditorPane("text/plain", ""); + }); + } +} From cc44b47d1862f5295917c77a06a605af6fd3a00b Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 18 May 2016 19:23:39 +0300 Subject: [PATCH 10/87] 8156894: Cleanup of sun.java2d.pipe.Region Reviewed-by: flar --- .../classes/sun/java2d/SunGraphics2D.java | 5 +- .../classes/sun/java2d/pipe/DrawImage.java | 10 +- .../share/classes/sun/java2d/pipe/Region.java | 138 ++++++------------ .../sun/java2d/pipe/ShapeSpanIterator.java | 4 +- 4 files changed, 53 insertions(+), 104 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java index 8207213e3e5..57b40d769d8 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1915,8 +1915,7 @@ public final class SunGraphics2D sr.setOutputArea(devClip); sr.appendPath(cpi); sr.getPathBox(box); - Region r = Region.getInstance(box); - r.appendSpans(sr); + Region r = Region.getInstance(box, sr); clipRegion = r; clipState = r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java index b1ebb0136e9..1c9665cf563 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -401,10 +401,10 @@ public class DrawImage implements DrawImagePipe } Region clip = sg.getCompClip(); - final int dx1 = Math.max((int) Math.floor(ddx1), clip.lox); - final int dy1 = Math.max((int) Math.floor(ddy1), clip.loy); - final int dx2 = Math.min((int) Math.ceil(ddx2), clip.hix); - final int dy2 = Math.min((int) Math.ceil(ddy2), clip.hiy); + final int dx1 = Math.max((int) Math.floor(ddx1), clip.getLoX()); + final int dy1 = Math.max((int) Math.floor(ddy1), clip.getLoY()); + final int dx2 = Math.min((int) Math.ceil(ddx2), clip.getHiX()); + final int dy2 = Math.min((int) Math.ceil(ddy2), clip.getHiY()); if (dx2 <= dx1 || dy2 <= dy1) { // empty destination means no output return; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java index 95a7aa46674..e78d5f7a482 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/Region.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,37 +62,21 @@ import sun.java2d.loops.TransformHelper; * bands[rowstart+3+N*2] = ... // start of next Y row * */ -public class Region { - static final int INIT_SIZE = 50; - static final int GROW_SIZE = 50; +public final class Region { + private static final int INIT_SIZE = 50; + private static final int GROW_SIZE = 50; - /** - * Immutable Region. - */ - private static final class ImmutableRegion extends Region { - protected ImmutableRegion(int lox, int loy, int hix, int hiy) { - super(lox, loy, hix, hiy); - } - - // Override all the methods that mutate the object - public void appendSpans(sun.java2d.pipe.SpanIterator si) {} - public void setOutputArea(java.awt.Rectangle r) {} - public void setOutputAreaXYWH(int x, int y, int w, int h) {} - public void setOutputArea(int[] box) {} - public void setOutputAreaXYXY(int lox, int loy, int hix, int hiy) {} - } - - public static final Region EMPTY_REGION = new ImmutableRegion(0, 0, 0, 0); - public static final Region WHOLE_REGION = new ImmutableRegion( + public static final Region EMPTY_REGION = new Region(0, 0, 0, 0); + public static final Region WHOLE_REGION = new Region( Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - int lox; - int loy; - int hix; - int hiy; + private int lox; + private int loy; + private int hix; + private int hiy; int endIndex; int[] bands; @@ -155,7 +139,7 @@ public class Region { return (int) Math.round(newv); } - protected Region(int lox, int loy, int hix, int hiy) { + private Region(int lox, int loy, int hix, int hiy) { this.lox = lox; this.loy = loy; this.hix = hix; @@ -258,9 +242,7 @@ public class Region { sr.setOutputArea(devBounds); sr.appendPath(s.getPathIterator(at)); sr.getPathBox(box); - Region r = Region.getInstance(box); - r.appendSpans(sr); - return r; + return Region.getInstance(box, sr); } finally { sr.dispose(); } @@ -349,56 +331,18 @@ public class Region { } /** - * Sets the rectangle of interest for storing and returning - * region bands. - *

- * This method can also be used to initialize a simple rectangular - * region. + * Returns a Region object with a rectangle of interest specified by the + * indicated rectangular area in lox, loy, hix, hiy format. + *

+ * Appends the list of spans returned from the indicated SpanIterator. Each + * span must be at a higher starting Y coordinate than the previous data or + * it must have a Y range equal to the highest Y band in the region and a + * higher X coordinate than any of the spans in that band. */ - public void setOutputArea(Rectangle r) { - setOutputAreaXYWH(r.x, r.y, r.width, r.height); - } - - /** - * Sets the rectangle of interest for storing and returning - * region bands. The rectangle is specified in x, y, width, height - * format and appropriate clipping is performed as per the method - * {@code dimAdd}. - *

- * This method can also be used to initialize a simple rectangular - * region. - */ - public void setOutputAreaXYWH(int x, int y, int w, int h) { - setOutputAreaXYXY(x, y, dimAdd(x, w), dimAdd(y, h)); - } - - /** - * Sets the rectangle of interest for storing and returning - * region bands. The rectangle is specified as a span array. - *

- * This method can also be used to initialize a simple rectangular - * region. - */ - public void setOutputArea(int box[]) { - this.lox = box[0]; - this.loy = box[1]; - this.hix = box[2]; - this.hiy = box[3]; - } - - /** - * Sets the rectangle of interest for storing and returning - * region bands. The rectangle is specified in lox, loy, - * hix, hiy format. - *

- * This method can also be used to initialize a simple rectangular - * region. - */ - public void setOutputAreaXYXY(int lox, int loy, int hix, int hiy) { - this.lox = lox; - this.loy = loy; - this.hix = hix; - this.hiy = hiy; + public static Region getInstance(int box[], SpanIterator si) { + Region ret = new Region(box[0], box[1], box[2], box[3]); + ret.appendSpans(si); + return ret; } /** @@ -408,7 +352,7 @@ public class Region { * Y range equal to the highest Y band in the region and a * higher X coordinate than any of the spans in that band. */ - public void appendSpans(SpanIterator si) { + private void appendSpans(SpanIterator si) { int[] box = new int[6]; while (si.nextSpan(box)) { @@ -739,9 +683,9 @@ public class Region { return ret; } - static final int INCLUDE_A = 1; - static final int INCLUDE_B = 2; - static final int INCLUDE_COMMON = 4; + private static final int INCLUDE_A = 1; + private static final int INCLUDE_B = 2; + private static final int INCLUDE_COMMON = 4; private void filterSpans(Region ra, Region rb, int flags) { int abands[] = ra.bands; @@ -1080,35 +1024,35 @@ public class Region { /** * Returns the lowest X coordinate in the Region. */ - public final int getLoX() { + public int getLoX() { return lox; } /** * Returns the lowest Y coordinate in the Region. */ - public final int getLoY() { + public int getLoY() { return loy; } /** * Returns the highest X coordinate in the Region. */ - public final int getHiX() { + public int getHiX() { return hix; } /** * Returns the highest Y coordinate in the Region. */ - public final int getHiY() { + public int getHiY() { return hiy; } /** * Returns the width of this Region clipped to the range (0 - MAX_INT). */ - public final int getWidth() { + public int getWidth() { if (hix < lox) return 0; int w; if ((w = hix - lox) < 0) { @@ -1120,7 +1064,7 @@ public class Region { /** * Returns the height of this Region clipped to the range (0 - MAX_INT). */ - public final int getHeight() { + public int getHeight() { if (hiy < loy) return 0; int h; if ((h = hiy - loy) < 0) { @@ -1325,6 +1269,7 @@ public class Region { return si; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Region[["); @@ -1335,13 +1280,13 @@ public class Region { sb.append(hix); sb.append(", "); sb.append(hiy); - sb.append("]"); + sb.append(']'); if (bands != null) { int col = 0; while (col < endIndex) { sb.append("y{"); sb.append(bands[col++]); - sb.append(","); + sb.append(','); sb.append(bands[col++]); sb.append("}["); int end = bands[col++]; @@ -1351,20 +1296,25 @@ public class Region { sb.append(bands[col++]); sb.append(", "); sb.append(bands[col++]); - sb.append(")"); + sb.append(')'); } - sb.append("]"); + sb.append(']'); } } - sb.append("]"); + sb.append(']'); return sb.toString(); } + @Override public int hashCode() { return (isEmpty() ? 0 : (lox * 3 + loy * 5 + hix * 7 + hiy * 9)); } + @Override public boolean equals(Object o) { + if (this == o) { + return true; + } if (!(o instanceof Region)) { return false; } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/ShapeSpanIterator.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/ShapeSpanIterator.java index 0ccf594af7d..57477190483 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/ShapeSpanIterator.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/ShapeSpanIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,7 +131,7 @@ public final class ShapeSpanIterator * span segments to the bounds of the specified Region. */ public void setOutputArea(Region r) { - setOutputAreaXYXY(r.lox, r.loy, r.hix, r.hiy); + setOutputAreaXYXY(r.getLoX(), r.getLoY(), r.getHiX(), r.getHiY()); } /* From 3179e6a792bd01c68e93784a04d3f5bc291c86ab Mon Sep 17 00:00:00 2001 From: Daniil Titov Date: Mon, 16 May 2016 22:57:40 -0700 Subject: [PATCH 11/87] 8155785: Add @Deprecated annotations to the Applet API classes Reviewed-by: smarks, serb --- .../java.desktop/share/classes/java/applet/Applet.java | 8 +++++++- .../share/classes/java/applet/AppletContext.java | 8 +++++++- .../share/classes/java/applet/AppletStub.java | 8 +++++++- .../java.desktop/share/classes/java/applet/AudioClip.java | 8 +++++++- .../java.desktop/share/classes/java/applet/package.html | 5 +++++ .../java.desktop/share/classes/javax/swing/JApplet.java | 8 +++++++- .../netscape/javascript/spi/JSObjectProvider.java | 1 + .../share/classes/netscape/javascript/JSObject.java | 1 + 8 files changed, 42 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/applet/Applet.java b/jdk/src/java.desktop/share/classes/java/applet/Applet.java index 0e02c9cb054..a8430a76e99 100644 --- a/jdk/src/java.desktop/share/classes/java/applet/Applet.java +++ b/jdk/src/java.desktop/share/classes/java/applet/Applet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,13 @@ import javax.accessibility.*; * @author Arthur van Hoff * @author Chris Warth * @since 1.0 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package documentation + * for further information. */ + +@Deprecated(since = "9") public class Applet extends Panel { /** diff --git a/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java b/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java index 7caae99949d..3863aedb0e3 100644 --- a/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java +++ b/jdk/src/java.desktop/share/classes/java/applet/AppletContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,13 @@ import java.util.Iterator; * * @author Arthur van Hoff * @since 1.0 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package documentation + * for further information. */ + +@Deprecated(since = "9") public interface AppletContext { /** * Creates an audio clip. diff --git a/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java b/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java index 7a7e614536a..1f4e39b8060 100644 --- a/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java +++ b/jdk/src/java.desktop/share/classes/java/applet/AppletStub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,13 @@ import java.net.URL; * @author Arthur van Hoff * @see java.applet.Applet#setStub(java.applet.AppletStub) * @since 1.0 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package documentation + * for further information. */ + +@Deprecated(since = "9") public interface AppletStub { /** * Determines if the applet is active. An applet is active just diff --git a/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java b/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java index f935fa4965b..6436ccbcc5d 100644 --- a/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java +++ b/jdk/src/java.desktop/share/classes/java/applet/AudioClip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,13 @@ package java.applet; * * @author Arthur van Hoff * @since 1.0 + * + * @deprecated The Applet API is deprecated. See the + * java.applet package documentation + * for further information. */ + +@Deprecated(since = "9") public interface AudioClip { /** * Starts playing this audio clip. Each time this method is called, diff --git a/jdk/src/java.desktop/share/classes/java/applet/package.html b/jdk/src/java.desktop/share/classes/java/applet/package.html index 3315f292594..a95395b900e 100644 --- a/jdk/src/java.desktop/share/classes/java/applet/package.html +++ b/jdk/src/java.desktop/share/classes/java/applet/package.html @@ -39,6 +39,11 @@ The applet context is an application that is responsible for loading and running applets. For example, the applet context could be a Web browser or an applet development environment.

+The APIs in this package are all deprecated. Alternative technologies such as Java Web Start +or installable applications should be used instead. See JEP 289 +and the Oracle White Paper +"Migrating from Java Applets to plugin-free Java technologies" for more information. +