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.

EXPRESSIONS this 15.8.3<br />

ing-point literal is double and its value must be an element of the double<br />

value set.<br />

• <strong>The</strong> type of a boolean literal is boolean.<br />

• <strong>The</strong> type of a character literal is char.<br />

• <strong>The</strong> type of a string literal is String.<br />

• <strong>The</strong> type of the null literal null is the null type; its value is the null reference.<br />

Evaluation of a lexical literal always completes normally.<br />

15.8.2 Class Literals<br />

A class literal is an expression consisting of the name of a class, interface, array,<br />

or primitive type, or the pseudo-type void, followed by a ‘.’ and the token class.<br />

<strong>The</strong> type of a class literal, C.Class, where C is the name of a class, interface or<br />

array type, is Class. If p is the name of a primitive type, let B be the type of<br />

an expression of type p after boxing conversion (§5.1.7). <strong>The</strong>n the type of<br />

p.class is Class. <strong>The</strong> type of void.class is Class.<br />

A class literal evaluates to the Class object for the named type (or for void) as<br />

defined by the defining class loader of the class of the current instance.<br />

It is a compile time error if any of the following occur:<br />

• <strong>The</strong> named type is a type variable (§4.4) or a parameterized type (§4.5) or an<br />

array whose element type is a type variable or parameterized type.<br />

• <strong>The</strong> named type does not denote a type that is accessible (§6.6) and in scope<br />

(§6.3) at the point where the class literal appears.<br />

15.8.3 this<br />

DRAFT<br />

<strong>The</strong> keyword this may be used only in the body of an instance method, instance<br />

initializer or constructor, or in the initializer of an instance variable of a class. If it<br />

appears anywhere else, a compile-time error occurs.<br />

When used as a primary expression, the keyword this denotes a value that is<br />

a reference to the object for which the instance method was invoked (§15.12), or<br />

to the object being constructed. <strong>The</strong> type of this is the class C within which the<br />

keyword this occurs. At run time, the class of the actual object referred to may<br />

be the class C or any subclass of C.<br />

421

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

Saved successfully!

Ooh no, something went wrong!