Conventions changed to normalReturn + exception = exit
This commit is contained in:
+21
-21
@@ -78,8 +78,8 @@ public class InterceptionInstrumenter {
|
|||||||
FieldData fieldData = getFieldData(field, interceptorClass);
|
FieldData fieldData = getFieldData(field, interceptorClass);
|
||||||
|
|
||||||
List<MethodData> enterData = new ArrayList<MethodData>();
|
List<MethodData> enterData = new ArrayList<MethodData>();
|
||||||
List<MethodData> exitData = new ArrayList<MethodData>();
|
List<MethodData> normalReturnData = new ArrayList<MethodData>();
|
||||||
List<MethodData> errorData = new ArrayList<MethodData>();
|
List<MethodData> exceptionData = new ArrayList<MethodData>();
|
||||||
List<Method> dumpMethods = new ArrayList<Method>();
|
List<Method> dumpMethods = new ArrayList<Method>();
|
||||||
for (Method method : interceptorClass.getMethods()) {
|
for (Method method : interceptorClass.getMethods()) {
|
||||||
String name = method.getName();
|
String name = method.getName();
|
||||||
@@ -87,15 +87,15 @@ public class InterceptionInstrumenter {
|
|||||||
if (name.startsWith("enter")) {
|
if (name.startsWith("enter")) {
|
||||||
enterData.add(methodData);
|
enterData.add(methodData);
|
||||||
}
|
}
|
||||||
|
else if (name.startsWith("normalReturn")) {
|
||||||
|
normalReturnData.add(methodData);
|
||||||
|
}
|
||||||
|
else if (name.startsWith("exception")) {
|
||||||
|
exceptionData.add(methodData);
|
||||||
|
}
|
||||||
else if (name.startsWith("exit")) {
|
else if (name.startsWith("exit")) {
|
||||||
exitData.add(methodData);
|
normalReturnData.add(methodData);
|
||||||
}
|
exceptionData.add(methodData);
|
||||||
else if (name.startsWith("error")) {
|
|
||||||
errorData.add(methodData);
|
|
||||||
}
|
|
||||||
else if (name.startsWith("anyExit")) {
|
|
||||||
exitData.add(methodData);
|
|
||||||
errorData.add(methodData);
|
|
||||||
}
|
}
|
||||||
else if (name.startsWith("dump")) {
|
else if (name.startsWith("dump")) {
|
||||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||||
@@ -117,8 +117,8 @@ public class InterceptionInstrumenter {
|
|||||||
compilePattern(annotation.erasedSignature()),
|
compilePattern(annotation.erasedSignature()),
|
||||||
annotation.allowMultipleMatches(),
|
annotation.allowMultipleMatches(),
|
||||||
enterData,
|
enterData,
|
||||||
exitData,
|
normalReturnData,
|
||||||
errorData,
|
exceptionData,
|
||||||
annotation.logInterceptions());
|
annotation.logInterceptions());
|
||||||
|
|
||||||
for (Method dumpMethod : dumpMethods) {
|
for (Method dumpMethod : dumpMethods) {
|
||||||
@@ -286,9 +286,9 @@ public class InterceptionInstrumenter {
|
|||||||
|
|
||||||
if (applicableInstrumenters.isEmpty()) return mv;
|
if (applicableInstrumenters.isEmpty()) return mv;
|
||||||
|
|
||||||
final List<MethodData> exitData = new ArrayList<MethodData>();
|
final List<MethodData> normalReturnData = new ArrayList<MethodData>();
|
||||||
final List<MethodData> enterData = new ArrayList<MethodData>();
|
final List<MethodData> enterData = new ArrayList<MethodData>();
|
||||||
final List<MethodData> errorData = new ArrayList<MethodData>();
|
final List<MethodData> exceptionData = new ArrayList<MethodData>();
|
||||||
|
|
||||||
org.jetbrains.asm4.commons.Method methodBeingInstrumented = new org.jetbrains.asm4.commons.Method(name, desc);
|
org.jetbrains.asm4.commons.Method methodBeingInstrumented = new org.jetbrains.asm4.commons.Method(name, desc);
|
||||||
|
|
||||||
@@ -302,24 +302,24 @@ public class InterceptionInstrumenter {
|
|||||||
enterData.add(methodData);
|
enterData.add(methodData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MethodData methodData : instrumenter.getExitData()) {
|
for (MethodData methodData : instrumenter.getNormalReturnData()) {
|
||||||
int depth = stackDepth(methodData, methodBeingInstrumented);
|
int depth = stackDepth(methodData, methodBeingInstrumented);
|
||||||
if (maxStackDepth < depth) {
|
if (maxStackDepth < depth) {
|
||||||
maxStackDepth = depth;
|
maxStackDepth = depth;
|
||||||
}
|
}
|
||||||
exitData.add(methodData);
|
normalReturnData.add(methodData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MethodData methodData : instrumenter.getErrorData()) {
|
for (MethodData methodData : instrumenter.getExceptionData()) {
|
||||||
int depth = stackDepth(methodData, methodBeingInstrumented);
|
int depth = stackDepth(methodData, methodBeingInstrumented);
|
||||||
if (maxStackDepth < depth) {
|
if (maxStackDepth < depth) {
|
||||||
maxStackDepth = depth;
|
maxStackDepth = depth;
|
||||||
}
|
}
|
||||||
errorData.add(methodData);
|
exceptionData.add(methodData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enterData.isEmpty() && exitData.isEmpty()) return mv;
|
if (enterData.isEmpty() && normalReturnData.isEmpty()) return mv;
|
||||||
|
|
||||||
if (dumpInstrumentedMethods) {
|
if (dumpInstrumentedMethods) {
|
||||||
mv = getDumpingVisitorWrapper(mv, name, desc);
|
mv = getDumpingVisitorWrapper(mv, name, desc);
|
||||||
@@ -362,12 +362,12 @@ public class InterceptionInstrumenter {
|
|||||||
case FRETURN:
|
case FRETURN:
|
||||||
case DRETURN:
|
case DRETURN:
|
||||||
case ARETURN:
|
case ARETURN:
|
||||||
for (MethodData methodData : exitData) {
|
for (MethodData methodData : normalReturnData) {
|
||||||
invokeMethod(access, name, desc, getInstructionAdapter(), methodData, false);
|
invokeMethod(access, name, desc, getInstructionAdapter(), methodData, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATHROW:
|
case ATHROW:
|
||||||
for (MethodData methodData : errorData) {
|
for (MethodData methodData : exceptionData) {
|
||||||
// A constructor may throw before calling super(), 'this' is not available in this case
|
// A constructor may throw before calling super(), 'this' is not available in this case
|
||||||
invokeMethod(access, name, desc, getInstructionAdapter(), methodData, isConstructor);
|
invokeMethod(access, name, desc, getInstructionAdapter(), methodData, isConstructor);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -21,9 +21,9 @@ import java.util.List;
|
|||||||
interface MethodInstrumenter {
|
interface MethodInstrumenter {
|
||||||
boolean isApplicable(String name, String desc);
|
boolean isApplicable(String name, String desc);
|
||||||
|
|
||||||
List<MethodData> getExitData();
|
List<MethodData> getNormalReturnData();
|
||||||
|
|
||||||
List<MethodData> getErrorData();
|
List<MethodData> getExceptionData();
|
||||||
|
|
||||||
List<MethodData> getEnterData();
|
List<MethodData> getEnterData();
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -26,8 +26,8 @@ class MethodInstrumenterImpl implements MethodInstrumenter {
|
|||||||
private final Pattern descPattern;
|
private final Pattern descPattern;
|
||||||
private final boolean allowMultipleMatches;
|
private final boolean allowMultipleMatches;
|
||||||
private final List<MethodData> enterData;
|
private final List<MethodData> enterData;
|
||||||
private final List<MethodData> exitData;
|
private final List<MethodData> normalReturnData;
|
||||||
private final List<MethodData> errorData;
|
private final List<MethodData> exceptionData;
|
||||||
private final boolean logApplications;
|
private final boolean logApplications;
|
||||||
|
|
||||||
public MethodInstrumenterImpl(
|
public MethodInstrumenterImpl(
|
||||||
@@ -36,8 +36,8 @@ class MethodInstrumenterImpl implements MethodInstrumenter {
|
|||||||
Pattern descPattern,
|
Pattern descPattern,
|
||||||
boolean allowMultipleMatches,
|
boolean allowMultipleMatches,
|
||||||
List<MethodData> enterData,
|
List<MethodData> enterData,
|
||||||
List<MethodData> exitData,
|
List<MethodData> normalReturnData,
|
||||||
List<MethodData> errorData, boolean logApplications
|
List<MethodData> exceptionData, boolean logApplications
|
||||||
) {
|
) {
|
||||||
this.debugName = debugName;
|
this.debugName = debugName;
|
||||||
this.classPattern = classPattern;
|
this.classPattern = classPattern;
|
||||||
@@ -45,8 +45,8 @@ class MethodInstrumenterImpl implements MethodInstrumenter {
|
|||||||
this.descPattern = descPattern;
|
this.descPattern = descPattern;
|
||||||
this.allowMultipleMatches = allowMultipleMatches;
|
this.allowMultipleMatches = allowMultipleMatches;
|
||||||
this.enterData = enterData;
|
this.enterData = enterData;
|
||||||
this.exitData = exitData;
|
this.normalReturnData = normalReturnData;
|
||||||
this.errorData = errorData;
|
this.exceptionData = exceptionData;
|
||||||
this.logApplications = logApplications;
|
this.logApplications = logApplications;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,13 +73,13 @@ class MethodInstrumenterImpl implements MethodInstrumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MethodData> getExitData() {
|
public List<MethodData> getNormalReturnData() {
|
||||||
return exitData;
|
return normalReturnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MethodData> getErrorData() {
|
public List<MethodData> getExceptionData() {
|
||||||
return errorData;
|
return exceptionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user