10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.4.3 Method Modifiers CLASSES<br />

214<br />

Two method signatures m1 and m2 are override-equivalent iff either m1 is a subsignature<br />

of m2 or m2 is a subsignature of m1.<br />

<strong>The</strong> example:<br />

class Point implements Move {<br />

int x, y;<br />

abstract void move(int dx, int dy);<br />

void move(int dx, int dy) { x += dx; y += dy; }<br />

}<br />

causes a compile-time error because it declares two move methods with the same<br />

(and hence, override-equivalent) signature. This is an error even though one of the<br />

declarations is abstract.<br />

8.4.3 Method Modifiers<br />

MethodModifiers:<br />

MethodModifier<br />

MethodModifiers MethodModifier<br />

MethodModifier: one of<br />

Annotation public protected private abstract static<br />

final synchronized native strictfp<br />

<strong>The</strong> access modifiers public, protected, and private are discussed in<br />

§6.6. A compile-time error occurs if the same modifier appears more than once in<br />

a method declaration, or if a method declaration has more than one of the access<br />

modifiers public, protected, and private. A compile-time error occurs if a<br />

method declaration that contains the keyword abstract also contains any one of<br />

the keywords private, static, final, native, strictfp,orsynchronized.A<br />

compile-time error occurs if a method declaration that contains the keyword<br />

native also contains strictfp.<br />

If an annotation a on a method declaration corresponds to an annotation type<br />

T, and T has a (meta-)annotation m that corresponds to annotation.Target, then<br />

m must have an element whose value is annotation.ElementType.METHOD, ora<br />

compile-time error occurs. Annotations are discussed further in §9.7.<br />

If two or more method modifiers appear in a method declaration, it is customary,<br />

though not required, that they appear in the order consistent with that shown<br />

above in the production for MethodModifier.<br />

8.4.3.1 abstract Methods<br />

DRAFT<br />

An abstract method declaration introduces the method as a member, providing<br />

its signature (§8.4.2), return type, and throws clause (if any), but does not provide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!