Looking to write a new Bytecode back-end (Gen) for microcontroller VM

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Wed Jul 9 05:01:29 PDT 2008


Niels,

You can use javac's Context mechanism to preRegister your own  
implementation
of Gen.  To do this, you'd want to modify  
com.sun.tools.javac.main.Main to put
a factory for your Gen into the context as soon as the context is  
created.

(There are two ways to preregister code like this -- you can either  
put an instance
in the context directory, or you can put a factory to create an  
instance. In this case,
a factory would likely be better because you do not want to create Gen  
to early
and have it trigger the creation of all the other components on which  
it depends.)

You might also want to use your own impl of ClassWriter as well.

-- Jon

On Jul 8, 2008, at 10:04 PM, Niels Brouwers wrote:

> Hello all,
>
> I hope that this mailing list is the correct medium for asking this
> question. If not, please forgive my intrusion.
>
> I'm writing a Java virtual machine for microcontrollers, and since the
> Java instruction set is not suitable for such platforms (32-bit stack
> width is the main problem) I would like to build my own bytecode
> back-end (Gen).
>
> I've been hacking the compiler a bit today, but found it extremely
> difficult to extend or change the behavior of Javac in a non-intrusive
> way. I would basically like to re-use all of Javac, and simply drop in
> my own bytecode generator visitor.
>
> Before I go further with this I was wondering what the best approach
> would be. Can I keep most of the Javac functionality or do I need to
> write most of it from scratch?
>
> Thanks in advance,
>
> Niels Brouwers




More information about the compiler-dev mailing list