Byteman 2.1.2 is now available for download. You can obtain a copy
either as a binary-only or full-source zip from the project downloads
page or you can depend upon the version available in the Maven Central
Byteman 2.1.2 is for the most part a maintenance update to release
2.1.0, fixing about half a dozen bugs. However, it does include a few
new features. In particular:
Allow downcasts when initialising local vars in the BIND clause
Support computing object size as a standard method in Helper
Downcasting is particularly helpful when dealing with generic types when
you know that a specific type parameter is used. For example when
injecting into this class
void foo(List names)
. . .
downcasting allows you to bind elements of the argument list using the
type String rather than the generic type Object
RULE access name as a name
BIND first : String = $names.get(0);
second : String = $names.get(1);
IF first == "Andrew" && second == "Dinn"
DO throw new Exception("Won't get fooed again!")
Of course, Byteman performs a checkcast before binding the variables so
when the rule executes if you try to downcast a value which is not an
instance of the subtype your program will see a ClassCastException.
If you want to disable downcasting and revert to the old behaviour where
the type checker flags this as a type error the simply set system property
in the JVM running the Byteman agent.