Drag & Drop and JNI Error

V

Vincent Cantin

Hello,

I was doing a drag & drop (DnD) with a simple JComponent, but it made my IDE
crash. Later, I discovered the option "-Xcheck:jni" in the command line of
the jvm and now I start to see why it crashed. Now when I start a DnD with
this option, the following message is displayed on the console and the JVM
stop.

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:262)
at java.lang.Thread.run(Thread.java:534)


I reduiced to the minimum the code to isolate the problem and it seems to
crash on a really simple example.
Here is the reduiced program which make the JVM crash when using the
"-Xcheck:jni" option :



import java.awt.event.*;
import javax.swing.*;

public class BugComponent extends JLabel {

public BugComponent()
{
setText("Drag me and Bug");
setTransferHandler(new TransferHandler("text"));
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
JComponent component = (JComponent) event.getSource();
TransferHandler handler = component.getTransferHandler();
handler.exportAsDrag(component, event, TransferHandler.COPY);
}
});
}

public static void main(String[] args)
{
JFrame f = new JFrame();
f.getContentPane().add(new BugComponent());
f.setSize(100, 100);
f.show();
}

}


Someone know how to find a way to not make the JVM crash ??

Thank you,
Vincent Cantin
 
V

Vincent Cantin

I just tried the demo "LabelDnD" from the official tutorial of Java on the
website of SUN
(http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html), and the
result is EXACTLY THE SAME !


C:\JBuilderX\jdk1.4\bin\javaw -classpath "C:\Documents and
Settings\user\jbproject\age\classes;C:\JBuilderX\jdk1.4\demo\jfc\Java2D\Java
2Demo.jar;C:\JBuilderX\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\JBuild
erX\jdk1.4\jre\javaws\javaws.jar;C:\JBuilderX\jdk1.4\jre\lib\charsets.jar;C:
\JBuilderX\jdk1.4\jre\lib\ext\dnsns.jar;C:\JBuilderX\jdk1.4\jre\lib\ext\ldap
sec.jar;C:\JBuilderX\jdk1.4\jre\lib\ext\localedata.jar;C:\JBuilderX\jdk1.4\j
re\lib\ext\sunjce_provider.jar;C:\JBuilderX\jdk1.4\jre\lib\im\indicim.jar;C:
\JBuilderX\jdk1.4\jre\lib\im\thaiim.jar;C:\JBuilderX\jdk1.4\jre\lib\jce.jar;
C:\JBuilderX\jdk1.4\jre\lib\jsse.jar;C:\JBuilderX\jdk1.4\jre\lib\plugin.jar;
C:\JBuilderX\jdk1.4\jre\lib\rt.jar;C:\JBuilderX\jdk1.4\jre\lib\sunrsasign.ja
r;C:\JBuilderX\jdk1.4\lib\dt.jar;C:\JBuilderX\jdk1.4\lib\htmlconverter.jar;C
:\JBuilderX\jdk1.4\lib\tools.jar;C:\JBuilderX\jdk1.4\jre\lib\ext\jogl.jar"
-Xcheck:jni LabelDnD

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:262)
at java.lang.Thread.run(Thread.java:534)


.... snif .. what can I do in such a working condition :'(
 
V

Vincent Cantin

Hello,
I was doing a drag & drop (DnD) with a simple JComponent, but it made my IDE
crash. Later, I discovered the option "-Xcheck:jni" in the command line of
the jvm and now I start to see why it crashed. Now when I start a DnD with
this option, the following message is displayed on the console and the JVM
stop.

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:262)
at java.lang.Thread.run(Thread.java:534)


I reduiced to the minimum the code to isolate the problem and it seems to
crash on a really simple example.
Here is the reduiced program which make the JVM crash when using the
"-Xcheck:jni" option :



import java.awt.event.*;
import javax.swing.*;

public class BugComponent extends JLabel {

public BugComponent()
{
setText("Drag me and Bug");
setTransferHandler(new TransferHandler("text"));
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
JComponent component = (JComponent) event.getSource();
TransferHandler handler = component.getTransferHandler();
handler.exportAsDrag(component, event, TransferHandler.COPY);
}
});
}

public static void main(String[] args)
{
JFrame f = new JFrame();
f.getContentPane().add(new BugComponent());
f.setSize(100, 100);
f.show();
}

}


Someone know how to find a way to not make the JVM crash ??

Thank you,
Vincent Cantin


The bug report is now on the website of Sun at
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5082481 ... for thoses
who want to know the eventual source of their DnD crashes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top