Class JavaModule
java.lang.Object
net.bytebuddy.utility.JavaModule
- All Implemented Interfaces:
AnnotationSource, NamedElement, NamedElement.WithOptionalName
Type-safe representation of a
java.lang.Module. On platforms that do not support the module API, modules are represented by null.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceA proxy for interacting withjava.lang.Module.protected static interfaceA proxy for resolving aClass'sjava.lang.Module.Nested classes/interfaces inherited from interface AnnotationSource
AnnotationSource.Empty, AnnotationSource.ExplicitNested classes/interfaces inherited from interface NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AnnotatedElementThejava.lang.Moduleinstance this wrapper represents.protected static final JavaModule.ModuleA dispatcher to interact withjava.lang.Module.protected static final JavaModule.ResolverA dispatcher to resolve aClass'sjava.lang.Module.static final JavaModuleCanonical representation of a Java module on a JVM that does not support the module API.Fields inherited from interface NamedElement
EMPTY_NAME, NO_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJavaModule(AnnotatedElement module) Creates a new Java module representation. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRead(JavaModule module) Checks if this module can read the exported packages of the supplied module.private static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.booleanReturns the display name of this element as it is found in the source code.Returns the class loader of this module.Returns a list of annotations that are declared by this instance.Returns the packages of this module.getResourceAsStream(String name) Returns a resource stream for this module for a resource of the given name ornullif such a resource does not exist.inthashCode()booleanisExported(PackageDescription packageDescription, JavaModule module) Returnstrueif this module exports the supplied package to this module.booleanisNamed()Returnstrueif this element has an explicit name.booleanisOpened(PackageDescription packageDescription, JavaModule module) Returnstrueif this module opens the supplied package to this module.static booleanChecks if the current VM supports thejava.lang.ModuleAPI.static JavaModuleRepresents the suppliedjava.lang.Moduleas an instance of this class and validates that the supplied instance really represents a JavaModule.static JavaModuleReturns a representation of the supplied type'sjava.lang.Moduleornullif the current VM does not support modules.Returns a description of the module if the current module is a named module.toString()unwrap()Unwraps this instance to ajava.lang.Module.
-
Field Details
-
UNSUPPORTED
Canonical representation of a Java module on a JVM that does not support the module API. -
RESOLVER
A dispatcher to resolve aClass'sjava.lang.Module. -
MODULE
A dispatcher to interact withjava.lang.Module. -
module
Thejava.lang.Moduleinstance this wrapper represents.
-
-
Constructor Details
-
JavaModule
Creates a new Java module representation.- Parameters:
module- Thejava.lang.Moduleinstance this wrapper represents.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.- Type Parameters:
T- The type of the action's resolved value.- Parameters:
action- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
ofType
Returns a representation of the supplied type'sjava.lang.Moduleornullif the current VM does not support modules.- Parameters:
type- The type for which to describe the module.- Returns:
- A representation of the type's module or
nullif the current VM does not support modules.
-
of
Represents the suppliedjava.lang.Moduleas an instance of this class and validates that the supplied instance really represents a JavaModule.- Parameters:
module- The module to represent.- Returns:
- A representation of the supplied Java module.
-
isSupported
public static boolean isSupported()Checks if the current VM supports thejava.lang.ModuleAPI.- Returns:
trueif the current VM supports modules.
-
isNamed
public boolean isNamed()Returnstrueif this element has an explicit name.- Specified by:
isNamedin interfaceNamedElement.WithOptionalName- Returns:
trueif this element has an explicit name.
-
getActualName
Returns the display name of this element as it is found in the source code. If no such name exists, an empty string is returned.- Specified by:
getActualNamein interfaceNamedElement- Returns:
- The name of this element as given in a Java program's source code.
-
getPackages
-
getResourceAsStream
Returns a resource stream for this module for a resource of the given name ornullif such a resource does not exist.- Parameters:
name- The name of the resource.- Returns:
- An input stream for the resource or
nullif it does not exist. - Throws:
IOException- If an I/O exception occurs.
-
getClassLoader
Returns the class loader of this module.- Returns:
- The class loader of the represented module.
-
unwrap
Unwraps this instance to ajava.lang.Module.- Returns:
- The represented
java.lang.Module.
-
canRead
Checks if this module can read the exported packages of the supplied module.- Parameters:
module- The module to check for its readability by this module.- Returns:
trueif this module can read the supplied module.
-
isExported
Returnstrueif this module exports the supplied package to this module.- Parameters:
packageDescription- The package to check formodule- The target module.- Returns:
trueif this module exports the supplied package to this module.
-
isOpened
Returnstrueif this module opens the supplied package to this module.- Parameters:
packageDescription- The package to check for.module- The target module.- Returns:
trueif this module opens the supplied package to this module.
-
getDeclaredAnnotations
Returns a list of annotations that are declared by this instance.- Specified by:
getDeclaredAnnotationsin interfaceAnnotationSource- Returns:
- A list of declared annotations.
-
toDescription
Returns a description of the module if the current module is a named module. Otherwise, an exception is thrown.- Returns:
- A description of the current module.
-
hashCode
-
equals
-
toString
-