@@ -15,22 +15,34 @@ public class JunkCodeChanger extends ClassVisitor {
1515 public static int MAX_JUNK_NUM = 1000 ;
1616 public static int JUNK_NUM = 0 ;
1717 private final BaseConfig config ;
18+ private boolean shouldSkip ;
1819
1920 public JunkCodeChanger (ClassVisitor classVisitor , BaseConfig config ) {
2021 super (Const .ASMVersion , classVisitor );
2122 JUNK_NUM = 0 ;
2223 this .config = config ;
24+ this .shouldSkip = false ;
2325 }
2426
2527 @ Override
2628 public void visit (int version , int access , String name , String signature , String superName , String [] interfaces ) {
2729 super .visit (version , access , name , signature , superName , interfaces );
30+ boolean isAbstract = (access & Opcodes .ACC_ABSTRACT ) != 0 ;
31+ boolean isInterface = (access & Opcodes .ACC_INTERFACE ) != 0 ;
32+ boolean isEnum = (access & Opcodes .ACC_ENUM ) != 0 ;
33+ if (isAbstract || isInterface || isEnum ) {
34+ shouldSkip = true ;
35+ }
2836 }
2937
3038 @ Override
3139 public MethodVisitor visitMethod (int access , String name , String desc , String signature , String [] exceptions ) {
3240 MethodVisitor mv = super .visitMethod (access , name , desc , signature , exceptions );
33- return new JunkChangerMethodAdapter (mv , this .config );
41+ if (shouldSkip ) {
42+ return mv ;
43+ } else {
44+ return new JunkChangerMethodAdapter (mv , this .config );
45+ }
3446 }
3547
3648 @ Override
@@ -66,7 +78,7 @@ public void visitAttribute(Attribute attribute) {
6678 @ Override
6779 public void visitEnd () {
6880 // 添加无意义的代码
69- if (config .getJunkLevel () > 2 ) {
81+ if (! shouldSkip && config .getJunkLevel () > 2 ) {
7082 JunkUtil .addHttpCode (cv );
7183 JunkUtil .addPrintMethod (cv );
7284 }
0 commit comments