TransJVM Logo

What is TransJVM?

TransJVM is a Java package to assist compiler writers targeting the Java Virtual Machine. It provides a simple logical interface for creating JVM classes, expressed in terms of Methods, Fields, Statements and Expressions. JVM details are hidden. TransJVM is designed to be fast rather than optimizing, ie. to produce code quickly rather than produce quick code. It is primarily aimed at interpreter writers, although compiler writers would merely need to add a peephole optimisation phase. It will also be useful for any application where reflection is used, since the performance gains are substantial and it adds only a little complexity to the application.

Features of TransJVM

  • Ease of use:  TransJVM screens the programmer from the details of the JVM almost completely. The API is composed of a simple heirarchy, consisting of classes, methods, statements and expressions.
  • Speed:  TransJVM objects are small and designed to produce bytecode with the minimum of overhead.
  • Extensibility:  All languages differ in semantics. TransJVM allows Statements and Expressions to be overridden to match the semantics of the source language.

What TransJVM is not

  • A bytecode framework:  TransJVM is designed for writing JVM bytecode, not for manipulation or decoding of that bytecode. However the Statement/Expression tree can be manipulated via the Visitor interface, although this requires more work on the part of the programmer.
  • An optimiser:  Producing the fastest possible code is not an aim of TransJVM, although careful use can (and should) produce code that is reasonably efficient both it terms of size and performance. Since a compiling JVM will compile any heavily used code, this should be acceptable.

Learning more

TransJVM comes with full Javadoc documentation and several examples, if you have any questions after you have looked at the documentation please email me.

Java 5

TransJVM has been updated to use Java 5.. See the API for details.