@@ -40,26 +40,27 @@ public ClassAdapter(final ClassVisitor cv, String className) {
40
40
public MethodVisitor visitMethod (final int access , final String name ,
41
41
final String desc , final String signature , final String [] exceptions ) {
42
42
MethodVisitor mv = cv .visitMethod (access , name , desc , signature , exceptions );
43
+ if (clazzName != null ) {
44
+ final String methodName = clazzName .replace ('/' , '.' ) + "." + name ;
45
+ for (String methodPrefix : StackTraceHelper .methodPrefix ) {
46
+ if (methodName .startsWith (methodPrefix )) {
47
+ MethodVisitor nmv = new AdviceAdapter (Opcodes .ASM5 , mv , access , name , desc ) {
48
+ @ Override
49
+ protected void onMethodEnter () {
50
+ mv .visitFieldInsn (GETSTATIC , "java/lang/System" , "out" , "Ljava/io/PrintStream;" );
51
+ mv .visitLdcInsn ("Enter Method: " + methodName );
52
+ mv .visitMethodInsn (INVOKEVIRTUAL , "java/io/PrintStream" , "println" , "(Ljava/lang/String;)V" , false );
43
53
44
- final String methodName = clazzName .replace ('/' , '.' ) + "." + name ;
45
- for (String methodPrefix : StackTraceHelper .methodPrefix ) {
46
- if (methodName .startsWith (methodPrefix )) {
47
- MethodVisitor nmv = new AdviceAdapter (Opcodes .ASM5 , mv , access , name , desc ) {
48
- @ Override
49
- protected void onMethodEnter () {
50
- mv .visitFieldInsn (GETSTATIC , "java/lang/System" , "out" , "Ljava/io/PrintStream;" );
51
- mv .visitLdcInsn ("Enter Method: " + methodName );
52
- mv .visitMethodInsn (INVOKEVIRTUAL , "java/io/PrintStream" , "println" , "(Ljava/lang/String;)V" , false );
53
-
54
- mv .visitTypeInsn (NEW , "java/lang/Exception" );
55
- mv .visitInsn (DUP );
56
- mv .visitLdcInsn ("Java Stack Trace" );
57
- mv .visitMethodInsn (INVOKESPECIAL , "java/lang/Exception" , "<init>" , "(Ljava/lang/String;)V" , false );
58
- mv .visitFieldInsn (GETSTATIC , "java/lang/System" , "out" , "Ljava/io/PrintStream;" );
59
- mv .visitMethodInsn (INVOKEVIRTUAL , "java/lang/Exception" , "printStackTrace" , "(Ljava/io/PrintStream;)V" , false );
60
- }
61
- };
62
- return nmv ;
54
+ mv .visitTypeInsn (NEW , "java/lang/Exception" );
55
+ mv .visitInsn (DUP );
56
+ mv .visitLdcInsn ("Java Stack Trace" );
57
+ mv .visitMethodInsn (INVOKESPECIAL , "java/lang/Exception" , "<init>" , "(Ljava/lang/String;)V" , false );
58
+ mv .visitFieldInsn (GETSTATIC , "java/lang/System" , "out" , "Ljava/io/PrintStream;" );
59
+ mv .visitMethodInsn (INVOKEVIRTUAL , "java/lang/Exception" , "printStackTrace" , "(Ljava/io/PrintStream;)V" , false );
60
+ }
61
+ };
62
+ return nmv ;
63
+ }
63
64
}
64
65
}
65
66
return mv ;
0 commit comments