8149151: Use local GraphicsEnvironment to get screen size in WToolkit
Reviewed-by: prr, serb
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Thu Feb 04 14:27:16 2016 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Sat Feb 06 09:25:56 2016 -0800
@@ -641,10 +641,21 @@
GraphicsEnvironment.getLocalGraphicsEnvironment();
return ge.getXResolution();
}
+
@Override
- protected native int getScreenWidth();
+ protected int getScreenWidth() {
+ return GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration()
+ .getBounds().width;
+ }
+
@Override
- protected native int getScreenHeight();
+ protected int getScreenHeight() {
+ return GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration()
+ .getBounds().height;
+ }
+
private native Insets getScreenInsets(int screen);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp Thu Feb 04 14:27:16 2016 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp Sat Feb 06 09:25:56 2016 -0800
@@ -2347,53 +2347,6 @@
/*
* Class: sun_awt_windows_WToolkit
- * Method: getScreenWidth
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_windows_WToolkit_getScreenWidth(JNIEnv *env, jobject self)
-{
- TRY;
-
- int width = ::GetSystemMetrics(SM_CXSCREEN);
-
- if (!Devices::GetInstance()) {
- Devices::UpdateInstance(env);
- }
- Devices::InstanceAccess devices;
- AwtWin32GraphicsDevice *device = devices->GetDevice(
- AwtWin32GraphicsDevice::GetDefaultDeviceIndex());
-
- return (device == NULL) ? width : device->ScaleDownX(width);
- CATCH_BAD_ALLOC_RET(0);
-}
-
-/*
- * Class: sun_awt_windows_WToolkit
- * Method: getScreenHeight
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_windows_WToolkit_getScreenHeight(JNIEnv *env, jobject self)
-{
- TRY;
-
- int height = ::GetSystemMetrics(SM_CYSCREEN);
-
- if (!Devices::GetInstance()) {
- Devices::UpdateInstance(env);
- }
- Devices::InstanceAccess devices;
- AwtWin32GraphicsDevice *device = devices->GetDevice(
- AwtWin32GraphicsDevice::GetDefaultDeviceIndex());
-
- return (device == NULL) ? height : device->ScaleDownY(height);
-
- CATCH_BAD_ALLOC_RET(0);
-}
-
-/*
- * Class: sun_awt_windows_WToolkit
* Method: getSreenInsets
* Signature: (I)Ljava/awt/Insets;
*/
--- a/jdk/test/java/awt/Toolkit/GetSizeTest/GetScreenSizeTest.java Thu Feb 04 14:27:16 2016 +0300
+++ b/jdk/test/java/awt/Toolkit/GetSizeTest/GetScreenSizeTest.java Sat Feb 06 09:25:56 2016 -0800
@@ -23,7 +23,7 @@
/*
@test
- @bug 8144074 8145785
+ @bug 8144074 8145785 8149151
@summary Crash while getting screen size during Toolkit initialisation
@run main/othervm GetScreenSizeTest
*/