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.

NAMES Meaning of Package Names 6.5.3<br />

As an example, consider the following contrived “library code”:<br />

package org.rpgpoet;<br />

import java.util.Random;<br />

interface Music { Random[] wizards = new Random[4]; }<br />

and then consider this example code in another package:<br />

package bazola;<br />

class Gabriel {<br />

static int n = org.rpgpoet.Music.wizards.length;<br />

}<br />

First of all, the name org.rpgpoet.Music.wizards.length is classified as an<br />

ExpressionName because it functions as a PostfixExpression. <strong>The</strong>refore, each of<br />

the names:<br />

org.rpgpoet.Music.wizards<br />

org.rpgpoet.Music<br />

org.rpgpoet<br />

org<br />

is initially classified as an AmbiguousName. <strong>The</strong>se are then reclassified:<br />

• <strong>The</strong> simple name org is reclassified as a PackageName (since there is no variable<br />

or type named org in scope).<br />

• Next, assuming that there is no class or interface named rpgpoet in any compilation<br />

unit of package org (and we know that there is no such class or interface<br />

because package org has a subpackage named rpgpoet), the qualified<br />

name org.rpgpoet is reclassified as a PackageName.<br />

• Next, because package org.rpgpoet has an interface type named Music, the<br />

qualified name org.rpgpoet.Music is reclassified as a TypeName.<br />

• Finally, because the name org.rpgpoet.Music is a TypeName, the qualified<br />

name org.rpgpoet.Music.wizards is reclassified as an ExpressionName.<br />

DRAFT<br />

6.5.3 Meaning of Package Names<br />

<strong>The</strong> meaning of a name classified as a PackageName is determined as follows.<br />

6.5.3.1 Simple Package Names<br />

If a package name consists of a single Identifier, then this identifier denotes a top<br />

level package named by that identifier. If no top level package of that name is in<br />

scope (§7.4.4), then a compile-time error occurs.<br />

131

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

Saved successfully!

Ooh no, something went wrong!