You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SuperCallCase.java 637B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package javassist;
  2. class Animal {
  3. }
  4. class Bear extends Animal {
  5. }
  6. /**
  7. * Base class has a method with precise type.
  8. */
  9. class Man {
  10. String feed(Bear bear) {
  11. return "Man feed(Bear)";
  12. }
  13. }
  14. /**
  15. * Derived class has a method which has same name with base class's and more imprecise type.
  16. */
  17. class Keeper extends Man {
  18. String feed(Animal animal) {
  19. return "Keeper feed(Animal)";
  20. }
  21. }
  22. /**
  23. * Derived class has a method which call super method with precise type.
  24. */
  25. class BearKeeper extends Keeper {
  26. public BearKeeper() {
  27. }
  28. String javacResult() {
  29. return super.feed(new Bear());
  30. }
  31. }