Last active
April 24, 2020 11:35
-
-
Save tnishada/dc95e5a04a85e8052c6f6c7e4727fb9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyAdvices { | |
@Advice.OnMethodEnter(suppress = Throwable.class) | |
static long enter(@Advice.This Object thisObject, | |
@Advice.Origin String origin, | |
@Advice.Origin("#t #m") String detaildOrigin, | |
@Advice.AllArguments Object[] ary, | |
@Advice.FieldValue(value = "name", readOnly = false) String nameField){ | |
System.out.println("Inside enter method . . . "); | |
if(ary != null) { | |
for(int i =0 ; i < ary.length ; i++){ | |
System.out.println("Argument: " + i + " is " + ary[i]); | |
} | |
} | |
System.out.println("Origin :" + origin); | |
System.out.println("Detailed Origin :" + detaildOrigin); | |
nameField = "Jack"; | |
return System.nanoTime(); | |
} | |
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class) | |
static void exit(@Advice.Enter long time){ | |
System.out.println("Inside exit method . . ."); | |
System.out.println("Method Execution Time: " + (System.nanoTime() - time) + " nano seconds"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment