[Mono-list] Mono/Java interop - Usage scenarios
Chris Ball
chris@void.printf.net
Tue, 12 Nov 2002 13:49:38 +0000
<delurk/>
>> On Tue, 12 Nov 2002, Joshua Tauberer <tauberer@for.net> said:
>> 1. Transform Java bytecode to CIL
> I started working on this in my free time in the last few days. I
> used MS's JUMP to import the BCEL (jakarta.apache.org/bcel) library
> to .NET, and I'm using that to convert arbitrary bytecode over to
> CIL. If it ever gets done, it would be able to convert BCEL on its
> own and use that, making the program no longer dependent on MS's
> .NET Java library.
I'm working on a retarget of the Jikes compiler to output CIL, which is
probably easier (but less generalised) than your project; I get to use
Jikes' AST data as some extra context. The hard parts are certainly:
o Mapping class invocations. (So, java.lang.Integer to System.Int32)
o With that, arguments would have to be converted too. For example,
we might give ("a: {0}, b: {1}", a, b) to the CLR, but ("a: " + a +
" b: " + b) to the JVM, as arguments to a print function. (It's a
bad example; System.Console.Writeline would support both formats)
o Mapping OO models. (I'm not even going to go there right now)
o Resolving differences in storage. Java uses the constant pool an
awful lot in ways that the CLR doesn't, and the CLR uses a heap
without any real counterpart.
That's all I've come across, so far. Apart from that, they seem to be
very similarly typed stack-based machines, which looks to have been by
design on the part of the CLR. The layout of stack frames is nearly
identical, as is the bytecode verification process. There are small
differences where the CLR is more dynamic; for example, the overloaded
operators - '{i,f}add' in JBC going to an overloaded 'add' on the CLR.
Since something like Jikes is going to have more type information, we
should be able to pass type explicitly (say, 'ldc.u4' instead of 'ldc'
for pushing a four-byte unsigned int to the stack) and save some
lookup for mono at load-time.
Those are my first impressions, anyway - I'd be interested to hear if
anyone has any thoughts of any of this, or things I've missed. I've
been at it for less than a month. How are things going for you?
Cheers,
- Chris.
--
$a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a
<@jwz> The human genome is about 3 gigabases long, which boils down to
750 megabytes. Depressingly enough, this is only 2.8 Mozilla browsers.