Used when fabricating a new class. Represents a wrapper around
the Javassist library.
The core concept of Javassist is how method bodies (as well as constructor bodies, etc.)
are specified ... as a very Java-like scripting language. The
BodyBuilder class is very useful for assembling
this method bodies. Details are available at the
Javassist home page.
Method bodies look largely like Java. References to java classes must be fully qualified.
Several special variables are used:
$0 first parameter, equivalent to this in Java code (and can't
be used when creating a static method)
$1, $2, ... actual parameters to the method
$args all the parameters as an Object[]
$r the return type of the method, typically used as return ($r) ....
$r is valid with method that return void. This also handles conversions
between wrapper types and primitive types.
$w conversion from primitive type to wrapper type, used as ($w) foo() where
foo() returns a primitive type and a wrapper type is needed
The core concept of Javassist is how method bodies (as well as constructor bodies, etc.) are specified ... as a very Java-like scripting language. The BodyBuilder class is very useful for assembling this method bodies. Details are available at the Javassist home page.
Method bodies look largely like Java. References to java classes must be fully qualified. Several special variables are used:
$0first parameter, equivalent tothisin Java code (and can't be used when creating a static method)$1, $2, ...actual parameters to the method$argsall the parameters as anObject[]$rthe return type of the method, typically used asreturn ($r) ....$ris valid with method that returnvoid. This also handles conversions between wrapper types and primitive types.$wconversion from primitive type to wrapper type, used as($w) foo()wherefoo()returns a primitive type and a wrapper type is needed