8346952: GetGraphicsStressTest.java fails: Native resources unavailable

Reviewed-by: serb
This commit is contained in:
Anass Baya 2025-07-07 04:58:17 +00:00 committed by Sergey Bylokhov
parent 3bcbcc5747
commit 44cff9d6ab
3 changed files with 62 additions and 22 deletions

View File

@ -2498,32 +2498,22 @@ jint AwtWindow::_GetScreenImOn(void *param)
jobject self = (jobject)param;
// It's entirely possible that our native resources have been destroyed
// before our java peer - if we're dispose()d, for instance.
// Alert caller w/ IllegalComponentStateException.
if (self == NULL) {
JNU_ThrowByName(env, "java/awt/IllegalComponentStateException",
"Peer null in JNI");
return 0;
}
PDATA pData = JNI_GET_PDATA(self);
if (pData == NULL) {
JNU_ThrowByName(env, "java/awt/IllegalComponentStateException",
"Native resources unavailable");
env->DeleteGlobalRef(self);
return 0;
}
jint result = -1;
AwtWindow* window = NULL;
jint result = 0;
AwtWindow *w = (AwtWindow *)pData;
if (::IsWindow(w->GetHWnd()))
// Our native resources may have been destroyed before the Java peer,
// e.g., if dispose() was called. In that case, return the default screen.
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
window = (AwtWindow *)pData;
if (::IsWindow(window->GetHWnd()))
{
result = (jint)w->GetScreenImOn();
result = (jint)window->GetScreenImOn();
}
ret:
env->DeleteGlobalRef(self);
return result;
return (result != -1) ? result : AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
}
void AwtWindow::_SetFocusableWindow(void *param)

View File

@ -0,0 +1,50 @@
/*
* Copyright Amazon.com Inc. 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.Window;
/**
* @test
* @bug 8346952
* @summary Verifies no exception occurs when triggering updateCG()
* for an ownerless window.
* @key headful
*/
public final class BogusFocusableWindowState {
public static void main(String[] args) {
Window frame = new Window(null) {
@Override
public boolean getFocusableWindowState() {
removeNotify();
return true;
}
};
try {
frame.pack();
frame.setVisible(true);
} finally {
frame.dispose();
}
}
}

View File

@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
/**
* @test
* @bug 8235638 8235739 8285094
* @bug 8235638 8235739 8285094 8346952
* @key headful
*/
public final class GetGraphicsStressTest {