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
class Foo
{
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
CLASS Foo
METHOD foo
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!")
ENDRULE
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
org.jboss.byteman.disallow.downcasts
in the JVM running the Byteman agent.