🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3303

Bug in JNI. Need help.

#3303
From: Alec Dorfman
Date: Thu, 12 Feb 1998 00:00
98 lines
3310 bytes
Hi All,

I ran across the problem while trying to use native methods in JBuilder
� excuition of the native method causes the folowing exception

Exception occurred during event dispatching:
java.lang.NullPointerException

When I put  try/catch around I got:

exception java.lang.NullPointerException
Exception occurred during event dispatching:
java.lang.InternalError: undefined opcode
        at
        at
test_print.Frame1_buttonControl1_actionAdapter.actionPerformed(Compiled
Code)
        at borland.jbcl.util.ActionMulticaster.dispatch(Compiled Code)
        at borland.jbcl.view.BeanPanel.processActionEvent(Compiled Code)

        at borland.jbcl.view.ButtonView.processMouseReleased(Compiled
Code)
        at borland.jbcl.view.BeanPanel.processMouseEvent(Compiled Code)
        at java.awt.Component.processEvent(Compiled Code)
        at java.awt.Container.processEvent(Compiled Code)
        at borland.jbcl.view.BeanPanel.processEvent(Compiled Code)
        at java.awt.Component.dispatchEventImpl(Compiled Code)
        at java.awt.Container.dispatchEventImpl(Compiled Code)
        at java.awt.Component.dispatchEvent(Compiled Code)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)

exception java.lang.NullPointerException


Interestingly enough  - the exception ONLY occurs when the application
is executed within JBuilder IDE.
Running trough the debbuger, outside IDE  using Borland�s JVM or using
Sun�s JVM was ALWAYS SUCCESSFUL.

Trying to resolve the problem I eliminated  99.99% of my code � the
problem still persist.

So here it is:

//Java class that has one native method in JB.java
package jj;
public class JB {
 public native int f0();
 static {
  System.loadLibrary("JB");
 }
}


//Native method implementation in JB.c
#include "jj_JB.h"
JNIEXPORT jint JNICALL Java_jj_JB_f0(JNIEnv *env , jobject this) {
 return 0;
}

I am using MSoft compiler and the following make file

JAVA=I:\JBuilder\Java
INCLUDES= -I.  -I$(JAVA)\include
LIBS=  user32.lib kernel32.lib advapi32.lib
JLIB=$(JAVA)\Lib\javai.lib
CLASSES=.;$(JAVA)\LIB\classes.zip;
JAVAH=$(JAVA)\bin\javah.exe
JAVAC=$(JAVA)\bin\javac.exe
JB.dll: JB.obj
 link -DLL -out:JB.dll JB.obj $(LIBS)  $(JLIB)
 del *.obj
 del *.exp
 del *.lib
JB.obj: JB.c JB.h
        cl -c -W3 -MT $(INCLUDES) -D_WIN32 -DXP_PC JB.c
JB.h: JB.class
 $(JAVAH) -jni  -classpath $(CLASSES) jj.JB
JB.class: JB.java
 $(JAVAC) -d . JB.java

JB.dll  goes to PATH.  JB.class goes to CLASSPATH.

If JB�s method f0() is executed as an action:


void buttonControl1_actionPerformed(ActionEvent e) {
jj.JB jb=new jj.JB();
for(int i=0;i<200;i++)
         jb.f0();
}

java.lang.NullPointerException if  thrown.

 Looks like a bug to me. Any ideas?

/alec
Technical Details
Message-ID: <34E38636.B6CB5E33@nevaobject.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,62987de87bde9144,start
X-Google-Attributes: gid1089d0,public
From: Alec Dorfman <alec@nevaobject.com>
Subject: Bug in JNI. Need help.
Date: 1998/02/12
Message-ID: <34E38636.B6CB5E33@nevaobject.com>
X-Deja-AN: 324682012
Content-Transfer-Encoding: 8bit
Mime-Version: 1.0
Reply-To: alec@nevaobject.com
Content-Type: text/plain; charset=iso-8859-1
Organization: None
Newsgroups: borland.public.jbuilder.java.api