Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jun 2002 21:20:59 -0700
From:      Alan Batie <alan@batie.org>
To:        freebsd-java@freebsd.org
Subject:   jni symbol resolution problem
Message-ID:  <20020606212059.D87904@agora.rdrop.com>

next in thread | raw e-mail | index | archive | help

--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I'm puzzled, as this was working at one point and I can't see any reason
for it to stop --- I'm hoping someone here will have some insight...
Thanks!

I have a simple JNI function to check for the existence of a specified
login, but java's stopped being able to load it:

Version info:

<agora.rdrop.com> [168] $ java -version
java_X version "1.1.8"
<agora.rdrop.com> [169] $ uname -a
FreeBSD agora.rdrop.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Apr  3 08:52:=
15 PST 2002     root@agora.rdrop.com:/usr/src/freebsd/src/sys/compile/AGORA=
  i386


A simple java test wrapper:

class atest1 {
    //  Check to see if unix login already exists
    private native boolean jlogin_exists(String login);

    //  Static initializer to load the C library
    static {
	System.loadLibrary("apply");
    }

    static public void main(String s[]) {
	if ((new atest1()).jlogin_exists("root")) {
	    System.out.println("good: root exists");
	} else {
	    System.out.println("bad: root doesn't exist");
	}

	if ((new atest1()).jlogin_exists("beezlebub")) {
	    System.out.println("bad: beezlebug exists");
	} else {
	    System.out.println("good: beezlebug doesn't exist");
	}
    }
}

What happens when I run it:

<agora.rdrop.com> [174] $ java atest1
java.lang.UnsatisfiedLinkError: jlogin_exists
        at atest1.main(atest1.java:12)

Ktrace output showing that the symbol is in fact *in* libapply, i.e. it's
finding the library and it seems to be built right:

 88958 java_X   CALL  open(0x2811d100,0,0xbfbfef44)
 88958 java_X   NAMI  "/usr/local/lib/libapply.so"
 88958 java_X   RET   open 5
 88958 java_X   CALL  fstat(0x5,0xbfbfef14)
 88958 java_X   RET   fstat 0
 88958 java_X   CALL  read(0x5,0xbfbfdee4,0x1000)
 88958 java_X   GIO   fd 5 read 4096 bytes
       "\^?ELF\^A\^A\^A \0\0\0\0\0\0\0\0\^C\0\^C\0\^A\0\0\0\^P\^F\0\0004\0\=
0\0\
=2E..
        \0      \0\0_DYNAMIC\0_GLOBAL_OFFSET_TABLE_\0_init\0_fini\0__deregi=
ste\
        r_frame_info\0__register_frame_info\0Java_apply_jcrypt\0time\0srand=
om\
        \0crypt_set_format\0random\0crypt\0Java_apply_jlogin_1exists\0getpw=
nam\
        \0libcrypt.so.2\0_edata\0__bss_start\0_end\0\M-@\^X\0\0\b\0\0\0\b\^=
Y\0\
        \0\^F\^[\0\0\f\^Y\0\0\^F%\0\0\M-h\^X\0\0\a\^V\0\0\M-l\^X\0\0\a\^Z\0=
\0\

The JNI C code:

#include <jni.h>
#include <stdio.h>
#include <unistd.h>
#include "apply.h"

JNIEXPORT jboolean JNICALL
Java_apply_jlogin_1exists(JNIEnv *env, jobject this, jstring login)
{
    const jbyte *clogin;

    //  Convert java Unicode string to UTF-8 (ascii)
    clogin =3D (*env)->GetStringUTFChars(env, login, NULL);
    if (clogin =3D=3D NULL) {
        //  Probably OutOfMemoryError exception;
        //  if so, it has already been thrown
        return NULL;
    }

    return(getpwnam(clogin) !=3D NULL);
}

And I tried it on a system with the latest versions of things:

<pyrex.batie.org> [113] $ java atest1
Exception in thread "main" java.lang.UnsatisfiedLinkError: jlogin_exists
        at atest1.main(atest1.java:12)
<pyrex.batie.org> [114] $ java -version
java version "1.3.1-p6"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-p6-root-02052=
8-22:16)
Classic VM (build 1.3.1-p6-root-020528-22:16, green threads, nojit)
<pyrex.batie.org> [115] $ uname -a
FreeBSD pyrex.batie.org 4.6-RC FreeBSD 4.6-RC #3: Mon May 27 14:40:21 PDT 2=
002     root@pyrex.batie.org:/usr/src/freebsd/src/sys/compile/PYREX  i386

--=20
Alan Batie                   ______    www.rdrop.com/users/alan      Me
alan@batie.org               \    /    www.qrd.org         The Triangle
PGPFP DE 3C 29 17 C0 49 7A    \  /     www.pgpi.com   The Weird Numbers
27 40 A5 3C 37 4A DA 52 B9     \/      razor.sourceforge.net   NO SPAM!

    A free society is a place where it's safe to be unpopular.
    -Adlai Stevenson, statesman (1900-1965)

--YiEDa0DAkWCtVeE4
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iQCVAwUBPQA0qov4wNua7QglAQESqAQAkAeS2XsSgrcKBqJ9A1nlmvO0GQq5D+zF
WtKa5FD68isicDLWPMLM++wTHDdZ7Ob1PnMYP7nO9ntgO6JGjMQN2rIstKNQGXr+
/D2t3i7Y2EEBIA5SVzdIrLCt4NVB642mDOPNxekt10j8g/E3RhSxf+fYuNNpqmBf
eNyAsgdPaXA=
=8IuC
-----END PGP SIGNATURE-----

--YiEDa0DAkWCtVeE4--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020606212059.D87904>