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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8.5.1 Modifiers CLASSES<br />

238<br />

If the same type declaration is inherited from an interface by multiple paths,<br />

the class or interface is considered to be inherited only once. It may be referred to<br />

by its simple name without ambiguity.<br />

8.5.1 Modifiers<br />

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

A compile-time error occurs if a member type declaration has more than one of<br />

the access modifiers public, protected, and private.<br />

Member type declarations may have annotation modifers just like any type or<br />

member declaration.<br />

8.5.2 Static Member Type Declarations<br />

<strong>The</strong> static keyword may modify the declaration of a member type C within the<br />

body of a non-inner class T. Its effect is to declare that C is not an inner class. Just<br />

as a static method of T has no current instance of T in its body, C also has no current<br />

instance of T, nor does it have any lexically enclosing instances.<br />

It is a compile-time error if a static class contains a usage of a non-static<br />

member of an enclosing class.<br />

Member interfaces are always implicitly static. It is permitted but not<br />

required for the declaration of a member interface to explicitly list the static<br />

modifier.<br />

8.6 Instance Initializers<br />

An instance initializer declared in a class is executed when an instance of the class<br />

is created (§15.9), as specified in §8.8.7.1.<br />

InstanceInitializer:<br />

Block<br />

It is compile-time error if an instance initializer of a named class can throw a<br />

checked exception unless that exception or one of its supertypes is explicitly<br />

declared in the throws clause of each constructor of its class and the class has at<br />

least one explicitly declared constructor. An instance initializer in an anonymous<br />

class (§15.9.5) can throw any exceptions.<br />

DRAFT<br />

<strong>The</strong> rules above distinguish between instance initializers in named and anonymous<br />

classes. This distinction is deliberate. A given anonymous class is only<br />

instantiated at a single point in a program. It is therefore possible to directly prop-

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

Saved successfully!

Ooh no, something went wrong!