diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers index 096bfe553264856292e9587fc67e9bb6b81f6398..8a12b69c31494a3c55a960a83f52e49c5371ab16 100644 --- a/make/sun/xawt/mapfile-vers +++ b/make/sun/xawt/mapfile-vers @@ -158,7 +158,6 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl; Java_sun_awt_X11_XRobotPeer_mouseWheelImpl; Java_sun_awt_X11_XRobotPeer_setup; - Java_sun_awt_X11_XRobotPeer__1dispose; Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl; Java_java_awt_Component_initIDs; Java_java_awt_Container_initIDs; diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index f577887abe67c4caf7831dd385c71e25909a3427..2225633c0db5d6783b57663ae335b14fb7ed52ac 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -2887,11 +2887,12 @@ public abstract class Component implements ImageObserver, MenuContainer, /** * Invalidates this component and its ancestors. *

- * All the ancestors of this component up to the nearest validate root are - * marked invalid also. If there is no a validate root container for this - * component, all of its ancestors up to the root of the hierarchy are - * marked invalid as well. Marking a container invalid indicates - * that the container needs to be laid out. + * By default, all the ancestors of the component up to the top-most + * container of the hierarchy are marked invalid. If the {@code + * java.awt.smartInvalidate} system property is set to {@code true}, + * invalidation stops on the nearest validate root of this component. + * Marking a container invalid indicates that the container needs to + * be laid out. *

* This method is called automatically when any layout-related information * changes (e.g. setting the bounds of the component, or adding the diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index 88f0865b187128a72ef555892d04799f5189e423..c59aa90bc5f238f14ee02d9e7267366e5f4831dc 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -41,6 +41,8 @@ import java.io.ObjectStreamField; import java.io.PrintStream; import java.io.PrintWriter; +import java.security.AccessController; + import java.util.Arrays; import java.util.EventListener; import java.util.HashSet; @@ -60,6 +62,8 @@ import sun.awt.dnd.SunDropTargetEvent; import sun.java2d.pipe.Region; +import sun.security.action.GetBooleanAction; + /** * A generic Abstract Window Toolkit(AWT) container object is a component * that can contain other AWT components. @@ -1506,12 +1510,18 @@ public class Container extends Component { * Layout-related changes, such as bounds of the validate root descendants, * do not affect the layout of the validate root parent. This peculiarity * enables the {@code invalidate()} method to stop invalidating the - * component hierarchy when the method encounters a validate root. + * component hierarchy when the method encounters a validate root. However, + * to preserve backward compatibility this new optimized behavior is + * enabled only when the {@code java.awt.smartInvalidate} system property + * value is set to {@code true}. *

- * If a component hierarchy contains validate roots, the {@code validate()} - * method must be invoked on the validate root of a previously invalidated - * component, rather than on the top-level container (such as a {@code - * Frame} object) to restore the validity of the hierarchy later. + * If a component hierarchy contains validate roots and the new optimized + * {@code invalidate()} behavior is enabled, the {@code validate()} method + * must be invoked on the validate root of a previously invalidated + * component to restore the validity of the hierarchy later. Otherwise, + * calling the {@code validate()} method on the top-level container (such + * as a {@code Frame} object) should be used to restore the validity of the + * component hierarchy. *

* The {@code Window} class and the {@code Applet} class are the validate * roots in AWT. Swing introduces more validate roots. @@ -1527,13 +1537,20 @@ public class Container extends Component { return false; } + private static final boolean isJavaAwtSmartInvalidate; + static { + // Don't lazy-read because every app uses invalidate() + isJavaAwtSmartInvalidate = AccessController.doPrivileged( + new GetBooleanAction("java.awt.smartInvalidate")); + } + /** * Invalidates the parent of the container unless the container * is a validate root. */ @Override void invalidateParent() { - if (!isValidateRoot()) { + if (!isJavaAwtSmartInvalidate || !isValidateRoot()) { super.invalidateParent(); } } @@ -1572,9 +1589,8 @@ public class Container extends Component { * automatically. Note that the ancestors of the container may be * invalidated also (see {@link Component#invalidate} for details.) * Therefore, to restore the validity of the hierarchy, the {@code - * validate()} method should be invoked on a validate root of an - * invalidated component, or on the top-most container if the hierarchy - * does not contain validate roots. + * validate()} method should be invoked on the top-most invalid + * container of the hierarchy. *

* Validating the container may be a quite time-consuming operation. For * performance reasons a developer may postpone the validation of the diff --git a/src/share/classes/java/awt/Toolkit.java b/src/share/classes/java/awt/Toolkit.java index 6e00e6afdbf260aba46d82a34b09e98b0be903f1..3ac2714dcef892da3bb4d97a96f61fa2123715bb 100644 --- a/src/share/classes/java/awt/Toolkit.java +++ b/src/share/classes/java/awt/Toolkit.java @@ -466,10 +466,7 @@ public abstract class Toolkit { */ protected void loadSystemColors(int[] systemColors) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } - + GraphicsEnvironment.checkHeadless(); } /** @@ -504,10 +501,7 @@ public abstract class Toolkit { */ public void setDynamicLayout(boolean dynamic) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } - + GraphicsEnvironment.checkHeadless(); } /** @@ -531,9 +525,8 @@ public abstract class Toolkit { */ protected boolean isDynamicLayoutSet() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutSet(); } else { @@ -569,9 +562,8 @@ public abstract class Toolkit { */ public boolean isDynamicLayoutActive() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutActive(); } else { @@ -615,9 +607,7 @@ public abstract class Toolkit { */ public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getScreenInsets(gc); } else { @@ -1200,10 +1190,7 @@ public abstract class Toolkit { * security manager's checkPermission method with a * RuntimePermission("queuePrintJob") permission. * - * @param frame the parent of the print dialog. May be null if and only - * if jobAttributes is not null and jobAttributes.getDialog() - * returns JobAttributes.DialogType.NONE or - * JobAttributes.DialogType.COMMON. + * @param frame the parent of the print dialog. May not be null. * @param jobtitle the title of the PrintJob. A null title is equivalent * to "". * @param jobAttributes a set of job attributes which will control the @@ -1359,9 +1346,8 @@ public abstract class Toolkit { * @since 1.4 */ public Clipboard getSystemSelection() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getSystemSelection(); } else { @@ -1391,9 +1377,7 @@ public abstract class Toolkit { * @since JDK1.1 */ public int getMenuShortcutKeyMask() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); return Event.CTRL_MASK; } @@ -1418,7 +1402,10 @@ public abstract class Toolkit { * @since 1.3 */ public boolean getLockingKeyState(int keyCode) - throws UnsupportedOperationException { + throws UnsupportedOperationException + { + GraphicsEnvironment.checkHeadless(); + if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) { throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState"); @@ -1449,7 +1436,10 @@ public abstract class Toolkit { * @since 1.3 */ public void setLockingKeyState(int keyCode, boolean on) - throws UnsupportedOperationException { + throws UnsupportedOperationException + { + GraphicsEnvironment.checkHeadless(); + if (! (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK || keyCode == KeyEvent.VK_KANA_LOCK)) { throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState"); @@ -1523,9 +1513,8 @@ public abstract class Toolkit { */ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit(). @@ -1553,9 +1542,8 @@ public abstract class Toolkit { * @since 1.2 */ public int getMaximumCursorColors() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getMaximumCursorColors(); @@ -1605,9 +1593,8 @@ public abstract class Toolkit { public boolean isFrameStateSupported(int state) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit(). isFrameStateSupported(state); @@ -2614,9 +2601,8 @@ public abstract class Toolkit { * @since 1.7 */ public boolean areExtraMouseButtonsEnabled() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } + GraphicsEnvironment.checkHeadless(); + return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); } } diff --git a/src/solaris/classes/sun/awt/X11/XRobotPeer.java b/src/solaris/classes/sun/awt/X11/XRobotPeer.java index 1463f283f0bd33b06551bf3d0ae687bd51a96803..a6acd8eb5f58241958e601b14a5fd3710838b222 100644 --- a/src/solaris/classes/sun/awt/X11/XRobotPeer.java +++ b/src/solaris/classes/sun/awt/X11/XRobotPeer.java @@ -48,7 +48,7 @@ class XRobotPeer implements RobotPeer { } public void dispose() { - _dispose(); + // does nothing } public void mouseMove(int x, int y) { @@ -88,7 +88,6 @@ class XRobotPeer implements RobotPeer { } private static native synchronized void setup(int numberOfButtons, int[] buttonDownMasks); - private static native synchronized void _dispose(); private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); private static native synchronized void mousePressImpl(int buttons); diff --git a/src/solaris/native/sun/awt/awt_Robot.c b/src/solaris/native/sun/awt/awt_Robot.c index 38ad27863667f4e7fe49f8f702470dc36500f4ff..c3384b2eb1a3a5461bac73c2cebd1f84c3105e39 100644 --- a/src/solaris/native/sun/awt/awt_Robot.c +++ b/src/solaris/native/sun/awt/awt_Robot.c @@ -48,28 +48,12 @@ #ifdef __linux__ #include #endif -#include extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; static jint * masks; static jint num_buttons; -static unsigned int s_robotInstanceCounter = 0; - -static void* xcompositeLibHandle = NULL; -static Bool xcompositeExtAvailable = False; -static Bool xcompositeExtTested = False; - -typedef Status (*T_XCompositeQueryVersion)(Display *dpy, int *major_versionp, int *minor_versionp); -typedef Window (*T_XCompositeGetOverlayWindow)(Display *dpy, Window window); -typedef void (*T_XCompositeReleaseOverlayWindow)(Display *dpy, Window window); - -static T_XCompositeQueryVersion XCompositeQueryVersion = NULL; -static T_XCompositeGetOverlayWindow XCompositeGetOverlayWindow = NULL; -static T_XCompositeReleaseOverlayWindow XCompositeReleaseOverlayWindow = NULL; - - static int32_t isXTestAvailable() { int32_t major_opcode, first_event, first_error; int32_t event_basep, error_basep, majorp, minorp; @@ -210,80 +194,8 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButton } AWT_UNLOCK(); - - s_robotInstanceCounter++; } -JNIEXPORT void JNICALL -Java_sun_awt_X11_XRobotPeer__1dispose (JNIEnv * env, jclass cls) -{ - if (--s_robotInstanceCounter) { - return; - } - - // This is the last instance of the XRobotPeer being released - - if (xcompositeExtTested && xcompositeExtAvailable && xcompositeLibHandle) { - // The lib is loaded in IsXCompositeAvailable(). Unload under AWT_LOCK - // so that the shutdown function of the lib behaves correctly. - AWT_LOCK(); - dlclose(xcompositeLibHandle); - AWT_UNLOCK(); - } - - xcompositeExtTested = False; - xcompositeExtAvailable = False; - xcompositeLibHandle = NULL; -} - -/* - * Returns True only if XCOMPOSITE is of version 0.3 or higher. - * The functions that we need are available since that version. - * - * Must be invoked under AWT_LOCK. - * - * Leaves the library loaded if the version is correct. - */ -static Bool IsXCompositeAvailable() -{ - if (!xcompositeExtTested) { - int opcode, eventb, errorb; - - if (XQueryExtension(awt_display, "Composite", &opcode, &eventb, &errorb)) { - xcompositeLibHandle = dlopen("libXcomposite.so.1", RTLD_LAZY | RTLD_GLOBAL); -#ifndef __linux__ /* SOLARIS */ - if (xcompositeLibHandle == NULL) { - xcompositeLibHandle = dlopen("/usr/sfw/lib/libXcomposite.so.1", - RTLD_LAZY | RTLD_GLOBAL); - } -#endif - - if (xcompositeLibHandle) { - int major, minor; - XCompositeQueryVersion = (T_XCompositeQueryVersion)dlsym(xcompositeLibHandle, "XCompositeQueryVersion"); - - if (XCompositeQueryVersion && XCompositeQueryVersion(awt_display, &major, &minor)) { - if (major >= 0 && minor >= 3) { - XCompositeGetOverlayWindow = (T_XCompositeGetOverlayWindow)dlsym(xcompositeLibHandle, "XCompositeGetOverlayWindow"); - XCompositeReleaseOverlayWindow = (T_XCompositeReleaseOverlayWindow)dlsym(xcompositeLibHandle, "XCompositeReleaseOverlayWindow"); - - if (XCompositeGetOverlayWindow && XCompositeReleaseOverlayWindow) { - xcompositeExtAvailable = True; - } - } - } - - if (!xcompositeExtAvailable) { - dlclose(xcompositeLibHandle); - } /* else the lib is unloaded in _dispose() */ - } - } - - xcompositeExtTested = True; - } - - return xcompositeExtAvailable; -} JNIEXPORT void JNICALL Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, @@ -299,7 +211,7 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, jint *ary; /* Array of jints for sending pixel values back * to parent process. */ - Window window; + Window rootWindow; AwtGraphicsConfigDataPtr adata; DTRACE_PRINTLN6("RobotPeer: getRGBPixelsImpl(%lx, %d, %d, %d, %d, %x)", xgc, x, y, width, height, pixelArray); @@ -316,24 +228,14 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, xgc, x11GraphicsConfigIDs.aData); DASSERT(adata != NULL); - window = XRootWindow(awt_display, adata->awt_visInfo.screen); - - if (IsXCompositeAvailable()) { - // Use 'composite overlay window' instead of the root window. - // See 6903034 for details. - window = XCompositeGetOverlayWindow(awt_display, window); - } - - image = getWindowImage(awt_display, window, x, y, width, height); + rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); + image = getWindowImage(awt_display, rootWindow, x, y, width, height); /* Array to use to crunch around the pixel values */ ary = (jint *) malloc(width * height * sizeof (jint)); if (ary == NULL) { JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError"); XDestroyImage(image); - if (IsXCompositeAvailable()) { - XCompositeReleaseOverlayWindow(awt_display, window); - } AWT_UNLOCK(); return; } @@ -354,9 +256,6 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, free(ary); XDestroyImage(image); - if (IsXCompositeAvailable()) { - XCompositeReleaseOverlayWindow(awt_display, window); - } AWT_UNLOCK(); } diff --git a/src/windows/classes/sun/awt/windows/WFramePeer.java b/src/windows/classes/sun/awt/windows/WFramePeer.java index a3e4a1d17fc0c1a0614fb164de8d9c7987bd3a45..94cde03850f46a085f28a2d23070b9abd474e56e 100644 --- a/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -107,8 +107,16 @@ class WFramePeer extends WWindowPeer implements FramePeer { Rectangle currentDevBounds = currentDevGC.getBounds(); Rectangle primaryDevBounds = primaryDevGC.getBounds(); - b.width -= (currentDevBounds.width - primaryDevBounds.width); - b.height -= (currentDevBounds.height - primaryDevBounds.height); + boolean isCurrentDevLarger = + ((currentDevBounds.width - primaryDevBounds.width > 0) || + (currentDevBounds.height - primaryDevBounds.height > 0)); + + // the window manager doesn't seem to compensate for differences when + // the primary monitor is larger than the monitor that display the window + if (isCurrentDevLarger) { + b.width -= (currentDevBounds.width - primaryDevBounds.width); + b.height -= (currentDevBounds.height - primaryDevBounds.height); + } } } diff --git a/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp b/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp index a563c78802b5af58678ec6b555ec1566a34d90f6..3f0284cb073f747dd1548d3bcefa49a60fc9a766 100644 --- a/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp +++ b/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp @@ -192,6 +192,14 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter, pMgr = D3DPipelineManager::GetInstance(); RETURN_IF_NULL(pMgr); hMon = pMgr->pd3d9->GetAdapterMonitor(adapter); + + /* + * If we don't have devices initialized yet, no sense to clear them. + */ + if (!Devices::GetInstance()){ + return; + } + gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon); JNU_CallStaticMethodByName(env, NULL, diff --git a/src/windows/native/sun/windows/Devices.h b/src/windows/native/sun/windows/Devices.h index bbd8a497aaf90a20de9010a6e55858084c678dab..14e9e7b7f0dbe9ec906354ecd1e3edaf751e168e 100644 --- a/src/windows/native/sun/windows/Devices.h +++ b/src/windows/native/sun/windows/Devices.h @@ -36,6 +36,7 @@ class AwtWin32GraphicsDevice; class Devices { public: +static Devices* GetInstance(); static BOOL UpdateInstance(JNIEnv *env); int GetNumDevices() { return numDevices; } AwtWin32GraphicsDevice* GetDeviceReference(int index, BOOL adjust = TRUE); @@ -59,7 +60,6 @@ friend class InstanceAccess; private: Devices(int numElements); void AddReference(); -static Devices* GetInstance(); AwtWin32GraphicsDevice** devices; int refCount; diff --git a/src/windows/native/sun/windows/awt_Choice.cpp b/src/windows/native/sun/windows/awt_Choice.cpp index dfd9a6de6b3260e31385494c07cdd6409a2fc138..0d014ac56f945e9f4cf62b790d3e60cfc307c3bd 100644 --- a/src/windows/native/sun/windows/awt_Choice.cpp +++ b/src/windows/native/sun/windows/awt_Choice.cpp @@ -396,6 +396,12 @@ LRESULT CALLBACK AwtChoice::ListWindowProc(HWND hwnd, UINT message, DASSERT(::IsWindow(hwnd)); + // This branch is required for the proper work of AwtComponent::GetComponent() method + // while hovering drop-down list + if (message == WmAwtIsComponent) { + return (LRESULT)TRUE; + } + switch (message) { case WM_LBUTTONDOWN: { DWORD curPos = ::GetMessagePos(); diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp index 024915fcffcf691044d3442edd6d57f8f302e9c1..d4fe9e8766ff2d49361532eeca94ec71dfa6b356 100644 --- a/src/windows/native/sun/windows/awt_Component.cpp +++ b/src/windows/native/sun/windows/awt_Component.cpp @@ -364,7 +364,6 @@ AwtComponent* AwtComponent::GetComponentImpl(HWND hWnd) { AwtComponent *component = (AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA); DASSERT(!component || !IsBadReadPtr(component, sizeof(AwtComponent)) ); - DASSERT(!component || component->GetHWnd() == hWnd ); return component; } diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp index 6662d6d54c2f887fe92188b10ef58915418ca677..76811dfec035801af3276bbb7b9b11d850e2fb23 100644 --- a/src/windows/native/sun/windows/awt_Frame.cpp +++ b/src/windows/native/sun/windows/awt_Frame.cpp @@ -344,17 +344,6 @@ LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, Ms SetImeTargetComponent(NULL); } break; - // TODO: when a Choice's list is dropped down and we're scrolling in - // the list WM_MOUSEWHEEL messages come to the poxy, not to the list. Why? - case WM_MOUSEWHEEL: - focusOwner = AwtComponent::GetComponent(sm_focusOwner); - if (focusOwner != NULL && - focusOwner != this) // avoid recursive calls - { - retValue = focusOwner->WindowProc(message, wParam, lParam); - mr = mrConsume; - } - break; case WM_SETFOCUS: if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain diff --git a/test/java/awt/Component/Revalidate/Revalidate.java b/test/java/awt/Component/Revalidate/Revalidate.java index 670c374f87d4d151c30041c9cecff0ce16ec5c6a..386e5394c6f79b485b060c9381934c74c09ae7f6 100644 --- a/test/java/awt/Component/Revalidate/Revalidate.java +++ b/test/java/awt/Component/Revalidate/Revalidate.java @@ -26,7 +26,7 @@ @bug 7036669 @summary Test Component.revalidate() method @author anthony.petrov@oracle.com: area=awt.component - @run main Revalidate + @run main/othervm -Djava.awt.smartInvalidate=true Revalidate */ import java.awt.*; diff --git a/test/java/awt/Container/ValidateRoot/InvalidateMustRespectValidateRoots.java b/test/java/awt/Container/ValidateRoot/InvalidateMustRespectValidateRoots.java index 9fd38aa51ecbc0a0fb01c77a15bd9bd68c26505e..0986ebd7976b374896a0d5655793737dee1bb587 100644 --- a/test/java/awt/Container/ValidateRoot/InvalidateMustRespectValidateRoots.java +++ b/test/java/awt/Container/ValidateRoot/InvalidateMustRespectValidateRoots.java @@ -26,7 +26,7 @@ @bug 6852592 @summary invalidate() must stop when it encounters a validate root @author anthony.petrov@sun.com - @run main InvalidateMustRespectValidateRoots + @run main/othervm -Djava.awt.smartInvalidate=true InvalidateMustRespectValidateRoots */ import javax.swing.*; diff --git a/test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java b/test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java new file mode 100644 index 0000000000000000000000000000000000000000..e6835e69e926e6a543ef0c6f24263229b180c2bc --- /dev/null +++ b/test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2011, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 7040577 + @library ../../../regtesthelpers + @build Sysout + @summary Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env + @author andrei dmitriev: area=awt.headless + @run main/othervm -Djava.awt.headless=true ExceptionContract +*/ + +import java.awt.*; +import java.util.Properties; +import test.java.awt.regtesthelpers.Sysout; + +import java.awt.datatransfer.Clipboard; +import java.awt.dnd.*; +import java.awt.dnd.peer.DragSourceContextPeer; +import java.awt.font.TextAttribute; +import java.awt.im.InputMethodHighlight; +import java.awt.image.*; +import java.awt.peer.*; +import java.net.URL; +import java.util.Map; +import java.util.Properties; + +public class ExceptionContract { + + private static boolean passed = false; + public static void main(String[] args) { + //Case1 + try{ + new _Toolkit().getLockingKeyState(1); + } catch (HeadlessException he){ + passed = true; + } + if (!passed){ + throw new RuntimeException("Tk.getLockingKeyState() didn't throw HeadlessException while in the headless mode."); + } + + passed = false; + //Case2 + try{ + new _Toolkit().setLockingKeyState(1, true); + } catch (HeadlessException he){ + passed = true; + } + if (!passed){ + throw new RuntimeException("Tk.setLockingKeyState() didn't throw HeadlessException while in the headless mode."); + } + + passed = false; + //Case3 + try{ + new _Toolkit().createCustomCursor(new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB), new Point(0,0), "Custom cursor"); + } catch (HeadlessException he){ + he.printStackTrace(); + passed = true; + } + if (!passed){ + throw new RuntimeException("Tk.createCustomCursor(args) didn't throw HeadlessException while in the headless mode."); + } + + } + + static class _Toolkit extends Toolkit { + + @Override + public Cursor createCustomCursor(Image cursor, Point hotSpot, String name) + throws IndexOutOfBoundsException, HeadlessException + { + return super.createCustomCursor(cursor, hotSpot, name); + } + + + @Override + public void setLockingKeyState(int keyCode, boolean on) throws UnsupportedOperationException { + super.setLockingKeyState(keyCode, on); + } + + @Override + public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException { + return super.getLockingKeyState(keyCode); + } + + + @Override + public void loadSystemColors(int[] systemColors) throws HeadlessException { + return; + } + + @Override + protected DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException { + return null; + } + + @Override + protected ButtonPeer createButton(Button target) throws HeadlessException { + return null; + } + + @Override + protected TextFieldPeer createTextField(TextField target) throws HeadlessException { + return null; + } + + @Override + protected LabelPeer createLabel(Label target) throws HeadlessException { + return null; + } + + @Override + protected ListPeer createList(List target) throws HeadlessException { + return null; + } + + @Override + protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException { + return null; + } + + @Override + protected ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException { + return null; + } + + @Override + protected ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException { + return null; + } + + @Override + protected TextAreaPeer createTextArea(TextArea target) throws HeadlessException { + return null; + } + + @Override + protected ChoicePeer createChoice(Choice target) throws HeadlessException { + return null; + } + + @Override + protected FramePeer createFrame(Frame target) throws HeadlessException { + return null; + } + + @Override + protected CanvasPeer createCanvas(Canvas target) { + return null; + } + + @Override + protected PanelPeer createPanel(Panel target) { + return null; + } + + @Override + protected WindowPeer createWindow(Window target) throws HeadlessException { + return null; + } + + @Override + protected DialogPeer createDialog(Dialog target) throws HeadlessException { + return null; + } + + @Override + protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException { + return null; + } + + @Override + protected MenuPeer createMenu(Menu target) throws HeadlessException { + return null; + } + + @Override + protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException { + return null; + } + + @Override + protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException { + return null; + } + + @Override + protected FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException { + return null; + } + + @Override + protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException { + return null; + } + + @Override + protected FontPeer getFontPeer(String name, int style) { + return null; + } + + @Override + public Dimension getScreenSize() throws HeadlessException { + return null; + } + + @Override + public int getScreenResolution() throws HeadlessException { + return 0; + } + + @Override + public ColorModel getColorModel() throws HeadlessException { + return null; + } + + @Override + public String[] getFontList() { + return new String[0]; + } + + @Override + public FontMetrics getFontMetrics(Font font) { + return null; + } + + @Override + public void sync() { + + } + + @Override + public Image getImage(String filename) { + return null; + } + + @Override + public Image getImage(URL url) { + return null; + } + + @Override + public Image createImage(String filename) { + return null; + } + + @Override + public Image createImage(URL url) { + return null; + } + + @Override + public boolean prepareImage(Image image, int width, int height, ImageObserver observer) { + return false; + } + + @Override + public int checkImage(Image image, int width, int height, ImageObserver observer) { + return 0; + } + + @Override + public Image createImage(ImageProducer producer) { + return null; + } + + @Override + public Image createImage(byte[] imagedata, int imageoffset, int imagelength) { + return null; + } + + @Override + public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) { + return null; + } + + @Override + public void beep() { + + } + + @Override + public Clipboard getSystemClipboard() throws HeadlessException { + return null; + } + + @Override + protected EventQueue getSystemEventQueueImpl() { + return null; + } + + @Override + public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + return null; + } + + @Override + public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { + return false; + } + + @Override + public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) { + return false; + } + + @Override + public Map mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException { + return null; + } + } +}