MCPcopy Create free account
hub / github.com/FabricMC/Matcher / resolveMethod

Method resolveMethod

src/main/java/matcher/type/ClassInstance.java:641–679  ·  view source on GitHub ↗
(String name, String desc, boolean toInterface)

Source from the content-addressed store, hash-verified

639 }
640
641 public MethodInstance resolveMethod(String name, String desc, boolean toInterface) {
642 // toInterface = false: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.3
643 // toInterface = true: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.4
644 // TODO: access check after resolution
645
646 assert asmNodes == null || isInterface() == toInterface;
647
648 if (!toInterface) {
649 MethodInstance ret = resolveSignaturePolymorphicMethod(name);
650 if (ret != null) return ret;
651
652 ret = getMethod(name, desc);
653 if (ret != null) return ret; // <this> is unconditional
654
655 ClassInstance cls = this;
656
657 while ((cls = cls.superClass) != null) {
658 ret = cls.resolveSignaturePolymorphicMethod(name);
659 if (ret != null) return ret;
660
661 ret = cls.getMethod(name, desc);
662 if (ret != null) return ret;
663 }
664
665 return resolveInterfaceMethod(name, desc);
666 } else {
667 MethodInstance ret = getMethod(name, desc);
668 if (ret != null) return ret; // <this> is unconditional
669
670 if (superClass != null) {
671 assert superClass.id.equals("Ljava/lang/Object;");
672
673 ret = superClass.getMethod(name, desc);
674 if (ret != null && (!ret.isReal() || (ret.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC)) == Opcodes.ACC_PUBLIC)) return ret;
675 }
676
677 return resolveInterfaceMethod(name, desc);
678 }
679 }
680
681 private MethodInstance resolveSignaturePolymorphicMethod(String name) {
682 if (id.equals("Ljava/lang/invoke/MethodHandle;")) { // check for signature polymorphic method - jvms-2.9

Callers 5

isSameMethodMethod · 0.95
resolveMethodMethod · 0.95
mapMethodNameMethod · 0.95
compareMethodsMethod · 0.45

Calls 6

isInterfaceMethod · 0.95
getMethodMethod · 0.95
isRealMethod · 0.95
equalsMethod · 0.45

Tested by

no test coverage detected