JDK-6610244 : modal dialog closes with fatal error if -Xcheck:jni is set
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u10,6u12,7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    windows,windows_2000,windows_xp,windows_vista windows,windows_2000,windows_xp,windows_vista
  • CPU: generic,x86
  • Submitted: 2007-09-27
  • Updated: 2012-06-05
  • Resolved: 2008-05-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u14Fixed 7 b27Fixed OpenJDK6Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
Using JDK7 run sample with a modal dialog like Font2DTest from the jfc folder:
..\JDK7.0b19\bin\java -Xcheck:jni -jar Font2DTest.jar

Steps to reproduce:
1) Open File menu
2) select Print menu item
3) press Cancel button in the appeared dialog

FATAL ERROR in native method: Bad global or local ref passed to JNI
        at sun.awt.windows.WToolkit.eventLoop(Native Method)
        at sun.awt.windows.WToolkit.run(WToolkit.java:285)
        at java.lang.Thread.run(Thread.java:659)

Reproducible always. Not reproducible with JDK6.

Comments
SUGGESTED FIX --- awt_Window.cpp 2008-01-11 20:06:20.000000000 +0300 *************** *** 2143,2149 **** { TRY; ! AwtWindow::wwindowPeerCls = cls; AwtWindow::getActiveWindowsMID = env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J"); DASSERT(AwtWindow::getActiveWindowsMID != NULL); --- 2143,2149 ---- { TRY; ! AwtWindow::wwindowPeerCls = (jclass)env->NewGlobalRef(cls); AwtWindow::getActiveWindowsMID = env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J"); DASSERT(AwtWindow::getActiveWindowsMID != NULL);
11-01-2008

EVALUATION I tracked the crash up to the place where we get the array of active windows in AwtDialog: void AwtDialog::ModalActivateNextWindow(HWND dialogHWnd, jobject dialogTarget, jobject dialogPeer){ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(AwtWindow::wwindowPeerCls, awtWindow::getActiveWindowsMID)); Seem that the AwtWindow::wwindowPeerCls member has Local instead of Global reference as its value. Searching the place where the assignment happens I found: Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls) { TRY; AwtWindow::wwindowPeerCls = cls; AwtWindow::getActiveWindowsMID =... Should wrap it into GlobalRef before using from the other thread. Perhaps the change caused that code to be called on a different thread and caused this to happen went into early JDK7 build.
11-01-2008

EVALUATION _endModal() function exits with error code.
27-09-2007