Wyjvm is the Java Bytecode disassembler / assembler used in the Whiley-to-Java Compiler (wyjc). Wyjvm can be used as a standalone tool, or accessed as a library from other Java applications. Wyjvm simplifies various tasks related to reading and writing JVM classfiles, including the following:

  • Automatic generation of the optimised bytecodes.  For example, if you want to load an integer onto the stack, then you simply create an instance of  LoadConst, and the library automatically chooses the most appropriate bytecode (i.e. bipush, sipush, ldc, etc).
  • Automatic computation of branch offsets.  When creating a branching instruction, you simply provide a “label” as its target.  The wyjvm library takes care of calculating the actual offset, and will generate code for wide branches as necessary.
  • Automatic generation of the constant pool.  Creating constant pool items with wyjvm is very simple, as the library takes care of all the necessary book-keeping.
  • Support for user-defined annotations. The library provides a simple mechanism for defining your own JVM annotations.  For example, the wyjc compiler defines annotations for encoding various necessary aspects of the Whiley language within classfiles.