Wednesday 19 October 2016

Byteman 4.0.0-BETA0 has been released

Byteman 4.0.0-BETA0 is now available from the Byteman downloads page and from the Maven Central repository.

This is a preview release allowing Byteman to be used with a JDK9 that includes the Java Platform Module System (JPMS aka Jigsaw). It implements basic support for Byteman to operate in a module-enabled JDK (e.g. Early Access release b138 for JDK 9 with Project Jigsaw or your own release built from the Jigsaw project jake tree).
This release implements one new capability. Byteman rules may now access members of classes which belong to a named module but are not exported by that module (or only have limited exports). For example, the following initialization for BIND variable name will now pass typecheck:

  RULE . . .
  . . .
  BIND
    th = Thread.getCurrentThread();
    name = th.name;
  . . .


This release will operate as normal on JDK6-8.
On JDK9 only one issue is expected: rule compilation will fail when a rule refers to public types that are not exported by their owning module. For example, the following initialization for BIND variable u will fail to compile

  RULE . . .
  . . .
  COMPILE
  BIND
    u = Unsafe.Unsafe();
  . . .

There is no problem invoking the constructor and, indeed, this code will work if the COMPILE option is switched to NOCOMPILE. However, when the rule is translated to bytecode the reference to variable u of type Unsafe leads to  a verify error,. Currently bytecode is generated in a class in the unnamed module and Unsafe, although it is a public class, is not exported to the unnamed module. This limitation will be addressed in a later release.