Closed KinComet closed 4 months ago
Have you tried to set -Dnet.bytebuddy.dump=/some/folder
?
You can then investigate the generated class to see if it actually contains the new code using javap
. If you set @Advice.OnMethodEnter(skipOn = String.class, inline = false)
you might also be able to set a break point. If it never triggers, something else is wrong.
Have you tried to set
-Dnet.bytebuddy.dump=/some/folder
?You can then investigate the generated class to see if it actually contains the new code using
javap
. If you set@Advice.OnMethodEnter(skipOn = String.class, inline = false)
you might also be able to set a break point. If it never triggers, something else is wrong.
Looked into the dump, it's
public String test() {
if ((System.currentTimeMillis() > 0 ? "inject" : null) instanceof String) {
return null;
}
return "test";
}
It returns null, but not inject
String.
I could skip original method codes and add a OnMethodExit
, but it adds one more of condition check. It will take more time. If all things can be done in OnMethodEnter
or something like that, it would be great.
Indeed, now I understand what you are trying to do. You would need to add the following:
@Advice.OnMethodExit
static void exit(@Advice.Enter String enter, @Advice.Return(readOnly = false) String returned) {
if (enter != null) {
returned = enter;
}
}
Otherwise, you will not assign the returned value.
This works! Thank you so much.
Hi. I want to introduce a cache system here but I cannot find a way to inject my code.
using
Also tried
MethodDelegation
, but@SuperCall
and@DefaultCall
gives null, so I cannot call original method