-
Notifications
You must be signed in to change notification settings - Fork 2
Background and motivation
I wrote the original Cojen "classfile" library in 1997, and like other bytecode libraries of this era, the design started out as a set of classes which mirrored the struct definitions outlined in the JVM specification. Because JIT compilers at this time weren't very good, direct control over bytecode instructions was necessary for achieving the best performance.
Over time, JIT compilers like HotSpot came along, and this meant that optimization tricks at the bytecode level became unnecessary. Precise instruction selection mattered less, as did direct control over the operand stack. And as more JVM features were added, it became difficult for the Cojen API to keep up. In particular, the StackMapTable
attribute introduced in Java 6 effectively killed all further development. This feature speeds up bytecode verification, but it created a heavy burden on the bytecode generator that didn't originally exist. Without a complete rewrite, the original library was stuck on Java 5, and so it couldn't support newer features like invokedynamic
.
Cojen/Maker is a complete rewrite of the original library, catching it up to the latest JVM and providing a foundation for future enhancements. The API is designed to be low-level enough to expose all the JVM features, but also be high-level enough to hide the ugly details. There's no reason for anyone using the API to ever read the JVM specification.