From c04c375e813597eaeb305a641f58a89fe665ea54 Mon Sep 17 00:00:00 2001 From: shifujun Date: Fri, 8 Dec 2023 14:48:28 +0800 Subject: Fix MemberResolver.lookupMethod bug when super class has more precise match When onlyExact=false and super class have a more precise match, it should not return with current class's maybe result. New added testSuperCall reveals the problem. --- src/test/javassist/SuperCallCase.java | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/javassist/SuperCallCase.java (limited to 'src/test/javassist/SuperCallCase.java') diff --git a/src/test/javassist/SuperCallCase.java b/src/test/javassist/SuperCallCase.java new file mode 100644 index 00000000..8d5ea9e7 --- /dev/null +++ b/src/test/javassist/SuperCallCase.java @@ -0,0 +1,38 @@ +package javassist; + +class Animal { +} + +class Bear extends Animal { +} + + +/** + * Base class has a method with precise type. + */ +class Man { + String feed(Bear bear) { + return "Man feed(Bear)"; + } +} + +/** + * Derived class has a method which has same name with base class's and more imprecise type. + */ +class Keeper extends Man { + String feed(Animal animal) { + return "Keeper feed(Animal)"; + } +} + +/** + * Derived class has a method which call super method with precise type. + */ +class BearKeeper extends Keeper { + public BearKeeper() { + } + + String javacResult() { + return super.feed(new Bear()); + } +} -- cgit v1.2.3