Jinterface question

Per Bohlin per.bohlin@REDACTED
Wed Feb 23 15:19:13 CET 2000

Gordon Beaton wrote:
> On 23 Feb 2000 10:14:00 GMT, Per Bohlin wrote:
> > > I also have a question about the functionallity of JInterface.
> > > At first I thought that it provided the same functionallity to JAVA
> > > that you get to C when using erl_interface.
> > > I've used erl_interface a bit in a User Interface tool where
> > > C++ objects are represented with Erlang PID's.
> > > When receiving messages from erlang a dictionary is used to keep
> > > track of which object to transfer the message to based on the pid
> > > that the message is sent to. So effectivly the erlang side can send
> > > messages to C++ objects (represening windows) as if they where Erlang
> > > processes.
> > >
> > > In JInterface it is possible to create Erlang PIDs on the java side.
> > > But, I have not found any way of getting the PID that the Erlang message
> > > was sent to. The messages just ends up in the OtpConnection.receive
> > > without reference to the PID that the message was sent to.
> > >
> > > Is there a way to find the PID that the message was sent to?
> > > (And possibly also the PID of the process that the message was sent
> > > from, I don't need it but it is there in erl_interface)
> This was a design decision. I thought about returning the received
> message inside another object along with the header information, but
> one of the goals with Jinterface was to provide something that was a
> lot easier to use than erl-interface and in particular had a lower
> learning threshold.
> For example, all outgoing messages appear to come from the same Erlang
> Pid, you don't need to make them up in order to send messages to
> Erlang. By the same token, you don't get to find out what Pid messages
> were sent to. It's possible that this decision should be reevaluated.
> If you need to dispatch incoming messages to different receivers you
> can still do it quite easily by including the intended recipient in
> the body of the message: { pid, msg } or similar. The recipient
> doesn't even need to be a pid in this case, for example if you use an
> integer then you can switch on it.
This is exactly what I have done. But if you can diferentiate between
pids on the java side it is possible to make it behave like an erlang
containing erlang processes to which any process on the erlang side
sends messages
as if there where running in an other erlang node. I think that is quite

I agree that erl_interface to some extent is more compicated in the
sence that you have
to retreive the message from a c-structure instead of getting the
message directly.
And I think it should continue to be like that, 

What I would like is either an more advanced function in which you get
poth the pid
and the message, or a function to call after you have retreived the
that retruns the pid the last message was sent to. These functions would
then not be used
if they are not wanted.


> /gordon
> --
> g o r d o n . b e a t o n @ e r i c s s o n . c o m
> please no spam, chain letters or virtual postcards!

More information about the erlang-questions mailing list