[Mono-list] Mono/Java interop?
Ben Hutchison
ben.hutchison@intamission.com
Thu, 7 Nov 2002 13:59:50 -0000
I see 2 basic strategies for interop between .Net and Java:
1. Bytecode conversion
Cross-compilation, either Java->CIL, or the reverse, so that bytecode
binaries from one format can be converted to the other. I think MS
Java.Net product does this.
Although you can convert the bytecode over, its in large part both
framework's libraries that make them useful. To utilize these also
requires a mapping of the basic platform facilities of one API set to
the other. Eg. a Java String gets converted to a .Net string, a Class to
a Type, etc. One can compile the pure C# or Java components across
format using bytecode conversion, but the native libraries they rest
upon need to be recreated.
Although similar, I don't think the two libraries are close enough to
perform this mapping successfully. I think such an approach will provide
shallow interoperability that initally looks good, but worsens the more
complexity you introduce. My personal feeling is that cross-compilation
(like http://www.go-mono.com/java.html) doesn't add as much value as
"bridging"...
2. Remote call interoperability ("Bridging")
The ability to make remote calls using object types between the two
systems. A brief search of the web shows several companies developing
this type of tech; eg www.jnbridge.com.
The first challenge here is to find a suitable common wire protocol. At
present, there is SOAP (Web Services), but it is weak in both
performance and sematics. Far superior, IMO, would be a binary protocol,
and here the choices are probably either JRMP (the wire protocol of Java
RMI), or the .Net Remoting binary protocol (or finally, IIOP from
Corba). AFAIK, the .Net protocol is neither a standard, nor publicly
doccumented, and this could present IP ownership and compatibility
problems.
The bulk of data flowing down a remote call socket is serialized
objects. Developing a common mapping between Java and .Net object data
is a difficult piece of remote call level interop, a problem similar to
Objects By Value in CORBA. Objects over the wire can be classed into 3
broad categories:
(a) Simple objects & primitives which have a representation in both .Net
and Java - ints, strings, etc. Easily handled.
(b) Handles (ie stubs or references) to remote objects, passed by
reference. Easily handled by generic proxies.
(c) Complex pass-by-value objects which likely as not have no
representation in the other framework; imagine sending eg a
javax.swing.JButton to .Net (remember it cant instatiate it directly as
.Net doesn't understand the Java class definition). How is .Net going to
handle this piece of data?
While I don't think there's a *general* solution for (c), it can be
imporved by building a mapping for a wide variety of common Class-Type
pairs. The similarity between the Java and .Net libraries is striking,
and it seems that most types have a "brother" in the other framework; eg
Collections, Dates & Calendar, Culture/Locale. Such work expands a
"vocabulary" of objects which can be exchanged, making an interop
solution more widely useful and more transparent.
Since this is a .Net focused list, I guess there is greater interest in
making Java work with .Net than the other way round. Therefore,
obtaining or producing some specification of the Remoting binary
protocol seems a critical early step. This may mean reverse-engineering
it from the shared source CLI.
Alternately, I think Daniel Morgans idea of a CORBA channel has merit;
Java already has excellent support for CORBA, and this sidesteps the
need to develop wire protocol code.
This whole interop area is both vital and interesting. Great to see this
discussion happening!
Regards
Ben Hutchison
> -----Original Message-----
> From: mono-list-admin@ximian.com
> [mailto:mono-list-admin@ximian.com] On Behalf Of
> fgonthier@hermes.usherb.ca
> Sent: 06 November 2002 17:23
> To: mono-list@ximian.com
> Subject: [Mono-list] Mono/Java interop?
>
>
> Hello all,
>
> Yesterday I've tought how a Mono/Java bridge could be coded
> and realized that
> this could be an interresting project.
>
> Before I start anything I'd like to know if there is anything
> similar in
> development somewhere.
>
> I'd also like to have quick opinions on how such a things could be
> implemented. I have few design options myself but I'd like
> to know yours to
> see if I'll work the right way.
>
> Frs-Denis Gonthier
>
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GIT/GO d+(-) s a-- C++ UL? P L+(++) E--- W N+ o-- K- w++ O---
> M? V? PS PE Y+
> PGP- t+ 5(+) X-- R tv+ b+ DI+++(++++) D+(++) G-- !e h-- r++ y+
> ------END GEEK CODE BLOCK------
>
> _______________________________________________
> Mono-list maillist - Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>