aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist/SuperCallCase.java
blob: 8d5ea9e78e924783367254ca0972a38aefa1b88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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());
    }
}