Next: Perl-Specific Challenges Up: Porting Challenges Previous: Porting Challenges   Contents

General Challenges

Porting a new language to the JVM is a bit more complicated than the typical problem of targeting to a new chip-set. The JVM bytecode is at a higher level than most assemblers, and thus more care must be taken when generating code.

For example, for a JVM port to be effective, it must emit code that can pass the bytecode verification process. Proper bytecode verification is more than just a rubber-stamp; some JVMs simply reject code that cannot be verified. Other JVMs might support code without verification, but JVMs are rarely regression tested with unverified code. Bugs are commonly found in JVMs when unverifiable code is run. Finally, there is the problem that unverifiable code can never run as applets.

Therefore, any JVM code emitted by a compiler must be verifiable. To emit verifiable code, it usually means that some operations that seem completely legal given the JVM specification are not possible. Therefore, a compiler writer must not only be intimately familiar with the JVM specification, but must also be aware of the specific expectations of the verification process. (Section 4.5 describes trouble encountered in this work with the JVM bytecode verifier.)

Another challenge faced when porting to the JVM is its object oriented nature. First, the compiler writer must find a way to reasonably map a particular language structure onto the JVM concept of a class. Most languages have a comparable structure to a class (e.g., lambda in Scheme, or packages in Perl). However, the details are sometimes tricky. For example, in Scheme, generating a class for every single lambda in a program can be a performance hit, if not done with great care.

Finally, for a JVM port to be as useful as possible, the compiler must generate code that is aware of the JVM object model. If this is not done, the port will likely be functional, but will not reap the advantages discussed in Section 1.2.3. This issue represents the biggest challenge of a JVM port, particularly when integration with other non-Java languages is desired. Clear object interfaces must be defined for inter-language access to be successful.


Next: Perl-Specific Challenges Up: Porting Challenges Previous: Porting Challenges   Contents

Copyright © 2000, 2001 Bradley M. Kuhn.

Verbatim copying and distribution of this entire thesis is permitted in any medium, provided this notice is preserved.