mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-13 16:38:50 +00:00
8143316: Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
Reviewed-by: serb
This commit is contained in:
parent
faa243834a
commit
aeccbee0e7
@ -1159,17 +1159,6 @@ public abstract class SunToolkit extends Toolkit
|
||||
return getStartupLocale();
|
||||
}
|
||||
|
||||
private static DefaultMouseInfoPeer mPeer = null;
|
||||
|
||||
@Override
|
||||
public synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
if (mPeer == null) {
|
||||
mPeer = new DefaultMouseInfoPeer();
|
||||
}
|
||||
return mPeer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether default toolkit needs the support of the xembed
|
||||
* from embedding host(if any).
|
||||
|
||||
@ -23,18 +23,24 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.MouseInfoPeer;
|
||||
|
||||
public final class DefaultMouseInfoPeer implements MouseInfoPeer {
|
||||
public final class WMouseInfoPeer implements MouseInfoPeer {
|
||||
|
||||
static {
|
||||
// initialize screen devices for the mouse coordinates scaling
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Package-private constructor to prevent instantiation.
|
||||
*/
|
||||
DefaultMouseInfoPeer() {
|
||||
WMouseInfoPeer() {
|
||||
}
|
||||
|
||||
public native int fillPointWithCoords(Point point);
|
||||
@ -558,6 +558,16 @@ public final class WToolkit extends SunToolkit implements Runnable {
|
||||
return WKeyboardFocusManagerPeer.getInstance();
|
||||
}
|
||||
|
||||
private static WMouseInfoPeer wPeer = null;
|
||||
|
||||
@Override
|
||||
public synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
if (wPeer == null) {
|
||||
wPeer = new WMouseInfoPeer();
|
||||
}
|
||||
return wPeer;
|
||||
}
|
||||
|
||||
private native void setDynamicLayoutNative(boolean b);
|
||||
|
||||
@Override
|
||||
|
||||
@ -33,12 +33,12 @@
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: sun_awt_DefaultMouseInfoPeer
|
||||
* Class: sun_awt_windows_WMouseInfoPeer
|
||||
* Method: isWindowUnderMouse
|
||||
* Signature: (Ljava/awt/Window)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse(JNIEnv *env, jclass cls,
|
||||
Java_sun_awt_windows_WMouseInfoPeer_isWindowUnderMouse(JNIEnv *env, jclass cls,
|
||||
jobject window)
|
||||
{
|
||||
POINT pt;
|
||||
@ -73,12 +73,12 @@ Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse(JNIEnv *env, jclass cls,
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_DefaultMouseInfoPeer
|
||||
* Class: sun_awt_windows_WMouseInfoPeer
|
||||
* Method: fillPointWithCoords
|
||||
* Signature: (Ljava/awt/Point)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, jobject point)
|
||||
Java_sun_awt_windows_WMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, jobject point)
|
||||
{
|
||||
static jclass pointClass = NULL;
|
||||
static jfieldID xID, yID;
|
||||
@ -95,7 +95,8 @@ Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, j
|
||||
env->DeleteLocalRef(pointClassLocal);
|
||||
}
|
||||
|
||||
int screen = AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
|
||||
HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
||||
int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
|
||||
|
||||
66
jdk/test/java/awt/MouseInfo/PointerInfoCrashTest.java
Normal file
66
jdk/test/java/awt/MouseInfo/PointerInfoCrashTest.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.MouseInfo;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.MouseInfoPeer;
|
||||
import sun.awt.ComponentFactory;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8143316
|
||||
* @modules java.desktop/java.awt.peer
|
||||
* java.desktop/sun.awt.peer
|
||||
* @summary Crash Trend in 1.9.0-ea-b93 (sun.awt.DefaultMouseInfoPeer.fillPointWithCoords)
|
||||
*/
|
||||
public class PointerInfoCrashTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
testMouseInfo();
|
||||
testMouseInfoPeer();
|
||||
}
|
||||
|
||||
private static void testMouseInfo() {
|
||||
// call the getPointerInfo() before graphics devices initialization
|
||||
MouseInfo.getPointerInfo();
|
||||
}
|
||||
|
||||
private static void testMouseInfoPeer() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
if (toolkit instanceof ComponentFactory) {
|
||||
ComponentFactory componentFactory = (ComponentFactory) toolkit;
|
||||
|
||||
MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
|
||||
mouseInfoPeer.fillPointWithCoords(new Point());
|
||||
|
||||
Window win = new Window(null);
|
||||
win.setSize(300, 300);
|
||||
win.setVisible(true);
|
||||
|
||||
mouseInfoPeer.isWindowUnderMouse(win);
|
||||
win.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user