[erlang-questions] jinterface - type conversion

Vlad Dumitrescu <>
Sat Jul 25 23:25:14 CEST 2009


On Fri, Jul 24, 2009 at 18:22, Camilo
Cerchiari<> wrote:
> my question is:  is there any reason for not having such an
> OtpErlangObject.getValue() method?

Hi,

One reason is that some mappings between erlang and java types aren't
one-to-one. For example, there are a lot of java types mapping to the
erlang integer type. Also, the atom 'true' can be translated as a
string or as a boolean.

Another reason is IMHO that when jinterface was written, the author
didn't have a lot of experience with OOP, so the result can be
improved. Unfortunately, backwards compatibility is in the way. The
solution would be to write another library (like it was done for the C
mappings), but I guess that's not high priority.

In the meantime, you can check the code in erlide, where we have
implemented a lot of additions to jinterface.
http://erlide.svn.sourceforge.net/viewvc/erlide/trunk/org.erlide.jinterface/

There are helpers for converting between erlang and java and back,
using signature strings to let the programmer know what kind of data
he wants/provides. We have "sprintf"-like methods for building erlang
terms more easily in Java, and pattern matching methods to take those
terms apart. There is even some incomplete support for generating
bridging code to allow calling Java methods from Erlang, should the
need arise.

best regards,
Vlad


More information about the erlang-questions mailing list