Monday, 9 April 2018

Byteman 4.0.2 has been released

Byteman 4.0.2 is now available from the Byteman downloads page and from the Maven Central repository. It is the latest release for use on JDK9+ runtimes. It is also recommended as the preferred release for use on JDK8- runtimes.

Byteman 4.0.2 updates the 4.0.1 release with a small number of bug fixes and performance improvements. More details can be found in the Release Notes.

Monday, 19 February 2018

Byteman 4.0.1 has been released

Byteman 4.0.1 is now available from the Byteman downloads page and from the Maven Central repository. It is the latest release for use on JDK9+ runtimes. It is also recommended as the preferred release for use on JDK8- runtimes.
Byteman 4.0.1 upgrades the 4.0.0 release to ensure it runs correctly on the latest JDK10 release. It is also the preferred version to use for all prior JDK releases.
Byteman 4.0.1 also includes a small number of feature and bug fix updates. More details can be found in the Release Notes.

Thursday, 18 January 2018

Byteman 4.0.0 has been released

Byteman 4.0.0 is now available from the Byteman downloads page and from the Maven Central repository. It is the final release for use on JDK9+ runtimes. It is also recommended as the preferred release for use on JDK8- runtimes.

As well as supporting full operation in releases employing the Java Platform Module System Release 4.0.0 contains a host of bug fixes and a few other minor  features. The most noticeable fix is to Helper lifecycle processing, ensuring that rule installs and uninstalls are consistently observed and responded to with activate, install, uninstall and deactivate events notified to the all affected rule helper classes. This fix has finally enabled the default class Helper's deactivated callback to clear internally allocated rule resources when all rules using Helper have been uninstalled.

More details can be found in the Release Notes.
 

Monday, 22 May 2017

Configuring BMUnit for the latest JDK9 EA releases

The latest JDK9 EA access releases (jdk-ea+169 and subsequent) now incorporates a restriction that affects use of the BMUnit package (BMUnit integrates Byteman with JUnit and TestNG -- see the 2nd Byteman tutorial for full details).

BMUnit makes it easy to use Byteman in unit and integration tests. It provides @BMRule and @BMScript annotations used to annotate test methods or test classes. These annotations specify the Byteman rules you want injected into your application, test or JDK runtime classes prior to running a test. In order for that to work, BMUnit needs to ensure the Byteman agent is loaded into the current test JVM before running the annotated tests.

As of the Early Access 169 release, JDK9 now includes a check which, by default, stops code using the Agent Load library to hoist an agent into the same JVM. This is provided for users who want to guarantee that code they have deployed in their classpath cannot load an agent in order to escalate its own privilege level (agents like Byteman have very special powers, most notably the ability to rewrite method bytecode).

Of course, that kind of hostage scenario should never be an issue. Users ought to be in full control of what code gets placed in their classpath. So, they should not have to be concerned that a deployment might attempt to use this capability unless it is intended Anyway, irrespective of the rationale for its inclusion, this restriction has been added to JDK9 as a belt and braces security feature for the  super-paranoid^H^H^H^H^H^H -safety conscious user.

Of course, this restriction affects BMUnit because it has to use the Agent Load library to hoist the Byteman agent into the running JVM in order then to be able to inject code changes required for unit tests. Having BMUnit load the agent automatically is much more convenient than configuring the relevant agent options on the Java command line. In particular, BMUNit provides the BMUnitConfig annotation, allowing you to easily configure/reset all the extra arguments that you would otherwise have to squeeze into one long command line string. So, it is much better to be able to remove this restriction and rely on self-hoisting when running your BMUnit tests.

Luckily, it is very simple to disable the restriction. The JVM will allow an agent self-hoist to proceed if a specific system property, jdk.attach.allowAttachSelf, is set to the String value "true". This is a read-only property so it has to be set when the test JVM is started.

If you are using maven then this means that you need to modify the configuration for your maven surefire or failsafe tests to specify the required system property at JVM start setting using the argLine configuration element

<argLine>-Djdk.attach.allowAttachSelf=true</argLine>

n.b. specifying this value as a property element in the properties configuration element will not work.

If you are running from the command line or using some other tool then ensure you pass the property setting on the java command line using the -D command flag

  java -Djdk.attach.allowAttachSelf=true ...

It is probably worth adding this to all your BMUnit test configurations even if you are not yet using jdk9-ea+169 or later releases. You will be prepared for when you do eventually upgrade and setting the property will be harmless since it will ignored by any earlier JDK releases (including on JDK8).

Thursday, 27 April 2017

Byteman 3.0.10 and 4.0.0-BETA5 have been released


Byteman 3.0.10 is now available from the Byteman downloads page and from the Maven Central repository. It is accompanied by a corresponding 4.0.0-BETA5 release for JDK9.
3.0.10 is a minor update for the preceding release 3.0.9. It fixes a couple of bugs in the type checker. It is intended for use on JDK8 and earlier.
4.0.0-BETA5 is the corresponding release for use with JDK9. As well as providing the type checker fixes it also includes fixes to a couple of bugs found when testing on jdk9. One is a genuine bug in Byteman, the other works around a limitation on the use of method handles as currently implemented by JDK9.
More details can be found in the Release Notes.
Note that release 3.0.9 is intended for use on JDK6-8 whereas preview release Byteman 4.0.0-BETA4 is intended for use on the latest early access releases of JDK9 (jdk9-ea+165 and later).
Note also that 4.0.0-BETA4 should still work compatibly with 3.0.10 on JDK6-8.
 

Wednesday, 19 April 2017

Byteman 3.0.9 and 4.0.0-BETA4 have been released


Byteman 3.0.9 is now available from the Byteman downloads page and from the Maven Central repository. It is accompanied by a corresponding 4.0.0-BETA4 release for JDK9.
3.0.9 is a minor update for the preceding release 3.0.8. It fixes one bug in the 3.08 release for jdk8 which was latent but hidden by a second bug (also fixed :-).
The same bug does actually manifest in release 4.0.0-BETA3 for jdk9-ea+151 (the jdk9 pre-release version which accompanied 3.0.8) courtesy of other Byteman changes made to accommodate Jigsaw. The BETA4 release fixes this bug and also includes updates to accommodate further changes made to Jigsaw in versions up to and including jdk9-ea+165.
More details can be found in the Release Notes.

Note that release 3.0.9 is intended for use on JDK6-8 whereas preview release Byteman 4.0.0-BETA4 is intended for use on the latest early access releases of JDK9 (jdk9-ea+165 and later).
With luck 4.0.0-BETA4 will be the last BETA release for jdk9 and the current parallel release streams will merge when 4.0.0 is released.

Tuesday, 7 March 2017

Byteman 3.0.8 has been released

Byteman 3.0.8 is now available from the Byteman downloads page and from the Maven Central repository.


This is a minor update for the preceding release 3.0.7. It fixes a small problem in the top-level pom which was causing artifact resolution issues for some Maven-based projects wishing to consume byteman. It also contains some cosmetic tweaks to the dtest contributed library. More details can be found in the Release Notes.

Note that release 3.0.8 is intended for use on JDK6-8. Preview release Byteman 4.0.0-BETA3 is available for use on early access releases of JDK9.