From b75b83da3e089598067d43f6b0200310791a4604 Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Thu, 4 Jul 2013 16:06:11 +0400 Subject: [PATCH 01/10] 8015730: PIT: On Linux, OGL=true and fbobject=false leads to deadlock or infinite loop Reviewed-by: art, anthony --- .../classes/sun/awt/X11/XErrorHandlerUtil.java | 8 +++++++- jdk/src/solaris/native/sun/awt/awt_util.h | 18 ++++++++++++++---- .../native/sun/java2d/opengl/GLXSurfaceData.c | 10 ++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XErrorHandlerUtil.java b/jdk/src/solaris/classes/sun/awt/X11/XErrorHandlerUtil.java index e45f67ffde9..da12cd9ef89 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XErrorHandlerUtil.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XErrorHandlerUtil.java @@ -105,9 +105,15 @@ public final class XErrorHandlerUtil { * Unsets a current synthetic error handler. Must be called with the acquired AWT lock. */ public static void RESTORE_XERROR_HANDLER() { + RESTORE_XERROR_HANDLER(true); + } + + private static void RESTORE_XERROR_HANDLER(boolean doXSync) { // Wait until all requests are processed by the X server // and only then uninstall the error handler. - XSync(); + if (doXSync) { + XSync(); + } current_error_handler = null; } diff --git a/jdk/src/solaris/native/sun/awt/awt_util.h b/jdk/src/solaris/native/sun/awt/awt_util.h index 6e350727806..b93f7744cd6 100644 --- a/jdk/src/solaris/native/sun/awt/awt_util.h +++ b/jdk/src/solaris/native/sun/awt/awt_util.h @@ -46,11 +46,11 @@ /* * Expected types of arguments of the macro. - * (JNIEnv*) + * (JNIEnv*, jboolean) */ -#define RESTORE_XERROR_HANDLER(env) do { \ +#define RESTORE_XERROR_HANDLER(env, doXSync) do { \ JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \ - "RESTORE_XERROR_HANDLER", "()V"); \ + "RESTORE_XERROR_HANDLER", "(Z)V", doXSync); \ } while (0) /* @@ -64,8 +64,18 @@ do { \ code; \ } while (0); \ - RESTORE_XERROR_HANDLER(env); \ + RESTORE_XERROR_HANDLER(env, JNI_TRUE); \ if (handlerHasFlag == JNI_TRUE) { \ + GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag); \ + } \ +} while (0) + +/* + * Expected types of arguments of the macro. + * (JNIEnv*, jobject, jboolean) + */ +#define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag) do { \ + if (handlerRef != NULL) { \ errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", \ "()Z").z; \ } \ diff --git a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c index 4a4e75f6228..e1cf2c57501 100644 --- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c @@ -392,10 +392,12 @@ Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer attrlist[3] = height; errorOccurredFlag = JNI_FALSE; - EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler", - "()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE, - errorHandlerRef, errorOccurredFlag, - pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist)); + WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler", + "()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE, errorHandlerRef); + pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist); + XSync(awt_display, False); + RESTORE_XERROR_HANDLER(env, JNI_FALSE); + GET_HANDLER_ERROR_OCCURRED_FLAG(env, errorHandlerRef, errorOccurredFlag); if ((pbuffer == 0) || errorOccurredFlag) { J2dRlsTraceLn(J2D_TRACE_ERROR, From 007e944455c195c9a82efb6f3b61e9b2a2b42ad5 Mon Sep 17 00:00:00 2001 From: Leonid Romanov Date: Mon, 8 Jul 2013 19:47:40 +0400 Subject: [PATCH 02/10] 8019265: [macosx] apple.laf.useScreenMenuBar regression comparing with jdk6 Reviewed-by: anthony --- jdk/src/macosx/native/sun/awt/CMenuItem.m | 9 +++++++-- .../ActionListenerCalledTwiceTest.java | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jdk/src/macosx/native/sun/awt/CMenuItem.m b/jdk/src/macosx/native/sun/awt/CMenuItem.m index eaabb3e06ab..0d1ade68ab6 100644 --- a/jdk/src/macosx/native/sun/awt/CMenuItem.m +++ b/jdk/src/macosx/native/sun/awt/CMenuItem.m @@ -82,8 +82,13 @@ JNF_COCOA_ENTER(env); // keys, so we need to do the same translation here that we do // for the regular key down events if ([eventKey length] == 1) { - unichar ch = NsCharToJavaChar([eventKey characterAtIndex:0], 0); - eventKey = [NSString stringWithCharacters: &ch length: 1]; + unichar origChar = [eventKey characterAtIndex:0]; + unichar newChar = NsCharToJavaChar(origChar, 0); + if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) { + newChar = origChar; + } + + eventKey = [NSString stringWithCharacters: &newChar length: 1]; } if ([menuKey isEqualToString:eventKey]) { diff --git a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java index 4cf1c750da5..d9cedf423e6 100644 --- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java +++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java @@ -35,10 +35,11 @@ import java.awt.event.*; import javax.swing.*; public class ActionListenerCalledTwiceTest { - static String menuItems[] = { "Item1", "Item2" }; + static String menuItems[] = { "Item1", "Item2", "Item3" }; static KeyStroke keyStrokes[] = { KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK), - KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0) + KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), + KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK), }; static volatile int listenerCallCounter = 0; From 25f2802a700401be280e360238aceec9da874db8 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 9 Jul 2013 18:01:58 +0400 Subject: [PATCH 03/10] 6707231: Wrong read Method returned for boolen properties Reviewed-by: alexsch --- .../classes/java/beans/Introspector.java | 5 +- .../java/beans/Introspector/Test6707231.java | 80 +++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/beans/Introspector/Test6707231.java diff --git a/jdk/src/share/classes/java/beans/Introspector.java b/jdk/src/share/classes/java/beans/Introspector.java index 65d95eb4e80..783fcbef315 100644 --- a/jdk/src/share/classes/java/beans/Introspector.java +++ b/jdk/src/share/classes/java/beans/Introspector.java @@ -652,11 +652,12 @@ public class Introspector { } } else { if (pd.getReadMethod() != null) { + String pdName = pd.getReadMethod().getName(); if (gpd != null) { // Don't replace the existing read // method if it starts with "is" - Method method = gpd.getReadMethod(); - if (!method.getName().startsWith(IS_PREFIX)) { + String gpdName = gpd.getReadMethod().getName(); + if (gpdName.equals(pdName) || !gpdName.startsWith(IS_PREFIX)) { gpd = new PropertyDescriptor(gpd, pd); } } else { diff --git a/jdk/test/java/beans/Introspector/Test6707231.java b/jdk/test/java/beans/Introspector/Test6707231.java new file mode 100644 index 00000000000..67f935d6ec1 --- /dev/null +++ b/jdk/test/java/beans/Introspector/Test6707231.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2013, 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.beans.PropertyDescriptor; + +/* + * @test + * @bug 6707231 + * @summary Tests the boolean getter + * @author Sergey Malenkov + */ + +public class Test6707231 { + public static void main(String[] args) throws Exception { + test(Bean.class, Bean.class); + test(Public.class, Public.class); + test(Private.class, Bean.class); + } + + public static class Bean { + private boolean value; + + public boolean isValue() { + return this.value; + } + + public void setValue(boolean value) { + this.value = value; + } + } + + public static class Public extends Bean { + public boolean isValue() { + return super.isValue(); + } + + public void setValue(boolean value) { + super.setValue(value); + } + } + + private static class Private extends Bean { + public boolean isValue() { + return super.isValue(); + } + + public void setValue(boolean value) { + super.setValue(value); + } + } + + private static void test(Class actual, Class expected) { + PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(actual, "value"); + Class getter = pd.getReadMethod().getDeclaringClass(); + Class setter = pd.getWriteMethod().getDeclaringClass(); + if ((getter != expected) || (setter != expected)) { + throw new Error(actual.getName()); + } + } +} From b2b2d519cafa52436bd15425cd9592991a1d2b69 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 9 Jul 2013 21:21:55 +0400 Subject: [PATCH 04/10] 8019587: [macosx] Possibility to set the same frame for the different screens Reviewed-by: art, anthony --- .../classes/java/awt/GraphicsDevice.java | 6 ++ .../IncorrectDisplayModeExitFullscreen.java | 94 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java diff --git a/jdk/src/share/classes/java/awt/GraphicsDevice.java b/jdk/src/share/classes/java/awt/GraphicsDevice.java index b99d7ef8def..c619a2aee19 100644 --- a/jdk/src/share/classes/java/awt/GraphicsDevice.java +++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java @@ -296,6 +296,12 @@ public abstract class GraphicsDevice { bgColor.getBlue(), 255); w.setBackground(bgColor); } + // Check if this window is in fullscreen mode on another device. + final GraphicsConfiguration gc = w.getGraphicsConfiguration(); + if (gc != null && gc.getDevice() != this + && gc.getDevice().getFullScreenWindow() == w) { + gc.getDevice().setFullScreenWindow(null); + } } if (fullScreenWindow != null && windowedModeBounds != null) { // if the window went into fs mode before it was realized it may diff --git a/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java b/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java new file mode 100644 index 00000000000..1d42db8f47d --- /dev/null +++ b/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.awt.Color; +import java.awt.DisplayMode; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; + +import sun.awt.SunToolkit; + +/** + * @test + * @bug 8019587 + * @author Sergey Bylokhov + */ +public class IncorrectDisplayModeExitFullscreen { + + public static void main(final String[] args) { + + final GraphicsDevice[] devices = + GraphicsEnvironment.getLocalGraphicsEnvironment() + .getScreenDevices(); + if (devices.length < 2 || devices[0].getDisplayModes().length < 2 + || !devices[0].isFullScreenSupported() + || !devices[1].isFullScreenSupported()) { + System.err.println("Testcase is not applicable"); + return; + } + final DisplayMode defaultDM = devices[0].getDisplayMode(); + final DisplayMode[] dms = devices[0].getDisplayModes(); + DisplayMode nonDefaultDM = null; + + for (final DisplayMode dm : dms) { + if (!dm.equals(defaultDM)) { + nonDefaultDM = dm; + break; + } + } + if (nonDefaultDM == null) { + System.err.println("Testcase is not applicable"); + return; + } + + final Frame frame = new Frame(); + frame.setBackground(Color.GREEN); + frame.setUndecorated(true); + try { + devices[0].setFullScreenWindow(frame); + sleep(); + devices[0].setDisplayMode(nonDefaultDM); + sleep(); + devices[1].setFullScreenWindow(frame); + sleep(); + if (!defaultDM.equals(devices[0].getDisplayMode())) { + throw new RuntimeException("DisplayMode is not restored"); + } + } finally { + // cleaning up + devices[0].setFullScreenWindow(null); + devices[1].setFullScreenWindow(null); + frame.dispose(); + } + } + private static void sleep() { + ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + try { + Thread.sleep(1500); + } catch (InterruptedException ignored) { + } + } +} From f22f9eb04b4f8b9e0b2b3c7c3a756664ed1d15ee Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Thu, 11 Jul 2013 16:42:13 +0400 Subject: [PATCH 05/10] 8020210: [macosx] JVM crashes in CWrapper$NSWindow.screen(long) Reviewed-by: anthony, art --- .../sun/lwawt/macosx/CPlatformWindow.java | 22 ++-- .../classes/sun/lwawt/macosx/CWrapper.java | 8 -- jdk/src/macosx/native/sun/awt/CWrapper.m | 111 ------------------ .../MaximizeOffscreenTest.java | 67 +++++++++++ 4 files changed, 76 insertions(+), 132 deletions(-) create mode 100644 jdk/test/java/awt/Window/MaximizeOffscreen/MaximizeOffscreenTest.java diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 7230b2eeeb5..dc711c28f0e 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -479,12 +479,14 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo deliverZoom(true); this.normalBounds = peer.getBounds(); - long screen = CWrapper.NSWindow.screen(getNSWindowPtr()); - Rectangle toBounds = CWrapper.NSScreen.visibleFrame(screen).getBounds(); - // Flip the y coordinate - Rectangle frame = CWrapper.NSScreen.frame(screen).getBounds(); - toBounds.y = frame.height - toBounds.y - toBounds.height; - setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height); + + GraphicsConfiguration config = getPeer().getGraphicsConfiguration(); + Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets(); + Rectangle toBounds = config.getBounds(); + setBounds(toBounds.x + i.left, + toBounds.y + i.top, + toBounds.width - i.left - i.right, + toBounds.height - i.top - i.bottom); } } @@ -751,13 +753,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // the move/size notification from the underlying system comes // but it contains a bounds smaller than the whole screen // and therefore we need to create the synthetic notifications - Rectangle screenBounds; - final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr()); - try { - screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds(); - } finally { - CWrapper.NSObject.release(screenPtr); - } + Rectangle screenBounds = getPeer().getGraphicsConfiguration().getBounds(); peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height); } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java index 67d3ea1cf1f..7dc421e26b1 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CWrapper.java @@ -71,8 +71,6 @@ public final class CWrapper { public static native void zoom(long window); public static native void makeFirstResponder(long window, long responder); - - public static native long screen(long window); } public static final class NSView { @@ -95,12 +93,6 @@ public final class CWrapper { public static native void release(long object); } - public static final class NSScreen { - public static native Rectangle2D frame(long screen); - public static native Rectangle2D visibleFrame(long screen); - public static native long screenByDisplayId(int displayID); - } - public static final class NSColor { public static native long clearColor(); } diff --git a/jdk/src/macosx/native/sun/awt/CWrapper.m b/jdk/src/macosx/native/sun/awt/CWrapper.m index bef1d47cb9f..ccc688e802d 100644 --- a/jdk/src/macosx/native/sun/awt/CWrapper.m +++ b/jdk/src/macosx/native/sun/awt/CWrapper.m @@ -396,31 +396,6 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } -/* - * Class: sun_lwawt_macosx_CWrapper$NSWindow - * Method: screen - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSWindow_screen -(JNIEnv *env, jclass cls, jlong windowPtr) -{ - __block jlong screenPtr = 0L; - -JNF_COCOA_ENTER(env); - - AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - const NSScreen *screen = [window screen]; - CFRetain(screen); // GC - screenPtr = ptr_to_jlong(screen); - }]; - -JNF_COCOA_EXIT(env); - - return screenPtr; -} - /* * Method: miniaturize * Signature: (J)V @@ -690,92 +665,6 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } - -/* - * Class: sun_lwawt_macosx_CWrapper$NSScreen - * Method: frame - * Signature: (J)Ljava/awt/Rectangle; - */ -JNIEXPORT jobject JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSScreen_frame -(JNIEnv *env, jclass cls, jlong screenPtr) -{ - jobject jRect = NULL; - -JNF_COCOA_ENTER(env); - - __block NSRect rect = NSZeroRect; - - NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr); - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - rect = [screen frame]; - }]; - - jRect = NSToJavaRect(env, rect); - -JNF_COCOA_EXIT(env); - - return jRect; -} - -/* - * Class: sun_lwawt_macosx_CWrapper_NSScreen - * Method: visibleFrame - * Signature: (J)Ljava/awt/geom/Rectangle2D; - */ -JNIEXPORT jobject JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSScreen_visibleFrame -(JNIEnv *env, jclass cls, jlong screenPtr) -{ - jobject jRect = NULL; - -JNF_COCOA_ENTER(env); - - __block NSRect rect = NSZeroRect; - - NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr); - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - rect = [screen visibleFrame]; - }]; - - jRect = NSToJavaRect(env, rect); - -JNF_COCOA_EXIT(env); - - return jRect; -} - -/* - * Class: sun_lwawt_macosx_CWrapper_NSScreen - * Method: screenByDisplayId - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_sun_lwawt_macosx_CWrapper_00024NSScreen_screenByDisplayId -(JNIEnv *env, jclass cls, jint displayID) -{ - __block jlong screenPtr = 0L; - -JNF_COCOA_ENTER(env); - - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - NSArray *screens = [NSScreen screens]; - for (NSScreen *screen in screens) { - NSDictionary *screenInfo = [screen deviceDescription]; - NSNumber *screenID = [screenInfo objectForKey:@"NSScreenNumber"]; - if ([screenID intValue] == displayID){ - CFRetain(screen); // GC - screenPtr = ptr_to_jlong(screen); - break; - } - } - }]; - -JNF_COCOA_EXIT(env); - - return screenPtr; -} - /* * Class: sun_lwawt_macosx_CWrapper$NSColor * Method: clearColor diff --git a/jdk/test/java/awt/Window/MaximizeOffscreen/MaximizeOffscreenTest.java b/jdk/test/java/awt/Window/MaximizeOffscreen/MaximizeOffscreenTest.java new file mode 100644 index 00000000000..014637acec0 --- /dev/null +++ b/jdk/test/java/awt/Window/MaximizeOffscreen/MaximizeOffscreenTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013, 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 @summary JVM crash if the frame maximized from offscreen + * @author Petr Pchelko + * @library ../../regtesthelpers + * @build Util + * @compile MaximizeOffscreenTest.java + * @run main/othervm MaximizeOffscreenTest + */ + +import test.java.awt.regtesthelpers.Util; + +import javax.swing.*; +import java.awt.*; + +public class MaximizeOffscreenTest { + + private static JFrame frame; + + public static void main(String[] args) throws Throwable { + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + constructTestUI(); + } + }); + + Util.waitForIdle(null); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.setExtendedState(Frame.MAXIMIZED_BOTH); + } + }); + Util.waitForIdle(null); + } + + private static void constructTestUI() { + frame = new JFrame("Test frame"); + frame.setUndecorated(true); + frame.setBounds(-1000, -1000, 100, 100); + frame.setVisible(true); + } +} From b3a5f0ec3878822c8c23d0c183702d7ce8d50217 Mon Sep 17 00:00:00 2001 From: Leonid Romanov Date: Thu, 11 Jul 2013 18:23:15 +0400 Subject: [PATCH 06/10] 8020038: [macosx] Incorrect usage of invokeLater() and likes in callbacks called via JNI from AppKit thread Reviewed-by: art, anthony --- .../com/apple/eawt/FullScreenHandler.java | 3 +- .../com/apple/eawt/_AppEventHandler.java | 100 ++++++++++++------ .../com/apple/eawt/event/GestureHandler.java | 4 +- .../classes/com/apple/laf/ScreenMenu.java | 9 +- .../sun/lwawt/macosx/CCheckboxMenuItem.java | 4 +- .../sun/lwawt/macosx/CViewEmbeddedFrame.java | 4 +- 6 files changed, 80 insertions(+), 44 deletions(-) diff --git a/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java b/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java index f5a843bcdbf..64e81b08a00 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/FullScreenHandler.java @@ -32,6 +32,7 @@ import java.util.List; import javax.swing.RootPaneContainer; import com.apple.eawt.AppEvent.FullScreenEvent; +import sun.awt.SunToolkit; import java.lang.annotation.Native; @@ -75,7 +76,7 @@ final class FullScreenHandler { static void handleFullScreenEventFromNative(final Window window, final int type) { if (!(window instanceof RootPaneContainer)) return; // handles null - EventQueue.invokeLater(new Runnable() { + SunToolkit.executeOnEventHandlerThread(window, new Runnable() { public void run() { final FullScreenHandler handler = getHandlerFor((RootPaneContainer)window); if (handler != null) handler.notifyListener(new FullScreenEvent(window), type); diff --git a/jdk/src/macosx/classes/com/apple/eawt/_AppEventHandler.java b/jdk/src/macosx/classes/com/apple/eawt/_AppEventHandler.java index a380e8412fd..b98d5739510 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/_AppEventHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/_AppEventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import java.io.File; import java.net.*; import java.util.*; import java.util.List; +import sun.awt.AppContext; +import sun.awt.SunToolkit; import com.apple.eawt.AppEvent.*; @@ -269,11 +271,9 @@ class _AppEventHandler { } class _AppReOpenedDispatcher extends _AppEventMultiplexor { - void performOnListeners(final List listeners, final _NativeEvent event) { + void performOnListener(AppReOpenedListener listener, final _NativeEvent event) { final AppReOpenedEvent e = new AppReOpenedEvent(); - for (final AppReOpenedListener listener : listeners) { - listener.appReOpened(e); - } + listener.appReOpened(e); } } @@ -415,50 +415,67 @@ class _AppEventHandler { } abstract class _AppEventMultiplexor { - final List _listeners = new ArrayList(0); + private final Map listenerToAppContext = + new IdentityHashMap(); boolean nativeListenerRegistered; // called from AppKit Thread-0 void dispatch(final _NativeEvent event, final Object... args) { - // grab a local ref to the listeners - final List localListeners; + // grab a local ref to the listeners and its contexts as an array of the map's entries + final ArrayList> localEntries; synchronized (this) { - if (_listeners.size() == 0) return; - localListeners = new ArrayList(_listeners); + if (listenerToAppContext.size() == 0) { + return; + } + localEntries = new ArrayList>(listenerToAppContext.size()); + localEntries.addAll(listenerToAppContext.entrySet()); } - EventQueue.invokeLater(new Runnable() { - public void run() { - performOnListeners(localListeners, event); - } - }); + for (final Map.Entry e : localEntries) { + final L listener = e.getKey(); + final AppContext listenerContext = e.getValue(); + SunToolkit.invokeLaterOnAppContext(listenerContext, new Runnable() { + public void run() { + performOnListener(listener, event); + } + }); + } } synchronized void addListener(final L listener) { + setListenerContext(listener, AppContext.getAppContext()); + if (!nativeListenerRegistered) { registerNativeListener(); nativeListenerRegistered = true; } - _listeners.add(listener); } synchronized void removeListener(final L listener) { - _listeners.remove(listener); + listenerToAppContext.remove(listener); } - abstract void performOnListeners(final List listeners, final _NativeEvent event); + abstract void performOnListener(L listener, final _NativeEvent event); void registerNativeListener() { } + + private void setListenerContext(L listener, AppContext listenerContext) { + if (listenerContext == null) { + throw new RuntimeException( + "Attempting to add a listener from a thread group without AppContext"); + } + listenerToAppContext.put(listener, AppContext.getAppContext()); + } } abstract class _BooleanAppEventMultiplexor extends _AppEventMultiplexor { @Override - void performOnListeners(final List listeners, final _NativeEvent event) { + void performOnListener(L listener, final _NativeEvent event) { final boolean isTrue = Boolean.TRUE.equals(event.get(0)); final E e = createEvent(isTrue); if (isTrue) { - for (final L listener : listeners) performTrueEventOn(listener, e); + performTrueEventOn(listener, e); } else { - for (final L listener : listeners) performFalseEventOn(listener, e); + performFalseEventOn(listener, e); } } @@ -479,30 +496,34 @@ class _AppEventHandler { */ abstract class _AppEventDispatcher { H _handler; + AppContext handlerContext; // called from AppKit Thread-0 void dispatch(final _NativeEvent event) { - EventQueue.invokeLater(new Runnable() { - public void run() { - // grab a local ref to the handler - final H localHandler; - synchronized (_AppEventDispatcher.this) { - localHandler = _handler; - } + // grab a local ref to the handler + final H localHandler; + final AppContext localHandlerContext; + synchronized (_AppEventDispatcher.this) { + localHandler = _handler; + localHandlerContext = handlerContext; + } - // invoke the handler outside of the synchronized block - if (localHandler == null) { - performDefaultAction(event); - } else { + if (localHandler == null) { + performDefaultAction(event); + } else { + SunToolkit.invokeLaterOnAppContext(localHandlerContext, new Runnable() { + public void run() { performUsing(localHandler, event); } - } - }); + }); + } } synchronized void setHandler(final H handler) { this._handler = handler; + setHandlerContext(AppContext.getAppContext()); + // if a new handler is installed, block addition of legacy ApplicationListeners if (handler == legacyHandler) return; legacyHandler.blockLegacyAPI(); @@ -510,6 +531,15 @@ class _AppEventHandler { void performDefaultAction(final _NativeEvent event) { } // by default, do nothing abstract void performUsing(final H handler, final _NativeEvent event); + + protected void setHandlerContext(AppContext ctx) { + if (ctx == null) { + throw new RuntimeException( + "Attempting to set a handler from a thread group without AppContext"); + } + + handlerContext = ctx; + } } abstract class _QueuingAppEventDispatcher extends _AppEventDispatcher { @@ -531,6 +561,8 @@ class _AppEventHandler { synchronized void setHandler(final H handler) { this._handler = handler; + setHandlerContext(AppContext.getAppContext()); + // dispatch any events in the queue if (queuedEvents != null) { // grab a local ref to the queue, so the real one can be nulled out diff --git a/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java b/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java index 1378a2c808e..4514da90ca9 100644 --- a/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java +++ b/jdk/src/macosx/classes/com/apple/eawt/event/GestureHandler.java @@ -25,6 +25,8 @@ package com.apple.eawt.event; +import sun.awt.SunToolkit; + import java.awt.*; import java.util.*; import java.util.List; @@ -70,7 +72,7 @@ final class GestureHandler { static void handleGestureFromNative(final Window window, final int type, final double x, final double y, final double a, final double b) { if (window == null) return; // should never happen... - EventQueue.invokeLater(new Runnable() { + SunToolkit.executeOnEventHandlerThread(window, new Runnable() { public void run() { final Component component = SwingUtilities.getDeepestComponentAt(window, (int)x, (int)y); diff --git a/jdk/src/macosx/classes/com/apple/laf/ScreenMenu.java b/jdk/src/macosx/classes/com/apple/laf/ScreenMenu.java index 23c55c8d2a1..5f78ff6e061 100644 --- a/jdk/src/macosx/classes/com/apple/laf/ScreenMenu.java +++ b/jdk/src/macosx/classes/com/apple/laf/ScreenMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -32,6 +32,7 @@ import java.util.Hashtable; import javax.swing.*; +import sun.awt.SunToolkit; import sun.lwawt.LWToolkit; import sun.lwawt.macosx.*; @@ -144,7 +145,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S updateItems(); fItemBounds = new Rectangle[invoker.getMenuComponentCount()]; } - }, null); + }, invoker); } catch (final Exception e) { System.err.println(e); e.printStackTrace(); @@ -172,7 +173,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S fItemBounds = null; } - }, null); + }, invoker); } catch (final Exception e) { e.printStackTrace(); } @@ -200,7 +201,7 @@ class ScreenMenu extends Menu implements ContainerListener, ComponentListener, S if (kind == 0) return; if (fItemBounds == null) return; - SwingUtilities.invokeLater(new Runnable() { + SunToolkit.executeOnEventHandlerThread(fInvoker, new Runnable() { @Override public void run() { Component target = null; diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java index 9b59ceaef9b..da53c302ad5 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CCheckboxMenuItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, 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 @@ -53,7 +53,7 @@ public class CCheckboxMenuItem extends CMenuItem implements CheckboxMenuItemPeer public void handleAction(final boolean state) { final CheckboxMenuItem target = (CheckboxMenuItem)getTarget(); - EventQueue.invokeLater(new Runnable() { + SunToolkit.executeOnEventHandlerThread(target, new Runnable() { public void run() { target.setState(state); } diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java index 306cfb1e12e..28acc26f6cc 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -96,7 +96,7 @@ public class CViewEmbeddedFrame extends EmbeddedFrame { validate(); setVisible(true); } - }, null); + }, this); } catch (InterruptedException | InvocationTargetException ex) {} } } From 2a2bf1051b55d67b3bc65dd7b6c6f4c01056c993 Mon Sep 17 00:00:00 2001 From: Ragini Prasad Date: Fri, 12 Jul 2013 14:46:21 +0400 Subject: [PATCH 07/10] 8009168: accessibility.properties syntax issue Reviewed-by: ptbrunet, mfang, alexsch --- .../accessibility/internal/resources/accessibility.properties | 2 +- .../internal/resources/accessibility_de.properties | 2 +- .../internal/resources/accessibility_es.properties | 2 +- .../internal/resources/accessibility_fr.properties | 2 +- .../internal/resources/accessibility_it.properties | 2 +- .../internal/resources/accessibility_ja.properties | 2 +- .../internal/resources/accessibility_ko.properties | 2 +- .../internal/resources/accessibility_pt_BR.properties | 2 +- .../internal/resources/accessibility_sv.properties | 2 +- .../internal/resources/accessibility_zh_CN.properties | 2 +- .../internal/resources/accessibility_zh_TW.properties | 2 +- jdk/src/share/classes/javax/accessibility/AccessibleAction.java | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility.properties index 384409f726d..fd7314333e9 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility.properties @@ -102,7 +102,7 @@ horizontal=horizontal # # accessible actions # -toggle expand=toggle expand +toggleexpand=toggle expand # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_de.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_de.properties index 1cedaeb67c2..fe0f918d9bf 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_de.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_de.properties @@ -102,7 +102,7 @@ horizontal=horizontal # # accessible actions # -toggle expand=ein-/ausblenden +toggleexpand=ein-/ausblenden # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_es.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_es.properties index b1e2e9ba1ea..c3f90416a30 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_es.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_es.properties @@ -102,7 +102,7 @@ horizontal=horizontal # # accessible actions # -toggle expand=activar/desactivar ampliaci\u00F3n +toggleexpand=activar/desactivar ampliaci\u00F3n # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_fr.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_fr.properties index f41a5427605..c399d9a0b32 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_fr.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_fr.properties @@ -102,7 +102,7 @@ horizontal=horizontal # # accessible actions # -toggle expand=basculer le d\u00E9veloppement +toggleexpand=basculer le d\u00E9veloppement # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_it.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_it.properties index 2d5cfa39504..94eefb0a2a3 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_it.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_it.properties @@ -102,7 +102,7 @@ horizontal=orizzontale # # accessible actions # -toggle expand=abilita/disabilita espansione +toggleexpand=abilita/disabilita espansione # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ja.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ja.properties index e266fff6723..eefc1784ba8 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ja.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ja.properties @@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 # # accessible actions # -toggle expand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB +toggleexpand=\u5C55\u958B\u306E\u30C8\u30B0\u30EB # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties index 1a3da2e1b79..530caa68999 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties @@ -102,7 +102,7 @@ horizontal=\uAC00\uB85C # # accessible actions # -toggle expand=\uD1A0\uAE00 \uD655\uC7A5 +toggleexpand=\uD1A0\uAE00 \uD655\uC7A5 # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_pt_BR.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_pt_BR.properties index cdae36aaaaa..f8aaf355040 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_pt_BR.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_pt_BR.properties @@ -102,7 +102,7 @@ horizontal=horizontal # # accessible actions # -toggle expand=alternar expans\u00E3o +toggleexpand=alternar expans\u00E3o # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties index 553098d8289..962b9d35dc5 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_sv.properties @@ -102,7 +102,7 @@ horizontal=horisontell # # accessible actions # -toggle expand=v\u00E4xla ut\u00F6ka +toggleexpand=v\u00E4xla ut\u00F6ka # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_CN.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_CN.properties index 0a117037660..da67e241eba 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_CN.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_CN.properties @@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 # # accessible actions # -toggle expand=\u5207\u6362\u5C55\u5F00 +toggleexpand=\u5207\u6362\u5C55\u5F00 # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_TW.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_TW.properties index f4d11b45411..1de30c27f89 100644 --- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_TW.properties +++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_zh_TW.properties @@ -102,7 +102,7 @@ horizontal=\u6C34\u5E73 # # accessible actions # -toggle expand=\u5207\u63DB\u64F4\u5C55 +toggleexpand=\u5207\u63DB\u64F4\u5C55 # new relations, roles and states for J2SE 1.5.0 diff --git a/jdk/src/share/classes/javax/accessibility/AccessibleAction.java b/jdk/src/share/classes/javax/accessibility/AccessibleAction.java index 1967e2d58f6..ec0b8680bbe 100644 --- a/jdk/src/share/classes/javax/accessibility/AccessibleAction.java +++ b/jdk/src/share/classes/javax/accessibility/AccessibleAction.java @@ -54,7 +54,7 @@ public interface AccessibleAction { * @since 1.5 */ public static final String TOGGLE_EXPAND = - new String ("toggle expand"); + new String ("toggleexpand"); /** * An action which increments a value. From a507980e6df95bc188a45c746475aad145bcb385 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 12 Jul 2013 21:33:33 +0400 Subject: [PATCH 08/10] 8020298: [macosx] Incorrect merge in the lwawt code Reviewed-by: art, anthony --- .../sun/lwawt/macosx/CPlatformWindow.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index dc711c28f0e..abf6679ea3c 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -928,25 +928,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo final Rectangle oldB = nativeBounds; nativeBounds = new Rectangle(x, y, width, height); - final GraphicsConfiguration oldGC = peer.getGraphicsConfiguration(); - - final GraphicsConfiguration newGC = peer.getGraphicsConfiguration(); - // System-dependent appearance optimization. if (peer != null) { peer.notifyReshape(x, y, width, height); - } - - if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) - || isFullScreenAnimationOn || !Objects.equals(newGC, oldGC)) { - flushBuffers(); + // System-dependent appearance optimization. + if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) + || isFullScreenAnimationOn) { + flushBuffers(); + } } } private void deliverWindowClosingEvent() { - if (peer != null) { - if (peer.getBlocker() == null) { - peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING)); - } + if (peer != null && peer.getBlocker() == null) { + peer.postEvent(new WindowEvent(target, WindowEvent.WINDOW_CLOSING)); } } From 0b20e5e9afab364ef45e9a32ed3ac6070a146e88 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Mon, 15 Jul 2013 12:06:06 +0400 Subject: [PATCH 09/10] 8020371: [macosx] applets with Drag and Drop fail with IllegalArgumentException Reviewed-by: anthony, art --- .../classes/sun/lwawt/macosx/CDragSourceContextPeer.java | 9 +++++---- jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java | 2 ++ .../macosx/classes/sun/lwawt/macosx/CPlatformWindow.java | 2 -- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java index 0c0f3e7f1df..c46cb52e19e 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java @@ -107,10 +107,6 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { loc = rootComponent.getLocation(); } - //It sure will be LWComponentPeer instance as rootComponent is a Window - PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow(); - long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow); - // If there isn't any drag image make one of default appearance: if (fDragImage == null) this.setDefaultDragImage(component); @@ -137,6 +133,11 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer { } try { + //It sure will be LWComponentPeer instance as rootComponent is a Window + PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow(); + long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow); + if (nativeViewPtr == 0L) throw new InvalidDnDOperationException("Unsupported platform window implementation"); + // Create native dragging source: final long nativeDragSource = createNativeDragSource(component, nativeViewPtr, transferable, triggerEvent, (int) (dragOrigin.getX()), (int) (dragOrigin.getY()), extModifiers, diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java index 1448424e0ee..7db8c5f52ab 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDropTarget.java @@ -52,6 +52,8 @@ public final class CDropTarget { fPeer = peer; long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow()); + if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin) + // Create native dragging destination: fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer); if (fNativeDropTarget == 0) { diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index abf6679ea3c..124e8f73998 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -896,8 +896,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo nativePeer = ((CPlatformWindow) platformWindow).getContentView().getAWTView(); } else if (platformWindow instanceof CViewPlatformEmbeddedFrame){ nativePeer = ((CViewPlatformEmbeddedFrame) platformWindow).getNSViewPtr(); - } else { - throw new IllegalArgumentException("Unsupported platformWindow implementation"); } return nativePeer; } From c934d0bd27c282389c20393ba9c1bec2cba38e1c Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Mon, 15 Jul 2013 17:33:44 +0400 Subject: [PATCH 10/10] 8017492: Static field in HTML parser affects all applications Reviewed-by: art --- .../swing/text/html/parser/ContentModel.java | 4 +- .../javax/swing/text/html/parser/Element.java | 16 +++- .../swing/text/html/parser/Test8017492.java | 92 +++++++++++++++++++ 3 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 jdk/test/javax/swing/text/html/parser/Test8017492.java diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/ContentModel.java b/jdk/src/share/classes/javax/swing/text/html/parser/ContentModel.java index 67ecc321c16..a60f225b798 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/ContentModel.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/ContentModel.java @@ -170,8 +170,8 @@ public final class ContentModel implements Serializable { case '&': { Element e = (Element) token; if (valSet == null) { - valSet = new boolean[Element.maxIndex + 1]; - val = new boolean[Element.maxIndex + 1]; + valSet = new boolean[Element.getMaxIndex() + 1]; + val = new boolean[valSet.length]; // All Element instances are created before this ever executes } if (valSet[e.index]) { diff --git a/jdk/src/share/classes/javax/swing/text/html/parser/Element.java b/jdk/src/share/classes/javax/swing/text/html/parser/Element.java index 1e9c707b6e8..e1104f3099a 100644 --- a/jdk/src/share/classes/javax/swing/text/html/parser/Element.java +++ b/jdk/src/share/classes/javax/swing/text/html/parser/Element.java @@ -28,6 +28,7 @@ package javax.swing.text.html.parser; import java.util.Hashtable; import java.util.BitSet; import java.io.*; +import sun.awt.AppContext; /** * An element as described in a DTD using the ELEMENT construct. @@ -51,8 +52,6 @@ class Element implements DTDConstants, Serializable { public ContentModel content; public AttributeList atts; - static int maxIndex = 0; - /** * A field to store user data. Mostly used to store * style sheets. @@ -68,7 +67,18 @@ class Element implements DTDConstants, Serializable { Element(String name, int index) { this.name = name; this.index = index; - maxIndex = Math.max(maxIndex, index); + if (index > getMaxIndex()) { + AppContext.getAppContext().put(MAX_INDEX_KEY, index); + } + } + + private static final Object MAX_INDEX_KEY = new Object(); + + static int getMaxIndex() { + Integer value = (Integer) AppContext.getAppContext().get(MAX_INDEX_KEY); + return (value != null) + ? value.intValue() + : 0; } /** diff --git a/jdk/test/javax/swing/text/html/parser/Test8017492.java b/jdk/test/javax/swing/text/html/parser/Test8017492.java new file mode 100644 index 00000000000..e129a41f296 --- /dev/null +++ b/jdk/test/javax/swing/text/html/parser/Test8017492.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Vector; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.parser.DTD; +import javax.swing.text.html.parser.Element; +import sun.awt.SunToolkit; + +/* + * @test + * @bug 8017492 + * @run main/othervm Test8017492 + * @summary Tests for OutOfMemoryError/NegativeArraySizeException + * @author Sergey Malenkov + */ + +public class Test8017492 { + public static void main(String[] args) throws Exception { + Runnable task = new Runnable() { + @Override + public void run() { + try { + SunToolkit.createNewAppContext(); + DTD dtd = DTD.getDTD("dtd"); + dtd.elements = new Vector() { + @Override + public synchronized int size() { + return Integer.MAX_VALUE; + } + }; + dtd.getElement("element"); + } + catch (Exception exception) { + throw new Error("unexpected", exception); + } + } + }; + // run task with different AppContext + Thread thread = new Thread(new ThreadGroup("$$$"), task); + thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread thread, Throwable throwable) { + throwable.printStackTrace(); + System.exit(1); + } + }); + thread.start(); + thread.join(); + // add error handling + HTMLDocument document = new HTMLDocument() { + @Override + public HTMLEditorKit.ParserCallback getReader(int pos) { + return getReader(pos, 0, 0, null); + } + + @Override + public HTMLEditorKit.ParserCallback getReader(int pos, int popDepth, int pushDepth, HTML.Tag insertTag) { + return new HTMLDocument.HTMLReader(pos, popDepth, pushDepth, insertTag) { + @Override + public void handleError(String error, int pos) { + throw new Error(error); + } + }; + } + }; + // run parser + new HTMLEditorKit().insertHTML(document, 0, "text", 0, 0, null); + } +}