java.lang.reflect
Class Superpackage

java.lang.Object
  extended by java.lang.reflect.Superpackage
All Implemented Interfaces:
AnnotatedElement

public final class Superpackage
extends Object
implements AnnotatedElement

Instances of the class Superpackage represent superpackages in a running Java application.

Superpackage has no public constructor. Instead Superpackage objects are constructed automatically by the Java Virtual Machine as superpackages are loaded and by calls to the defineSuperpackage method in the class loader.

Since:
1.7
Author:
Andreas Sterbenz
See Also:
Class.getSuperpackage(), ClassLoader.findSuperpackage(String)

Nested Class Summary
static class Superpackage.exports
          temporary for superpackage definition until javac support arrives
static class Superpackage.members
          temporary for superpackage definition until javac support arrives
static class Superpackage.uses
          temporary for superpackage definition until javac support arrives
 
Method Summary
<A extends Annotation>
A
getAnnotation(Class<A> annotationClass)
           
 Annotation[] getAnnotations()
           
 ClassLoader getClassLoader()
          Returns the class loader for the superpackage.
 Annotation[] getDeclaredAnnotations()
           
 Superpackage getEnclosingSuperpackage()
          Returns the immediately enclosing superpackage of the underlying superpackage.
 Superpackage[] getExportedSuperpackages()
          Returns an array of Superpackage objects reflecting the exported superpackages that are a direct member of this superpackage.
 String[] getExportedTypes()
          Returns an array of String objects reflecting the binary names of all exported classes and interfaces that are a direct member of this superpackage.
<A extends Annotation>
A
getImportAnnotation(String importName, Class<A> annotationClass)
          Temporary, not in superpackage strawman
 Set<String> getImported()
          Temporary, not in superpackage strawman
 Superpackage[] getMemberSuperpackages()
          Returns an array of Superpackage objects reflecting the superpackages that are a direct member of this superpackage.
 String[] getMemberTypes()
          Returns an array of String objects reflecting the binary names of all classes and interfaces that are a direct member of this superpackage.
 String getName()
          Returns the fully qualified name of this superpackage.
 boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
           
 String toString()
          Converts the object to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public String getName()
Returns the fully qualified name of this superpackage.

Returns:
the fully qualified name of this superpackage.

getMemberTypes

public String[] getMemberTypes()
Returns an array of String objects reflecting the binary names of all classes and interfaces that are a direct member of this superpackage. Types that are a member of a nested superpackages are not returned.

The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the superpackage has no direct members that are types.

Returns:
an array of the names of all direct member types

getMemberSuperpackages

public Superpackage[] getMemberSuperpackages()
Returns an array of Superpackage objects reflecting the superpackages that are a direct member of this superpackage. Superpackages that are a member of these nested superpackages are not returned.

The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the superpackage has no members that are superpackages

Returns:
an array of the Superpackage objects of all direct member superpackages

getExportedTypes

public String[] getExportedTypes()
Returns an array of String objects reflecting the binary names of all exported classes and interfaces that are a direct member of this superpackage. Types that are a member of a nested superpackages are not returned. The names returned by this method are a subset of the names returned by getMemberTypes().

The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the superpackage has no direct members that are exported types.

Returns:
an array of the names of all direct exported member types

getExportedSuperpackages

public Superpackage[] getExportedSuperpackages()
Returns an array of Superpackage objects reflecting the exported superpackages that are a direct member of this superpackage. Superpackages that are a member of these nested superpackages are not returned. The superpackages returned by this method are a subset of the superpackages returned by getMemberSuperpackages().

The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the superpackage has no direct members that are exported superpackages.

Returns:
an array of the Superpackage objects of all exported member superpackages

getEnclosingSuperpackage

public Superpackage getEnclosingSuperpackage()
Returns the immediately enclosing superpackage of the underlying superpackage. If the underlying superpackage is a top level superpackage, this method returns null.

Returns:
the immediately enclosing superpackage of the underlying superpackage

getClassLoader

public ClassLoader getClassLoader()
Returns the class loader for the superpackage. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader.

If a security manager is present, and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the class loader for the superpackage whose class loader is requested, then this method calls the security manager's checkPermission method with a RuntimePermission("getClassLoader") permission to ensure it's ok to access the class loader for the superpackage.

Returns:
the class loader that loaded the superpackage represented by this object.
Throws:
SecurityException - if a security manager exists and its checkPermission method denies access to the class loader for the superpackage.
See Also:
ClassLoader, SecurityManager.checkPermission(java.security.Permission), RuntimePermission

getAnnotation

public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
Specified by:
getAnnotation in interface AnnotatedElement
Throws:
NullPointerException

isAnnotationPresent

public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
Specified by:
isAnnotationPresent in interface AnnotatedElement
Throws:
NullPointerException

getAnnotations

public Annotation[] getAnnotations()
Specified by:
getAnnotations in interface AnnotatedElement

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
Specified by:
getDeclaredAnnotations in interface AnnotatedElement

toString

public String toString()
Converts the object to a string. The string representation is the string "superpackage" followed by a space, and then by the fully qualified name of the superpackage in the format returned by getName.

Overrides:
toString in class Object
Returns:
a string representation of this superpackage object.

getImported

public Set<String> getImported()
Temporary, not in superpackage strawman


getImportAnnotation

public <A extends Annotation> A getImportAnnotation(String importName,
                                                    Class<A> annotationClass)
Temporary, not in superpackage strawman