'

Implementing dynamic language features in Java Using dynamic code generation

Thomas M. Breuel Xerox PARC, Palo Alto, California

Java has a safe but fairly simple and restrictive object and type system compared to dynamic object-oriented languages like CommonLisp or Smalltalk. Some of the key di erences between Java and these other languages is that they o er structural conformance, automatic dele- gation, and dynamic mixins. When such constructs are needed in a language like Java, they are usually expressed in terms of standard object-oriented design patterns, requiring the manual implementation of "glue" or "helper" classes.

This paper describes ways in which such features can be provided e ciently and automatically in terms of Java´s platform-independent binary format and dynamic loading mech- anisms. The implementation does not require any changes to the Java runtime, bytecodes, or class loader and yields performance compara- ble to manually implemented design patterns. The approach should prove useful both as a programming tool for Java and as an strategy for building e cient implementations of dynamic languages on top of the Java virtual machine.'