AnnotatedConstruct
, Element
, QualifiedNameable
public interface PackageElement extends Element, QualifiedNameable
package-info.java
file (JLS 7.4.1). A named package without a standalone package-info.java
file can be declared in the package declaration of a top-level class or interface. Implicit information is used to model unnamed packages (JLS 7.4.2). In the context of annotation processing, a package element can be:
Modifier and Type | Method | Description |
---|---|---|
TypeMirror |
asType() |
Returns a pseudo-type for this package. |
List |
getEnclosedElements() |
Returns the top-level classes and interfaces within this package. |
Element |
getEnclosingElement() |
Returns the enclosing module if such a module exists; otherwise null . |
Name |
getQualifiedName() |
Returns the fully qualified name of this package. |
Name |
getSimpleName() |
Returns the simple name of this package. |
boolean |
isUnnamed() |
Returns true if this is an unnamed package and
false otherwise. |
accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getKind, getModifiers, hashCode
TypeMirror asType()
asType
in interface Element
Name getQualifiedName()
getQualifiedName
in interface QualifiedNameable
.
", followed by the simple (member) name of the subpackage.Name getSimpleName()
getSimpleName
in interface Element
List<? extends Element> getEnclosedElements()
getEnclosedElements
in interface Element
boolean isUnnamed()
true
if this is an unnamed package and
false
otherwise.true
if this is an unnamed package and
false
otherwiseElement getEnclosingElement()
null
. One situation where a module does not exist for a package is if the environment does not include modules, such as an annotation processing environment configured for a source version without modules.getEnclosingElement
in interface Element
null
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.compiler/javax/lang/model/element/PackageElement.html