Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
java_language_specification_7.pdf
Скачиваний:
13
Добавлен:
21.03.2016
Размер:
3.11 Mб
Скачать

NAMES

Meaning of Package Names

6.5.3

package org.rpgpoet; import java.util.Random;

public interface Music { Random[] wizards = new Random[4]; }

and then consider this example code in another package:

package bazola; class Gabriel {

static int n = org.rpgpoet.Music.wizards.length;

}

First of all, the name org.rpgpoet.Music.wizards.length is classified as an ExpressionName because it functions as a PostfixExpression. Therefore, each of the names:

org.rpgpoet.Music.wizards

org.rpgpoet.Music

org.rpgpoet org

is initially classified as an AmbiguousName. These are then reclassified:

The simple name org is reclassified as a PackageName (since there is no variable or type named org in scope).

Next, assuming that there is no class or interface named rpgpoet in any compilation unit of package org (and we know that there is no such class or interface because package org has a subpackage named rpgpoet), the qualified name org.rpgpoet is reclassified as a PackageName.

Next, because package org.rpgpoet has an accessible (§6.6) interface type named Music, the qualified name org.rpgpoet.Music is reclassified as a TypeName.

Finally, because the name org.rpgpoet.Music is a TypeName, the qualified name org.rpgpoet.Music.wizards is reclassified as an ExpressionName.

6.5.3 Meaning of Package Names

The meaning of a name classified as a PackageName is determined as follows.

6.5.3.1 Simple Package Names

If a package name consists of a single Identifier, then this identifier denotes a top level package named by that identifier.

If no top level package of that name is in scope (§6.3), then a compile-time error occurs.

145

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]