public class DefaultAdvice extends HotSpotAdvice
| Constructor and Description |
|---|
DefaultAdvice() |
| Modifier and Type | Method and Description |
|---|---|
void |
advice()
Each extending class must provide advice() method.
|
doHotSpot, getHotSpotNamepublic void advice()
HotSpotAdviceThe exact location, where method body gets copied into, depends how developer writes the method body.
A call to doHotSpot() in method body, is a tagging method call indicating that current hotspot should be executed.
For example, of we have a method foo()...
public void foo() {
bar.doSomeThing();
}
...and HotSpotAdvisor.advice():
public void advice() {
long l1 = System.currentTimeMillis();
doHotSpot();
long l2 = System.currentTimeMillis();
System.out.println("It took " + (l2 - l1) + " ms");
}
...then it would result in instrumented foo() method like
public void foo() {
long l1 = System.currentTimeMillis();
bar.doSomething();
long l2 = System.currentTimeMillis();
System.out.println("It took " + (l2-l1) + " ms");
}
If a developer does not call doHotSpot() method in
implementation of advice() method, corresponding hotspot
gets replaced from instrumented class.advice in class HotSpotAdviceHotSpotAdvice.doHotSpot()Copyright © 2017. All rights reserved.