Loading Native Code: Arrays.h, NoSuchMethodError..

Marcos Polanco marcos at imana.com
Wed Dec 17 11:59:34 PST 1997


I've just installed Kaffe on my Solaris 2.5 box, and have had issues
getting native code to load. I'm using sun's latest CC compiler. I have
a single class Foo which implements native code.

(1) Arrays.h refused to compile into my program because arrays must have
at least one element, and the ones defined here are [0]. I made it [1]
to get past the compiler, which I *presume* is OK because I make no use
of Arrays in my program. (I'd love to have a real solution here.)

(2) I am experiencing that Foo's static initializer (which successfully
calls loadLibrary) is getting executed several times, basically once
each time I invoke the said class in some way.

(3) I successfully call a native static method Foo.initialize() from
Java. Good!

(4) When I attempt to call a native instance method from Java, the vm
raises a 'java.lang.NoSuchMethodError'. The method declaration is:

        public native synchronized Result lookup(key);

The call looks like this:

        String name = "bob";
        aFoo.lookup(name);

the method implementation is like this:

        struct HResult *Foo_lookup(struct Foo *aFoo,
                struct Hjava_lang_String *key){
        }

and the .h generated by kaffeh is:

        extern struct HResult *Foo_lookup(struct Foo *aFoo,
                struct Hjava_lang_String *key);

Note that if I (intentionally) misname the function, the result is a
'Failed to locate native function' error instead.

Thanks in advance for you attention.

- marcos

-- 
Marcos J. Polanco       Imana, Inc.
415.436.9700 tel        480 Potrero Ave.
415.436.9793 fax        San Francisco, CA 94110
marcos at imana.com        http://www.imana.com



More information about the kaffe mailing list