Reputation: 160
In both the JLS and JVM spec there is language that refers to direct superinterfaces of a class. This notion of a direct superinterface of a class is confusing, because a class cannot extend an interface.
For example, from Section 9 of the JLS:
A class necessarily implements all the interfaces that its direct superclasses and direct superinterfaces do.
From section 5.4.3.2 of the JVM spec:
Otherwise, field lookup is applied recursively to the direct superinterfaces of the specified class or interface C.
Although, in section 9.1.3 of the JLS, the definition of direct superinterface is given as
If an extends clause is provided, then the interface being declared extends each of the other named interfaces and therefore inherits the member types, methods, and constants of each of the other named interfaces. These other named interfaces are the direct superinterfaces of the interface being declared.
And rigorously stated as
Given a (possibly generic) interface declaration for I (n ≥ 0), the direct superinterfaces of the interface type I are the types given in the extends clause of the declaration of I if an extends clause is present.
In both of these definitions, the notion of a direct superinterface is applied to the Interface type, not the class type.
So what is meant by direct superinterfaces of a class?
Upvotes: 0
Views: 462
Reputation: 393781
Direct super-interfaces are all the interfaces that a class implements directly.
For example, if
class X implements Y,Z
Y & Z are direct super-interfaces of class X.
In addition to implementing its direct super-interfaces, a class also implements indirectly all the interfaces that its direct super-class implements and all the interfaces that its direct super-interfaces extend.
The optional implements clause in a class declaration lists the names of interfaces that are direct superinterfaces of the class being declared.
Upvotes: 4