JDK-6805157 : Bad global or local ref passed to JNI with Java6u12 when -Xcheck:jni
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u12
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-02-13
  • Updated: 2011-02-16
  • Resolved: 2009-02-13
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When running our application with the -Xcheck:jni VM flag, we get:
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:291)
        at java.lang.Thread.run(Thread.java:619)
whenever a dialog box is disposed

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the test case code with the -Xcheck:jni VM flag, click on the button and the exception should be produced


ERROR MESSAGES/STACK TRACES THAT OCCUR :
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:291)
        at java.lang.Thread.run(Thread.java:619)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package javaapplication1;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;

// run with -Xcheck:jni flag
public class Main
{
  public static void main(String[] args)
  {
      final JDialog dlg = new JDialog();
      JButton btn = new JButton("Hit me!");
      btn.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          dlg.dispose();
        }
      });
      dlg.getContentPane().add(btn);
      dlg.pack();
      dlg.setModal(true);
      dlg.setVisible(true);
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Stopped using the -Xcheck:jni flag

Release Regression From : 6u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.