[erlang-questions] rpc from erlang to java

Zac Brown zac@REDACTED
Wed Aug 15 15:03:41 CEST 2007


I'm quite interested in this project as I work with some computational
models that are written in Java. I'd like to write a distribution system
for the cluster I have here in Erlang since msg passing in Erlang is
much nicer than trying to fight with Java's RMI. I'll be keeping tabs on
 this :).

Zac

Vlad Dumitrescu wrote:
> Hi all,
> 
> I'm not sure how many people are interacting with Java from Erlang,
> but I am (for ErlIDE) and I just implemented a nice feature (if I may
> say so myself) that might of interest: the ability to call Java code
> from Erlang.
> 
> The reason I needed this is that I want to move as much erlide core
> functionality from Java code to Erlang code, but doing it without rpcs
> would have meant writing an awful lot of wrapper classes around the
> Eclipse API.
> 
> So what I can do now (work is still in progress) is for example
>   {ok, Map} = jrpc:call("java.util.HashMap", "HashMap", []),
>   jrpc:call(Map, "put", "theKey", {some, kind, of value}),
> 
> The conversion layer converts between Erlang terms and Java objects,
> almost seamlessly (atoms aren't easy to translate, for example) and
> uses reflection to resolve and invoke the proper methods. Type
> translation is trying to be clever, for example strings are
> represented by native types, likewise integers. Lists correspond to
> java.util.Lists and tuples to arrays.
> 
> Objects can also be sent back and forth, by storing them in a map and
> converting to unique references.
> 
> Beside 'call's, there is support for 'cast's and 'event's. The latter
> are async messages to which one can subscribe for notification on the
> Java side.
> 
> The functionality is similar to what the corba interface provides, but
> it's at the same time simpler (no idl descriptions are needed) and
> more naive, and more powerful (since objects can be sent). I am
> working on a tool to generate erlang stubs that would make the above
> example look something like
>   {ok, Map} = java_util_HashMap:'HashMap'(),
>   java_util_HashMap:put(Map, "theKey", value),
> 
> Of course, this isn't a general solution, and it is very slow to use
> as in the example above. One would still want to write special
> interface classes that would do much more work per call.
> 
> There are also issues still to be resolved (like memory management and
> concurrency issues), but I thought that someone might be interested
> and find it useful. The code is part of Erlide but I tried to keep it
> generic, so it can be extracted to a standalone library, if needed.
> 
> best regards,
> Vlad
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list