[ANN] rjni: Java binding for Ruby through JNI -- tech. preview

[this message was first rejected by SpamAssassin :slight_smile: ]

More information at http://www.thekode.net/ruby/rjni

                rjni: Java binding for Ruby through JNI

Copyright (c) 2003 Mauricio Julio Fernández Pradier

WARNING: This is a technology preview. The software is not even alpha
quality at the moment and is not meant to be used yet. It is only
provided to present the techniques employed and (hopefully) to
accelerate the development.

Feedback: please don’t hesitate to contact me to criticize, suggest new
features or help with the development :slight_smile:

License

For the time being, the same as Ruby. Might switch to LGPL in the future.

Status

 * The APIs are quickly stabilizing.
 * The base layer still needs some work and further testing.
 * Several low-level issues remain to be solved.
 * The higher-level APIs have yet to be documented and tested rigorously.

What is rjni?

rjni exposes the Java Native Interface to Ruby. This allows the programmer
to instantiate Java objects, manipulate them, define Java classes, etc…
from Ruby.

Note that rjni is not meant to embed Ruby into Java, although it can be
used to ease integration in that case.

Building

This technology preview is meant to illustrate the possibilities offered
by rjni. It is by no means a usable library yet. The build process is
quite tricky, as it involves linking against the Java libraries and is
therefore highly system-dependent.

The steps are:
1. creating the Makefile. This is done by executing

ruby extconf.rb
–with-jsdk-include=/usr/local/java/j2sdk1.4.1/include/
–with-jsdk-lib=/usr/local/java/j2sdk1.4.1/jre/lib/i386/
–with-jsdk-so-include=/usr/local/java/j2sdk1.4.1/include/linux/

   You have to replace the paths above by the appropriate values for your
   local Java installation. Note that rjni has been tested with Blackdown
   1.4.1, and, although it should be possible to build it with other
   JSDKs, compilation and/or linking might fail unless you get the above
   options right and/or modify extconf.rb itself (or end up modifying the
   Makefile by hand :)
2. Compiling

make


3. You can now run the tests:


./tc_all.sh

   You will notice a short pause after the execution of the script. This
   is normal and expected at the moment.
4. High-level API demo:


./test_reflect.sh

Problems

Compilation

   Were you to experience difficulties when compiling, you'd have to make
   sure that the appropriate -rpath and/or -L options are passed to gcc.

Execution

   Sometimes ld.so will be unable to resolve symbols at runtime; you will
   then need to set the LD_LIBRARY_PATH environment variable
   to some sensible value.

APIs

   RJNI will have at least 3 APIs:
      * RJNI: a low-level straight-forward mapping of the Java Native
        Interface to Ruby. All operations on Java objects and classes are
        ultimately performed through this layer.
      * RJNI::Java: a direct conversion of java.lang.reflect and
        associated classes to Ruby. It is built upon RJNI.
      * RJNI::Reflect: magic reflection of Java objects to Ruby, such
        that they can seemingly be manipulated exactly like Ruby objects.
        This involves automatic method dispatching, singleton class
        abstraction (static methods become singleton methods of the class
        object), some automatic type conversions, attribute setters and
        getters, etc.
···

–
_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Linux: Where Don’t We Want To Go Today?
– Submitted by Pancrazio De Mauro, paraphrasing some well-known sales talk

Does it work using something similar to the Java Native Interface (ie.
through a C API)?

···

On Sat, Jul 05, 2003 at 11:02:20AM +0900, Tim Sutherland wrote:

In article 20030703143112.GA11662@student.ei.uni-stuttgart.de, Mauricio
Fernández wrote:
[…]

What is rjni?

rjni exposes the Java Native Interface to Ruby. This allows the programmer
to instantiate Java objects, manipulate them, define Java classes, etc…
from Ruby.
[…]

In a related note, I’m working on a small library to allow C# and Ruby
to call each others’ methods (and properties/fields.) It somewhat works
now, I just need to work on some technical issues and write documentation.

–
_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

How do you power off this machine?
– Linus, when upgrading linux.cs.helsinki.fi, and after using the machine for several months

calling C# libs means calling the entire .net CTS-compatible stuff ?

seems great!

···

il Sat, 5 Jul 2003 02:00:22 +0000 (UTC), Tim Sutherland timsuth@ihug.co.nz ha scritto::

In a related note, I’m working on a small library to allow C# and Ruby
to call each others’ methods (and properties/fields.) It somewhat works
now, I just need to work on some technical issues and write documentation.