3

BridJ can not find the methods of a shared library. I need help with understanding why.

The library was generated by JNAerator.

mn -g of lib.so:

         w _Jv_RegisterClasses
         U _Unwind_Resume@@GCC_3.0
00004970 T _Z11CreateClassv
00004960 T _Z11DeleteClassPv
....

Header of the library:

#ifdef __cplusplus
extern "C" {
#endif;
void* CreateClass(void);
void  DeleteClass(void* hClass);
....

Java code:

@Runtime(CRuntime.class) 
public class MobileclientLibrary {
    static {
        BridJ.register();
    }
    public static Pointer<? > CreateClass() {
         return Pointer.pointerToAddress(CreateClass$2());
    }
    @Ptr 
    @Name("CreateClass") 
    protected native static long CreateClass$2();

    public static void DeleteClass(Pointer<? > hClass) {
        DeleteClass(Pointer.getPeer(hClass));
    }
    protected native static void DeleteClass(@Ptr long hClass);
    ...

When run this application in the logs:

Mar 12, 2013 2:13:53 PM org.bridj.BridJ log
INFO: Failed to get address of method protected static native void Mobileclient.MobileclientLibrary.DeleteClass(long)

But method CreateClass is successfully found.

Why is that?

Magnilex
  • 11,584
  • 9
  • 62
  • 84
davydes
  • 105
  • 9
  • You library class is missing the `@Library("Mobileclient")` annotation. Is it just a copy-paste issue? – zOlive Jul 04 '13 at 12:32

1 Answers1

0

This error message means there is a method declared in your header but not implemented in your library. Verify that DeleteClass() is in fact implemented in the library JNAerator is referencing.

Magnilex
  • 11,584
  • 9
  • 62
  • 84
Nikordaris
  • 2,297
  • 5
  • 20
  • 30
  • I think it's bug of JNarator or BridJ, because when i implemented the library manually like described documentation of BridJ and it works fine, now. – davydes Mar 29 '13 at 08:31