public class JavaModule extends Object implements NamedElement.WithOptionalName
java.lang.reflect.Module
. On platforms that do not support the module API, modules are represented by null
.Modifier and Type | Class and Description |
---|---|
protected static interface |
JavaModule.Dispatcher
A dispatcher for accessing the
java.lang.reflect.Module API if it is available on the current VM. |
NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
Modifier and Type | Field and Description |
---|---|
static JavaModule |
UNSUPPORTED
Canonical representation of a Java module on a JVM that does not support the module API.
|
EMPTY_NAME, NO_NAME
Modifier | Constructor and Description |
---|---|
protected |
JavaModule(Object module)
Creates a new Java module representation.
|
Modifier and Type | Method and Description |
---|---|
void |
addReads(Instrumentation instrumentation,
JavaModule module)
Adds a read-edge to this module to the supplied module using the instrumentation API.
|
boolean |
canRead(JavaModule module)
Checks if this module can read the exported packages of the supplied module.
|
boolean |
equals(Object object) |
String |
getActualName()
Returns the name of this element as it is found in the source code.
|
ClassLoader |
getClassLoader()
Returns the class loader of this module.
|
InputStream |
getResourceAsStream(String name)
Returns a resource stream for this module for a resource of the given name or
null if such a resource does not exist. |
int |
hashCode() |
boolean |
isNamed()
Returns
true if this element has an explicit name. |
static boolean |
isSupported()
Checks if the current VM supports the
java.lang.reflect.Module API. |
static JavaModule |
of(Object module)
Represents the supplied
java.lang.reflect.Module as an instance of this class and validates that the
supplied instance really represents a Java Module . |
static JavaModule |
ofType(Class<?> type)
Returns a representation of the supplied type's
java.lang.reflect.Module or null if the current VM does not support modules. |
String |
toString() |
Object |
unwrap()
Unwraps this instance to a
java.lang.reflect.Module . |
public static final JavaModule UNSUPPORTED
protected JavaModule(Object module)
module
- The java.lang.reflect.Module
instance this wrapper represents.public static JavaModule ofType(Class<?> type)
java.lang.reflect.Module
or null
if the current VM does not support modules.type
- The type for which to describe the module.null
if the current VM does not support modules.public static JavaModule of(Object module)
java.lang.reflect.Module
as an instance of this class and validates that the
supplied instance really represents a Java Module
.module
- The module to represent.public static boolean isSupported()
java.lang.reflect.Module
API.true
if the current VM supports modules.public boolean isNamed()
NamedElement.WithOptionalName
true
if this element has an explicit name.isNamed
in interface NamedElement.WithOptionalName
true
if this element has an explicit name.public String getActualName()
NamedElement
getActualName
in interface NamedElement
public InputStream getResourceAsStream(String name)
null
if such a resource does not exist.name
- The name of the resource.null
if it does not exist.public ClassLoader getClassLoader()
public Object unwrap()
java.lang.reflect.Module
.java.lang.reflect.Module
.public boolean canRead(JavaModule module)
module
- The module to check for its readability by this module.true
if this module can read the supplied module.public void addReads(Instrumentation instrumentation, JavaModule module)
instrumentation
- The instrumentation instance to use for adding the edge.module
- The module to add as a read dependency to this module.Copyright © 2014–2017. All rights reserved.