#39 Java/JNI: Generate method that registers methods with a VM

open
None
5
2006-09-01
2006-07-14
Dennis
No

Goal:
----------------------
- Make SWIG usefull for programs that can not
be compiled as a DLL/.so
- Avoid use of System.loadLibrary in Java Code

Idea:
----------------------
- Modify Source/Modules/java.cxx
- Generate an extra method that calls the JNI function
RegisterNatives() to register the native methods
associated with a class
- This method should get a pointer to an instantiated VM,
e.g. some_name(JavaVM *jvm);

I would be gratefull if the Java maintainer could
either implement this functionality or provide me with
some information on how to integrate that into SWIG
since I am not familiar with the SWIG code at all.

Thank you, Dennis

Discussion

  • William Fulton

    William Fulton - 2006-09-01
    • assigned_to: nobody --> wsfulton
     
  • William Fulton

    William Fulton - 2006-09-01

    Logged In: YES
    user_id=242951

    If you could send me a working example of what you require
    (what the generated code would do), I'll take a look at how
    this could be implemented.

     
  • Mark Donszelmann

    Logged In: YES
    user_id=800216

    We actually modified SWIG 1.3.29 to do this.

    Goal
    -------------
    - Use a library which we only have in Java, from C++.

    Implementation
    ---------------
    - Mods to insert code to start JavaVM.
    - Mods to java.cxx to handle call to registration of methods.
    - Generation of calls for all classes to register their methods.

    It is all a bit crude still, but does seem to work.
    If there is a general interest by the SWIG team (Java) for
    this, I would be happy to send in my changes.

    Regards
    Mark Donszelmann

     
  • Andras Varga

    Andras Varga - 2006-12-29

    Logged In: YES
    user_id=933227
    Originator: NO

    I have written a Perl script to generate the registerNatives() code from the xxxJNI.java file, but I'd really prefer if such functionality would be built into SWIG itself.

    In any case I'm willing to share the Perl script if there's interest.

    Andras

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks