aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist/SuperCallCase.java
diff options
context:
space:
mode:
authorshifujun <shifujun@foxmail.com>2023-12-08 14:48:28 +0800
committershifujun <shifujun@foxmail.com>2023-12-08 17:18:27 +0800
commitc04c375e813597eaeb305a641f58a89fe665ea54 (patch)
tree0ce0674728ec2a0b4a2c1d35d33dfa81a5cea3cc /src/test/javassist/SuperCallCase.java
parent158294371e39b24f003f15933bd74f2b26bbf3aa (diff)
downloadjavassist-c04c375e813597eaeb305a641f58a89fe665ea54.tar.gz
javassist-c04c375e813597eaeb305a641f58a89fe665ea54.zip
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.
Diffstat (limited to 'src/test/javassist/SuperCallCase.java')
-rw-r--r--src/test/javassist/SuperCallCase.java38
1 files changed, 38 insertions, 0 deletions
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());
+ }
+}