This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Does -fjni work with recent builds?

  RCS file: /cvs/gcc/egcs/gcc/java/expr.c,v
  retrieving revision 1.96
  diff -u -p -r1.96 expr.c
  --- expr.c      2001/01/17 00:39:09     1.96
  +++ expr.c      2001/01/20 02:26:45
  @@ -2024,6 +2024,7 @@ build_jni_stub (method)
     TREE_STATIC (meth_var) = 1;
     TREE_PUBLIC (meth_var) = 0;
     DECL_EXTERNAL (meth_var) = 0;
  +  DECL_CONTEXT (meth_var) = method;
     make_decl_rtl (meth_var, NULL);
     meth_var = pushdecl_top_level (meth_var);

Yes, this solves the compilation problem.

There may still be a package name problem.  The following combination of java and c works:

// package A;

public class JniTest {

    public native void jnitestc();
    public static native void jnistaticfn();

    static {

    public JniTest() {
      System.err.println("Hello world, from JniTest constructor.");

    public static void main(String[] argv) {
        new JniTest();

#include <stdio.h>
#include <jni.h>

/* extern void JNICALL Java_A_JniTest_jnitestc(JNIEnv *env,jobject jo) { *
extern void JNICALL Java_JniTest_jnitestc(JNIEnv *env,jobject jo) {
  printf("Hello world, from jnitestc.\n");


/* extern void JNICALL Java_A_JniTest_jnistaticfn(JNIEnv *env,jclass jc)) { */
extern void JNICALL Java_JniTest_jnistaticfn(JNIEnv *env,jclass jc)) {
    printf("Hello world, from jnistaticfn.\n");

( The library was created with ld -shared -o jnitestc.o)

However,  if  I use the package name A (see the commented lines,above), on execution we get the following error:

Exception in thread "main" java.lang.AbstractMethodError: jnistaticfn
   at 0x4019b219: java::lang::Throwable::Throwable(java::lang::String*) (/usr/local/gcc/lib/
   at 0x4018ec40: java::lang::Error::Error(java::lang::String*) (/usr/local/gcc/lib/
   at 0x40190f60: java::lang::LinkageError::LinkageError(java::lang::String*) (/usr/local/gcc/lib/
   at 0x4018fc20: java::lang::IncompatibleClassChangeError::IncompatibleClassChangeError(java::lang::String*) (/usr/local/gcc/lib/
   at 0x40189d10: java::lang::AbstractMethodError::AbstractMethodError(java::lang::String*) (/usr/local/gcc/lib/
   at 0x40162943: _Jv_LookupJNIMethod (/usr/local/gcc/lib/
   at 0x0804b857: A::JniTest::jnistaticfn() (/home/moi/GCJ_JavaTree/A/
   at 0x0804b8ec: _ZN1A7JniTest_003cclinit_003eEvU (/home/moi/GCJ_JavaTree/A/
   at 0x40179b13: java::lang::Class::initializeClass() (/usr/local/gcc/lib/
   at 0x40176a39: gnu::gcj::runtime::FirstThread::run() (/usr/local/gcc/lib/
   at 0x40181acb: java::lang::Thread::run_(java::lang::Object*) (/usr/local/gcc/lib/
   at 0x402a2d5a: _Jv_ThreadStart(java::lang::Thread*, int*, void (*)(java::lang::Thread*)) (/usr/local/gcc/lib/
   at 0x40181bff: java::lang::Thread::start() (/usr/local/gcc/lib/
   at 0x4015fea2: JvRunMain (/usr/local/gcc/lib/
   at 0x0804b933: main (/tmp/ccjYla8Mmain.i:0)
   at 0x40476a5e: __libc_start_main (/lib/
   at 0x080490d1: _start (??:0)

Note that this only occurs for the static method in the package.  Without the call to the static method, the package name is resolved correctly.

(Personally, I'd like to see change checked in even if the static reference problem can't be resolved at the present.)

Thanks and regards,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]