Spring Java-Interfaces
Spring Java-Interfaces
Interfaces
341
9.1 Interface Declarations INTERFACES
InterfaceDeclaration:
NormalInterfaceDeclaration
AnnotationInterfaceDeclaration
NormalInterfaceDeclaration:
{InterfaceModifier} interface TypeIdentifier [TypeParameters]
[InterfaceExtends] [InterfacePermits] InterfaceBody
InterfaceModifier:
(one of)
Annotation public protected private
abstract static sealed non-sealed strictfp
342
INTERFACES Interface Declarations 9.1
The rules concerning annotation modifiers for an interface declaration are specified
in §9.7.4 and §9.7.5.
The access modifier public (§6.6) pertains only to top level interfaces (§7.6) and
member interfaces (§8.5, §9.5), not to local interfaces (§14.3).
The access modifiers protected and private pertain only to member interfaces.
The modifier static pertains only to member interfaces and local interfaces.
It is a compile-time error if the same keyword appears more than once as a modifier
for an interface declaration, or if a interface declaration has more than one of the
access modifiers public, protected, and private.
It is a compile-time error if an interface declaration has more than one of the
modifiers sealed and non-sealed.
343
9.1 Interface Declarations INTERFACES
It is useful to recall that a class is said to be a direct subclass of its direct superinterfaces
(§8.1.5).
The following productions from §8.1.2 and §4.4 are shown here for convenience:
TypeParameters:
< TypeParameterList >
TypeParameterList:
TypeParameter {, TypeParameter}
TypeParameter:
{TypeParameterModifier} TypeIdentifier [TypeBound]
TypeParameterModifier:
Annotation
TypeBound:
extends TypeVariable
extends ClassOrInterfaceType {AdditionalBound}
AdditionalBound:
& InterfaceType
344
INTERFACES Interface Declarations 9.1
The rules concerning annotation modifiers for a type parameter declaration are
specified in §9.7.4 and §9.7.5.
In an interface's type parameter section, a type variable T directly depends on a
type variable S if S is the bound of T, while T depends on S if either T directly
depends on S or T directly depends on a type variable U that depends on S (using this
definition recursively). It is a compile-time error if a type variable in a interface's
type parameter section depends on itself.
The scope and shadowing of an interface's type parameter is specified in §6.3 and
§6.4.1.
References to an interface's type parameter from a static context or a nested class
or interface are restricted, as specified in §6.5.5.1.
A generic interface declaration defines a set of parameterized types (§4.5), one for
each possible parameterization of the type parameter section by type arguments.
All of these parameterized types share the same interface at run time.
InterfaceExtends:
extends InterfaceTypeList
InterfaceTypeList:
InterfaceType {, InterfaceType}
345
9.9 Function Types INTERFACES
interface XY extends X, Y {}
is:
is:
396
INTERFACES Function Types 9.9
interface A {
List<String> foo(List<String> arg)
throws IOException, SQLTransientException;
}
interface B {
List foo(List<String> arg)
throws EOFException, SQLException, TimeoutException;
}
interface C {
List foo(List arg) throws Exception;
}
interface D extends A, B {}
is:
(List<String>)->List<String>
throws EOFException, SQLTransientException
interface E extends A, B, C {}
is:
397
9.9 Function Types INTERFACES
interface G1 {
<E extends Exception> Object m() throws E;
}
interface G2 {
<F extends Exception> String m() throws Exception;
}
interface G extends G1, G2 {}
398