14
14
import static net .orfjackal .retrolambda .util .Flags .*;
15
15
import static org .objectweb .asm .Opcodes .*;
16
16
17
- public class ClassHierarchyAnalyzer {
17
+ public class ClassAnalyzer {
18
18
19
19
private final Map <Type , ClassInfo > classes = new HashMap <>();
20
20
private final Map <MethodRef , MethodRef > relocatedMethods = new HashMap <>();
@@ -45,10 +45,16 @@ public void visit(int version, int access, String name, String signature, String
45
45
46
46
@ Override
47
47
public MethodVisitor visitMethod (int access , String name , String desc , String signature , String [] exceptions ) {
48
- if (isConstructor (name ) || isStaticMethod (access )) {
49
- return null ;
48
+ int tag ;
49
+ if (isConstructor (name )) {
50
+ tag = H_INVOKESPECIAL ;
51
+ } else if (isStaticMethod (access )) {
52
+ tag = H_INVOKESTATIC ;
53
+ } else {
54
+ tag = H_INVOKEVIRTUAL ;
50
55
}
51
- c .addMethod (new MethodRef (H_INVOKEVIRTUAL , owner , name , desc ), new MethodKind .Implemented ());
56
+
57
+ c .addMethod (access , new MethodRef (tag , owner , name , desc ), new MethodKind .Implemented ());
52
58
return null ;
53
59
}
54
60
@@ -71,12 +77,12 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
71
77
MethodRef method = new MethodRef (Handles .accessToTag (access , true ), owner , name , desc );
72
78
73
79
if (isAbstractMethod (access )) {
74
- c .addMethod (method , new MethodKind .Abstract ());
80
+ c .addMethod (access , method , new MethodKind .Abstract ());
75
81
76
82
} else if (isDefaultMethod (access )) {
77
83
MethodRef defaultImpl = new MethodRef (H_INVOKESTATIC , companion , name , Bytecode .prependArgumentType (desc , Type .getObjectType (owner )));
78
84
c .enableCompanionClass ();
79
- c .addMethod (method , new MethodKind .Default (defaultImpl ));
85
+ c .addMethod (access , method , new MethodKind .Default (defaultImpl ));
80
86
81
87
} else if (isInstanceLambdaImplMethod (access )) {
82
88
relocatedMethods .put (method , new MethodRef (H_INVOKESTATIC , companion , name , Bytecode .prependArgumentType (desc , Type .getObjectType (owner ))));
0 commit comments