Merge
This commit is contained in:
commit
177206a185
@ -119,7 +119,9 @@ public class CEmbeddedFrame extends EmbeddedFrame {
|
|||||||
|
|
||||||
public void handleWindowFocusEvent(boolean parentWindowActive) {
|
public void handleWindowFocusEvent(boolean parentWindowActive) {
|
||||||
this.parentWindowActive = parentWindowActive;
|
this.parentWindowActive = parentWindowActive;
|
||||||
if (focused) {
|
// ignore focus "lost" native request as it may mistakenly
|
||||||
|
// deactivate active window (see 8001161)
|
||||||
|
if (focused && parentWindowActive) {
|
||||||
responder.handleWindowFocusEvent(parentWindowActive, null);
|
responder.handleWindowFocusEvent(parentWindowActive, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -58,7 +58,8 @@ import sun.reflect.misc.*;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class DefaultPersistenceDelegate extends PersistenceDelegate {
|
public class DefaultPersistenceDelegate extends PersistenceDelegate {
|
||||||
private String[] constructor;
|
private static final String[] EMPTY = {};
|
||||||
|
private final String[] constructor;
|
||||||
private Boolean definesEquals;
|
private Boolean definesEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +68,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
|
|||||||
* @see #DefaultPersistenceDelegate(java.lang.String[])
|
* @see #DefaultPersistenceDelegate(java.lang.String[])
|
||||||
*/
|
*/
|
||||||
public DefaultPersistenceDelegate() {
|
public DefaultPersistenceDelegate() {
|
||||||
this(new String[0]);
|
this.constructor = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +93,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
|
|||||||
* @see #instantiate
|
* @see #instantiate
|
||||||
*/
|
*/
|
||||||
public DefaultPersistenceDelegate(String[] constructorPropertyNames) {
|
public DefaultPersistenceDelegate(String[] constructorPropertyNames) {
|
||||||
this.constructor = constructorPropertyNames;
|
this.constructor = (constructorPropertyNames == null) ? EMPTY : constructorPropertyNames.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean definesEquals(Class<?> type) {
|
private static boolean definesEquals(Class<?> type) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -277,7 +277,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
|
|||||||
Method removeListenerMethod)
|
Method removeListenerMethod)
|
||||||
throws IntrospectionException {
|
throws IntrospectionException {
|
||||||
setName(eventSetName);
|
setName(eventSetName);
|
||||||
this.listenerMethodDescriptors = listenerMethodDescriptors;
|
this.listenerMethodDescriptors = (listenerMethodDescriptors != null)
|
||||||
|
? listenerMethodDescriptors.clone()
|
||||||
|
: null;
|
||||||
setAddListenerMethod(addListenerMethod);
|
setAddListenerMethod(addListenerMethod);
|
||||||
setRemoveListenerMethod(removeListenerMethod);
|
setRemoveListenerMethod(removeListenerMethod);
|
||||||
setListenerType(listenerType);
|
setListenerType(listenerType);
|
||||||
@ -347,7 +349,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
|
|||||||
* events are fired.
|
* events are fired.
|
||||||
*/
|
*/
|
||||||
public synchronized MethodDescriptor[] getListenerMethodDescriptors() {
|
public synchronized MethodDescriptor[] getListenerMethodDescriptors() {
|
||||||
return listenerMethodDescriptors;
|
return (this.listenerMethodDescriptors != null)
|
||||||
|
? this.listenerMethodDescriptors.clone()
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -70,7 +70,9 @@ public class MethodDescriptor extends FeatureDescriptor {
|
|||||||
ParameterDescriptor parameterDescriptors[]) {
|
ParameterDescriptor parameterDescriptors[]) {
|
||||||
setName(method.getName());
|
setName(method.getName());
|
||||||
setMethod(method);
|
setMethod(method);
|
||||||
this.parameterDescriptors = parameterDescriptors;
|
this.parameterDescriptors = (parameterDescriptors != null)
|
||||||
|
? parameterDescriptors.clone()
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +163,9 @@ public class MethodDescriptor extends FeatureDescriptor {
|
|||||||
* a null array if the parameter names aren't known.
|
* a null array if the parameter names aren't known.
|
||||||
*/
|
*/
|
||||||
public ParameterDescriptor[] getParameterDescriptors() {
|
public ParameterDescriptor[] getParameterDescriptors() {
|
||||||
return parameterDescriptors;
|
return (this.parameterDescriptors != null)
|
||||||
|
? this.parameterDescriptors.clone()
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -92,7 +92,7 @@ public class Statement {
|
|||||||
public Statement(Object target, String methodName, Object[] arguments) {
|
public Statement(Object target, String methodName, Object[] arguments) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.methodName = methodName;
|
this.methodName = methodName;
|
||||||
this.arguments = (arguments == null) ? emptyArray : arguments;
|
this.arguments = (arguments == null) ? emptyArray : arguments.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +128,7 @@ public class Statement {
|
|||||||
* @return the array of arguments
|
* @return the array of arguments
|
||||||
*/
|
*/
|
||||||
public Object[] getArguments() {
|
public Object[] getArguments() {
|
||||||
return arguments;
|
return this.arguments.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -994,10 +994,7 @@ public class XBaseWindow {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int buttonState = 0;
|
int buttonState = 0;
|
||||||
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
|
buttonState = xbe.get_state() & XConstants.ALL_BUTTONS_MASK;
|
||||||
for (int i = 0; i<buttonsNumber; i++){
|
|
||||||
buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
|
|
||||||
}
|
|
||||||
switch (xev.get_type()) {
|
switch (xev.get_type()) {
|
||||||
case XConstants.ButtonPress:
|
case XConstants.ButtonPress:
|
||||||
if (buttonState == 0) {
|
if (buttonState == 0) {
|
||||||
@ -1034,12 +1031,12 @@ public class XBaseWindow {
|
|||||||
* Checks ButtonRelease released all Mouse buttons
|
* Checks ButtonRelease released all Mouse buttons
|
||||||
*/
|
*/
|
||||||
static boolean isFullRelease(int buttonState, int button) {
|
static boolean isFullRelease(int buttonState, int button) {
|
||||||
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
|
final int buttonsNumber = XToolkit.getNumberOfButtonsForMask();
|
||||||
|
|
||||||
if (button < 0 || button > buttonsNumber) {
|
if (button < 0 || button > buttonsNumber) {
|
||||||
return buttonState == 0;
|
return buttonState == 0;
|
||||||
} else {
|
} else {
|
||||||
return buttonState == XConstants.buttonsMask[button - 1];
|
return buttonState == XlibUtil.getButtonMask(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,9 @@ final public class XConstants {
|
|||||||
public static final long ColormapChangeMask = (1L<<23) ;
|
public static final long ColormapChangeMask = (1L<<23) ;
|
||||||
public static final long OwnerGrabButtonMask = (1L<<24) ;
|
public static final long OwnerGrabButtonMask = (1L<<24) ;
|
||||||
|
|
||||||
|
public static final int MAX_BUTTONS = 5;
|
||||||
|
public static final int ALL_BUTTONS_MASK = (int) (Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask);
|
||||||
|
|
||||||
/* Event names. Used in "type" field in XEvent structures. Not to be
|
/* Event names. Used in "type" field in XEvent structures. Not to be
|
||||||
confused with event masks above. They start from 2 because 0 and 1
|
confused with event masks above. They start from 2 because 0 and 1
|
||||||
are reserved in the protocol for errors and replies. */
|
are reserved in the protocol for errors and replies. */
|
||||||
@ -194,34 +197,6 @@ final public class XConstants {
|
|||||||
public static final int Mod4MapIndex = 6 ;
|
public static final int Mod4MapIndex = 6 ;
|
||||||
public static final int Mod5MapIndex = 7 ;
|
public static final int Mod5MapIndex = 7 ;
|
||||||
|
|
||||||
|
|
||||||
/* button masks. Used in same manner as Key masks above. Not to be confused
|
|
||||||
with button names below. */
|
|
||||||
public static final int [] buttonsMask = new int []{ 1<<8,
|
|
||||||
1<<9,
|
|
||||||
1<<10,
|
|
||||||
1<<11,
|
|
||||||
1<<12,
|
|
||||||
1<<13,
|
|
||||||
1<<14,
|
|
||||||
1<<15,
|
|
||||||
1<<16,
|
|
||||||
1<<17,
|
|
||||||
1<<18,
|
|
||||||
1<<19,
|
|
||||||
1<<20,
|
|
||||||
1<<21,
|
|
||||||
1<<22,
|
|
||||||
1<<23,
|
|
||||||
1<<24,
|
|
||||||
1<<25,
|
|
||||||
1<<26,
|
|
||||||
1<<27,
|
|
||||||
1<<28,
|
|
||||||
1<<29,
|
|
||||||
1<<30,
|
|
||||||
1<<31 };
|
|
||||||
|
|
||||||
public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */
|
public static final int AnyModifier = (1<<15) ; /* used in GrabButton, GrabKey */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1543,6 +1543,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getNumberOfButtonsForMask() {
|
||||||
|
return Math.min(XConstants.MAX_BUTTONS, ((SunToolkit) (Toolkit.getDefaultToolkit())).getNumberOfButtons());
|
||||||
|
}
|
||||||
|
|
||||||
private final static String prefix = "DnD.Cursor.";
|
private final static String prefix = "DnD.Cursor.";
|
||||||
private final static String postfix = ".32x32";
|
private final static String postfix = ".32x32";
|
||||||
private static final String dndPrefix = "DnD.";
|
private static final String dndPrefix = "DnD.";
|
||||||
|
@ -596,12 +596,12 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
|
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
|
||||||
|
|
||||||
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
|
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
|
||||||
for (int i = 0; i < XConstants.buttonsMask.length; i ++){
|
for (int i = 0; i < XConstants.buttons.length; i ++){
|
||||||
//modifier should be added if :
|
//modifier should be added if :
|
||||||
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
|
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
|
||||||
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
|
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
|
||||||
// ONLY one of these conditions should be TRUE to add that modifier.
|
// ONLY one of these conditions should be TRUE to add that modifier.
|
||||||
if (((state & XConstants.buttonsMask[i]) != 0) != (button == XConstants.buttons[i])){
|
if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){
|
||||||
//exclude wheel buttons from adding their numbers as modifiers
|
//exclude wheel buttons from adding their numbers as modifiers
|
||||||
if (!wheel_mouse) {
|
if (!wheel_mouse) {
|
||||||
modifiers |= InputEvent.getMaskForButton(i+1);
|
modifiers |= InputEvent.getMaskForButton(i+1);
|
||||||
@ -689,7 +689,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
|
|
||||||
if (type == XConstants.ButtonPress) {
|
if (type == XConstants.ButtonPress) {
|
||||||
//Allow this mouse button to generate CLICK event on next ButtonRelease
|
//Allow this mouse button to generate CLICK event on next ButtonRelease
|
||||||
mouseButtonClickAllowed |= XConstants.buttonsMask[lbutton];
|
mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
|
||||||
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
|
XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
|
||||||
/*
|
/*
|
||||||
multiclick checking
|
multiclick checking
|
||||||
@ -747,7 +747,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
postEventToEventQueue(me);
|
postEventToEventQueue(me);
|
||||||
|
|
||||||
if ((type == XConstants.ButtonRelease) &&
|
if ((type == XConstants.ButtonRelease) &&
|
||||||
((mouseButtonClickAllowed & XConstants.buttonsMask[lbutton]) != 0) ) // No up-button in the drag-state
|
((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
|
||||||
{
|
{
|
||||||
postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
|
postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
|
||||||
MouseEvent.MOUSE_CLICKED,
|
MouseEvent.MOUSE_CLICKED,
|
||||||
@ -777,7 +777,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
/* Update the state variable AFTER the CLICKED event post. */
|
/* Update the state variable AFTER the CLICKED event post. */
|
||||||
if (type == XConstants.ButtonRelease) {
|
if (type == XConstants.ButtonRelease) {
|
||||||
/* Exclude this mouse button from allowed list.*/
|
/* Exclude this mouse button from allowed list.*/
|
||||||
mouseButtonClickAllowed &= ~XConstants.buttonsMask[lbutton];
|
mouseButtonClickAllowed &= ~ XlibUtil.getButtonMask(lbutton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,12 +793,12 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
|
|||||||
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
|
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
|
||||||
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
|
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
|
||||||
// should be passed from XWindow.
|
// should be passed from XWindow.
|
||||||
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
|
final int buttonsNumber = XToolkit.getNumberOfButtonsForMask();
|
||||||
|
|
||||||
for (int i = 0; i < buttonsNumber; i++){
|
for (int i = 0; i < buttonsNumber; i++){
|
||||||
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
|
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
|
||||||
if ((i != 4) && (i != 5)) {
|
if ((i != 4) && (i != 5)) {
|
||||||
mouseKeyState = mouseKeyState | (xme.get_state() & XConstants.buttonsMask[i]);
|
mouseKeyState = mouseKeyState | (xme.get_state() & XlibUtil.getButtonMask(i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2070,12 +2070,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
|||||||
}
|
}
|
||||||
if (isGrabbed()) {
|
if (isGrabbed()) {
|
||||||
boolean dragging = false;
|
boolean dragging = false;
|
||||||
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
|
final int buttonsNumber = XToolkit.getNumberOfButtonsForMask();
|
||||||
|
|
||||||
for (int i = 0; i < buttonsNumber; i++){
|
for (int i = 0; i < buttonsNumber; i++){
|
||||||
// here is the bug in WM: extra buttons doesn't have state!=0 as they should.
|
// here is the bug in WM: extra buttons doesn't have state!=0 as they should.
|
||||||
if ((i != 4) && (i != 5)){
|
if ((i != 4) && (i != 5)){
|
||||||
dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0);
|
dragging = dragging || ((xme.get_state() & XlibUtil.getButtonMask(i + 1)) != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// When window is grabbed, all events are dispatched to
|
// When window is grabbed, all events are dispatched to
|
||||||
|
@ -396,4 +396,14 @@ public class XlibUtil
|
|||||||
return isShapingSupported.booleanValue();
|
return isShapingSupported.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int getButtonMask(int button) {
|
||||||
|
// Button indices start with 1. The first bit in the button mask is the 8th.
|
||||||
|
// The state mask does not support button indicies > 5, so we need to
|
||||||
|
// cut there.
|
||||||
|
if (button <= 0 || button > XConstants.MAX_BUTTONS) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1 << (7 + button);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
131
jdk/test/java/beans/Introspector/Test8005065.java
Normal file
131
jdk/test/java/beans/Introspector/Test8005065.java
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012, 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 8005065
|
||||||
|
* @summary Tests that all arrays in JavaBeans are guarded
|
||||||
|
* @author Sergey Malenkov
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.beans.DefaultPersistenceDelegate;
|
||||||
|
import java.beans.Encoder;
|
||||||
|
import java.beans.EventSetDescriptor;
|
||||||
|
import java.beans.ExceptionListener;
|
||||||
|
import java.beans.Expression;
|
||||||
|
import java.beans.Statement;
|
||||||
|
import java.beans.MethodDescriptor;
|
||||||
|
import java.beans.ParameterDescriptor;
|
||||||
|
|
||||||
|
public class Test8005065 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
testDefaultPersistenceDelegate();
|
||||||
|
testEventSetDescriptor();
|
||||||
|
testMethodDescriptor();
|
||||||
|
testStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testDefaultPersistenceDelegate() {
|
||||||
|
Encoder encoder = new Encoder();
|
||||||
|
String[] array = { "array" };
|
||||||
|
MyDPD dpd = new MyDPD(array);
|
||||||
|
dpd.instantiate(dpd, encoder);
|
||||||
|
array[0] = null;
|
||||||
|
dpd.instantiate(dpd, encoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testEventSetDescriptor() {
|
||||||
|
try {
|
||||||
|
MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) };
|
||||||
|
EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null);
|
||||||
|
test(descriptor.getListenerMethodDescriptors());
|
||||||
|
array[0] = null;
|
||||||
|
test(descriptor.getListenerMethodDescriptors());
|
||||||
|
descriptor.getListenerMethodDescriptors()[0] = null;
|
||||||
|
test(descriptor.getListenerMethodDescriptors());
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
throw new Error("unexpected error", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testMethodDescriptor() {
|
||||||
|
try {
|
||||||
|
ParameterDescriptor[] array = { new ParameterDescriptor() };
|
||||||
|
MethodDescriptor descriptor = new MethodDescriptor(MyDPD.class.getMethod("getArray"), array);
|
||||||
|
test(descriptor.getParameterDescriptors());
|
||||||
|
array[0] = null;
|
||||||
|
test(descriptor.getParameterDescriptors());
|
||||||
|
descriptor.getParameterDescriptors()[0] = null;
|
||||||
|
test(descriptor.getParameterDescriptors());
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
throw new Error("unexpected error", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testStatement() {
|
||||||
|
Object[] array = { new Object() };
|
||||||
|
Statement statement = new Statement(null, null, array);
|
||||||
|
test(statement.getArguments());
|
||||||
|
array[0] = null;
|
||||||
|
test(statement.getArguments());
|
||||||
|
statement.getArguments()[0] = null;
|
||||||
|
test(statement.getArguments());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> void test(T[] array) {
|
||||||
|
if (array.length != 1) {
|
||||||
|
throw new Error("unexpected array length");
|
||||||
|
}
|
||||||
|
if (array[0] == null) {
|
||||||
|
throw new Error("unexpected array content");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MyDPD
|
||||||
|
extends DefaultPersistenceDelegate
|
||||||
|
implements ExceptionListener {
|
||||||
|
|
||||||
|
private final String[] array;
|
||||||
|
|
||||||
|
public MyDPD(String[] array) {
|
||||||
|
super(array);
|
||||||
|
this.array = array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression instantiate(Object instance, Encoder encoder) {
|
||||||
|
encoder.setExceptionListener(this);
|
||||||
|
return super.instantiate(instance, encoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getArray() {
|
||||||
|
return this.array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exceptionThrown(Exception exception) {
|
||||||
|
throw new Error("unexpected error", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.plaf.metal.*;
|
||||||
|
|
||||||
public class bug7193219 {
|
public class bug7193219 {
|
||||||
private static byte[] serializeGUI() {
|
private static byte[] serializeGUI() {
|
||||||
@ -73,6 +74,7 @@ public class bug7193219 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
43
jdk/test/javax/swing/JFrame/4962534/bug4962534.html
Normal file
43
jdk/test/javax/swing/JFrame/4962534/bug4962534.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
Copyright (c) 2012, 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 4962534
|
||||||
|
@summary JFrame dances very badly
|
||||||
|
@author dav@sparc.spb.su area=
|
||||||
|
@run applet bug4962534.html
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title> </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>bug4962534<br>Bug ID: 4962534 </h1>
|
||||||
|
|
||||||
|
<p> This is an AUTOMATIC test, simply wait for completion </p>
|
||||||
|
|
||||||
|
<APPLET CODE="bug4962534.class" WIDTH=200 HEIGHT=200></APPLET>
|
||||||
|
</body>
|
||||||
|
</html>
|
235
jdk/test/javax/swing/JFrame/4962534/bug4962534.java
Normal file
235
jdk/test/javax/swing/JFrame/4962534/bug4962534.java
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012, 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 4962534 7104594
|
||||||
|
@summary JFrame dances very badly
|
||||||
|
@author dav@sparc.spb.su area=
|
||||||
|
@run applet bug4962534.html
|
||||||
|
*/
|
||||||
|
import java.applet.Applet;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.Random;
|
||||||
|
import javax.swing.*;
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
|
public class bug4962534 extends Applet {
|
||||||
|
|
||||||
|
Robot robot;
|
||||||
|
volatile Point framePosition;
|
||||||
|
volatile Point newFrameLocation;
|
||||||
|
JFrame frame;
|
||||||
|
Rectangle gcBounds;
|
||||||
|
Component titleComponent;
|
||||||
|
JLayeredPane lPane;
|
||||||
|
volatile boolean titleFound = false;
|
||||||
|
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
|
||||||
|
public static Object LOCK = new Object();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
try {
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
createAndShowGUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new RuntimeException("Init failed. " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}//End init()
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
validate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
setJLayeredPaneEDT();
|
||||||
|
setTitleComponentEDT();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw new RuntimeException("Test failed. " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!titleFound) {
|
||||||
|
throw new RuntimeException("Test Failed. Unable to determine title's size.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Random r = new Random();
|
||||||
|
|
||||||
|
for (int iteration = 0; iteration < 10; iteration++) {
|
||||||
|
try {
|
||||||
|
setFramePosEDT();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw new RuntimeException("Test failed.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
robot = new Robot();
|
||||||
|
robot.setAutoDelay(70);
|
||||||
|
|
||||||
|
toolkit.realSync();
|
||||||
|
|
||||||
|
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
|
||||||
|
framePosition.y + titleComponent.getHeight() / 2);
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
|
||||||
|
toolkit.realSync();
|
||||||
|
|
||||||
|
gcBounds =
|
||||||
|
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getConfigurations()[0].getBounds();
|
||||||
|
|
||||||
|
robot.mouseMove(framePosition.x + getJFrameWidthEDT() / 2,
|
||||||
|
framePosition.y + titleComponent.getHeight() / 2);
|
||||||
|
|
||||||
|
toolkit.realSync();
|
||||||
|
|
||||||
|
int multier = gcBounds.height / 2 - 10; //we will not go out the borders
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
robot.mouseMove(gcBounds.width / 2 - (int) (r.nextDouble() * multier), gcBounds.height / 2 - (int) (r.nextDouble() * multier));
|
||||||
|
}
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
|
||||||
|
toolkit.realSync();
|
||||||
|
|
||||||
|
} catch (AWTException e) {
|
||||||
|
throw new RuntimeException("Test Failed. AWTException thrown." + e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException("Test Failed.");
|
||||||
|
}
|
||||||
|
System.out.println("Mouse lies in " + MouseInfo.getPointerInfo().getLocation());
|
||||||
|
boolean frameIsOutOfScreen = false;
|
||||||
|
try {
|
||||||
|
setNewFrameLocationEDT();
|
||||||
|
System.out.println("Now Frame lies in " + newFrameLocation);
|
||||||
|
frameIsOutOfScreen = checkFrameIsOutOfScreenEDT();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw new RuntimeException("Test Failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameIsOutOfScreen) {
|
||||||
|
throw new RuntimeException("Test failed. JFrame is out of screen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} //for iteration
|
||||||
|
System.out.println("Test passed.");
|
||||||
|
}// start()
|
||||||
|
|
||||||
|
private void createAndShowGUI() {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(
|
||||||
|
"javax.swing.plaf.metal.MetalLookAndFeel");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new RuntimeException(ex.getMessage());
|
||||||
|
}
|
||||||
|
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||||
|
frame = new JFrame("JFrame Dance Test");
|
||||||
|
frame.pack();
|
||||||
|
frame.setSize(450, 260);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setJLayeredPaneEDT() throws Exception {
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
lPane = frame.getLayeredPane();
|
||||||
|
System.out.println("JFrame's LayeredPane " + lPane);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTitleComponentEDT() throws Exception {
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (int j = 0; j < lPane.getComponentsInLayer(JLayeredPane.FRAME_CONTENT_LAYER.intValue()).length; j++) {
|
||||||
|
titleComponent = lPane.getComponentsInLayer(JLayeredPane.FRAME_CONTENT_LAYER.intValue())[j];
|
||||||
|
if (titleComponent.getClass().getName().equals("javax.swing.plaf.metal.MetalTitlePane")) {
|
||||||
|
titleFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFramePosEDT() throws Exception {
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
framePosition = frame.getLocationOnScreen();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkFrameIsOutOfScreenEDT() throws Exception {
|
||||||
|
|
||||||
|
final boolean[] result = new boolean[1];
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (newFrameLocation.x > gcBounds.width || newFrameLocation.x < 0
|
||||||
|
|| newFrameLocation.y > gcBounds.height || newFrameLocation.y
|
||||||
|
< 0) {
|
||||||
|
result[0] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setNewFrameLocationEDT() throws Exception {
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
newFrameLocation = new Point(frame.getLocationOnScreen().x
|
||||||
|
+ frame.getWidth() / 2, frame.getLocationOnScreen().y + titleComponent.getHeight() / 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getJFrameWidthEDT() throws Exception {
|
||||||
|
|
||||||
|
final int[] result = new int[1];
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
result[0] = frame.getWidth();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result[0];
|
||||||
|
}
|
||||||
|
}// class
|
Loading…
x
Reference in New Issue
Block a user