Abstract Methods

A class C can get an abstract method foo in two ways:

  1. foo is defined as an abstract method by the class C. This is only legal if C itself is an abstract class.

  2. foo is inherited from the superclass and/or a superinterface and not implemented in C. This can happen whether C is an abstract class or not.

The first case poses no problems, so we will deal with inheritance of abstract methods.

Inherited Abstract Methods

Method inherited from superclass (and maybe from superinterface, too)

NOTE: The superclass does not have to be abstract in this case.

C is abstract
  • This case is just normal inheritance.
C is not abstract
  • In this case there must be a stub in the

    vftbl that handles eventual calls to C.foo and throws an AbstractMethodError.

NOTE: We also enter the stub if C is abstract since this simplifies vftbl creation for derived non-abstract classes, and it makes no difference for C itself.

Method inherited only from superinterface

C is abstract
  • In this case we must create an (abstract) miranda method in class C. The miranda method is basically a placeholder that reserves a slot in the vftbl and allows the method foo of derived non-abstract classes to be called as C.foo.

C is not abstract
  • In this case there must be a stub in the

    interface table that handles eventual calls to C.foo and throws an AbstractMethodError.

cacaowiki: AbstractMethods (last edited 2006-06-28 18:47:54 by EdwinSteiner)