-
1. Re: $@ usage
adinn Jan 31, 2012 10:01 AM (in response to flavia.rainone)Hi Flavia,
Flavia Rainone wrote:
Hi!
I am using byteman to intercept a method call. However, I am having problems when I try to use $@.
If I try to assign $@ to a variable, at BIND, it works. But I need to retrieve the element at position 0 of the array $@.
Is there a way to do this?
Well, $@ is an Object[]. So, to retrieve element 0 you use $@[0] -- easy-peasy, just like Java :-)
Of course, the resulting value has type Object which is not a lot of use to you unless you pass it into a helper to do a cast.
Now, on that subject, I have been thinking of adding some form of cast operation to Byteman e.g. something like this
. . .
BIND serviceController : ServiceController = cast(ServiceControllerImpl, $@[0]);
serviceName = serviceController.getName().getSimpleName();
IF . . .
Or maybe even just adding automatic coercion where it is clear that a specific type is expected e.g.
. . .
BIND serviceController : ServiceController = $@[0];
serviceName = serviceController.getName().getSimpleName();
IF . . .
Anyway, I have not really come up with a good clear model for how to add this. So, until I do you will have to use a helper to do anything useful with $@[0].
-
2. Re: $@ usage
flavia.rainone Feb 13, 2012 9:03 AM (in response to adinn)Thanks Andrew. I tried:
BIND serviceController: ServiceController = $@[0]
But, since it didn't work, I assumed that there was a different sintax to access $@[0].
The helper solved my problem!