Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6610244
Votes 0
Synopsis modal dialog closes with fatal error if -Xcheck:jni is set
Category java:classes_awt
Reported Against
Release Fixed 7(b27), 6u14(b01) (Bug ID:2170104)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 6776193 , 6805157
Submit Date 27-SEP-2007
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.
Posted Date : 2007-09-27 11:06:44.0
Work Around
N/A
Evaluation
_endModal() function exits with error code.
Posted Date : 2007-09-27 11:06:44.0

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.
Posted Date : 2008-01-11 17:15:08.0
Comments
  
  Include a link with my name & email   

Submitted On 17-FEB-2009
cowwoc
This needs to be back-ported to JAva6 update 12.



PLEASE NOTE: JDK6 is formerly known as Project Mustang