Top Description Inners Fields Constructors Methods
org.easymock.bytebuddy.utility

public Class JavaModule

extends Object
implements WithOptionalName, AnnotationSource
Class Inheritance
All Implemented Interfaces
org.easymock.bytebuddy.description.annotation.AnnotationSource, org.easymock.bytebuddy.description.NamedElement.WithOptionalName, org.easymock.bytebuddy.description.NamedElement
Imports
org.easymock.bytebuddy.ClassFileVersion, org.easymock.bytebuddy.build.AccessControllerPlugin, org.easymock.bytebuddy.description.NamedElement, org.easymock.bytebuddy.description.annotation.AnnotationList, .AnnotationSource, org.easymock.bytebuddy.description.type.PackageDescription, org.easymock.bytebuddy.utility.dispatcher.JavaDispatcher, org.easymock.bytebuddy.utility.nullability.AlwaysNull, .MaybeNull, java.io.IOException, .InputStream, java.lang.reflect.AnnotatedElement, java.security.PrivilegedAction, java.util.Set

Type-safe representation of a java.lang.Module. On platforms that do not support the module API, modules are represented by null.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
JavaModule.Module

A proxy for interacting with java.lang.Module.

protected static interface
JavaModule.Resolver

A proxy for resolving a Class's java.lang.Module.

Field Summary

Modifier and TypeField and Description
protected static final JavaModule.Module
MODULE

A dispatcher to interact with java.lang.Module.

private final AnnotatedElement
module

The java.lang.Module instance this wrapper represents.

protected static final JavaModule.Resolver
RESOLVER

A dispatcher to resolve a Class's java.lang.Module.

public static final JavaModule
UNSUPPORTED

Canonical representation of a Java module on a JVM that does not support the module API.

Constructor Summary

AccessConstructor and Description
protected
JavaModule(AnnotatedElement
The java.lang.Module instance this wrapper represents.
module
)

Creates a new Java module representation.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this module can read the supplied module.
canRead
(JavaModule
The module to check for its readability by this module.
module
)

Checks if this module can read the exported packages of the supplied module.

private static <
The type of the action's resolved value.
T
>
T

Returns:

The action's resolved value.
doPrivileged
(PrivilegedAction<T>
The action to execute from a privileged context.
action
)

A proxy for java.security.AccessController#doPrivileged that is activated if available.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
getActualName()

Implements org.easymock.bytebuddy.description.NamedElement.getActualName.

Returns the display name of this element as it is found in the source code.
public ClassLoader

Returns:

The class loader of the represented module.
getClassLoader
()

Returns the class loader of this module.

public AnnotationList
getDeclaredAnnotations()

Implements org.easymock.bytebuddy.description.annotation.AnnotationSource.getDeclaredAnnotations.

Returns a list of annotations that are declared by this instance.
public Set<String>

Returns:

A set of the names of the packages that are defined by this module.
getPackages
()

Returns the packages of this module.

public InputStream

Returns:

An input stream for the resource or null if it does not exist.
getResourceAsStream
(String
The name of the resource.
name
)

Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean

Returns:

true if this module exports the supplied package to this module.
isExported
(PackageDescription
The package to check for
packageDescription
,
JavaModule
The target module.
module
)

Returns true if this module exports the supplied package to this module.

public boolean
isNamed()

Implements org.easymock.bytebuddy.description.NamedElement.WithOptionalName.isNamed.

Returns true if this element has an explicit name.
public boolean

Returns:

true if this module opens the supplied package to this module.
isOpened
(PackageDescription
The package to check for.
packageDescription
,
JavaModule
The target module.
module
)

Returns true if this module opens the supplied package to this module.

public static boolean

Returns:

true if the current VM supports modules.
isSupported
()

Checks if the current VM supports the java.lang.Module API.

public static JavaModule

Returns:

A representation of the supplied Java module.
of
(Object
The module to represent.
module
)

Represents the supplied java.lang.Module as an instance of this class and validates that the supplied instance really represents a Java Module.

public static JavaModule

Returns:

A representation of the type's module or null if the current VM does not support modules.
ofType
(Class<?>
The type for which to describe the module.
type
)

Returns a representation of the supplied type's java.lang.Module or null if the current VM does not support modules.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Object

Returns:

The represented java.lang.Module.
unwrap
()

Unwraps this instance to a java.lang.Module.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

MODULEback to summary
protected static final JavaModule.Module MODULE

A dispatcher to interact with java.lang.Module.

moduleback to summary
private final AnnotatedElement module

The java.lang.Module instance this wrapper represents.

RESOLVERback to summary
protected static final JavaModule.Resolver RESOLVER

A dispatcher to resolve a Class's java.lang.Module.

UNSUPPORTEDback to summary
public static final JavaModule UNSUPPORTED

Canonical representation of a Java module on a JVM that does not support the module API.

Annotations
@AlwaysNull

Constructor Detail

JavaModuleback to summary
protected JavaModule(AnnotatedElement module)

Creates a new Java module representation.

Parameters
module:AnnotatedElement

The java.lang.Module instance this wrapper represents.

Method Detail

canReadback to summary
public boolean canRead(JavaModule module)

Checks if this module can read the exported packages of the supplied module.

Parameters
module:JavaModule

The module to check for its readability by this module.

Returns:boolean

true if this module can read the supplied module.

doPrivilegedback to summary
private static <T> T doPrivileged(PrivilegedAction<T> action)

A proxy for java.security.AccessController#doPrivileged that is activated if available.

Parameters
<T>
The type of the action's resolved value.
action:PrivilegedAction<T>

The action to execute from a privileged context.

Returns:T

The action's resolved value.

Annotations
@Enhance
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getActualNameback to summary
public String getActualName()

Implements org.easymock.bytebuddy.description.NamedElement.getActualName.

Doc from org.easymock.bytebuddy.description.NamedElement.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.

Returns:String

The name of this element as given in a Java program's source code.

getClassLoaderback to summary
public ClassLoader getClassLoader()

Returns the class loader of this module.

Returns:ClassLoader

The class loader of the represented module.

Annotations
@MaybeNull
getDeclaredAnnotationsback to summary
public AnnotationList getDeclaredAnnotations()

Implements org.easymock.bytebuddy.description.annotation.AnnotationSource.getDeclaredAnnotations.

Doc from org.easymock.bytebuddy.description.annotation.AnnotationSource.getDeclaredAnnotations.

Returns a list of annotations that are declared by this instance.

Returns:AnnotationList

A list of declared annotations.

getPackagesback to summary
public Set<String> getPackages()

Returns the packages of this module.

Returns:Set<String>

A set of the names of the packages that are defined by this module.

getResourceAsStreamback to summary
public InputStream getResourceAsStream(String name) throws IOException

Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.

Parameters
name:String

The name of the resource.

Returns:InputStream

An input stream for the resource or null if it does not exist.

Annotations
@MaybeNull
Exceptions
IOException:
If an I/O exception occurs.
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isExportedback to summary
public boolean isExported(PackageDescription packageDescription, JavaModule module)

Returns true if this module exports the supplied package to this module.

Parameters
packageDescription:PackageDescription

The package to check for

module:JavaModule

The target module.

Returns:boolean

true if this module exports the supplied package to this module.

isNamedback to summary
public boolean isNamed()

Implements org.easymock.bytebuddy.description.NamedElement.WithOptionalName.isNamed.

Doc from org.easymock.bytebuddy.description.NamedElement.WithOptionalName.isNamed.

Returns true if this element has an explicit name.

Returns:boolean

true if this element has an explicit name.

isOpenedback to summary
public boolean isOpened(PackageDescription packageDescription, JavaModule module)

Returns true if this module opens the supplied package to this module.

Parameters
packageDescription:PackageDescription

The package to check for.

module:JavaModule

The target module.

Returns:boolean

true if this module opens the supplied package to this module.

isSupportedback to summary
public static boolean isSupported()

Checks if the current VM supports the java.lang.Module API.

Returns:boolean

true if the current VM supports modules.

ofback to summary
public static JavaModule of(Object module)

Represents the supplied java.lang.Module as an instance of this class and validates that the supplied instance really represents a Java Module.

Parameters
module:Object

The module to represent.

Returns:JavaModule

A representation of the supplied Java module.

ofTypeback to summary
public static JavaModule ofType(Class<?> type)

Returns a representation of the supplied type's java.lang.Module or null if the current VM does not support modules.

Parameters
type:Class<?>

The type for which to describe the module.

Returns:JavaModule

A representation of the type's module or null if the current VM does not support modules.

Annotations
@MaybeNull
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
unwrapback to summary
public Object unwrap()

Unwraps this instance to a java.lang.Module.

Returns:Object

The represented java.lang.Module.

org.easymock.bytebuddy.utility back to summary

protected Interface JavaModule.Module

Annotations
@Proxied:Module

A proxy for interacting with java.lang.Module.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the source module can read the target module.
canRead
(Object
The source module.
value
,
Object
The target module.
target
)

Checks if the source module can read the target module.

public ClassLoader

Returns:

The module's class loader.
getClassLoader
(Object
The java.lang.Module for which to return a class loader.
value
)

Returns the class loader of a module.

public String

Returns:

The module's (implicit or explicit) name.
getName
(Object
The java.lang.Module to check for its name.
value
)

Returns the module's name.

public Set<String>

Returns:

The module's packages.
getPackages
(Object
The java.lang.Module to check for its packages.
value
)

Returns the module's exported packages.

public InputStream

Returns:

An input stream for the resource or null if it does not exist.
getResourceAsStream
(Object
The java.lang.Module instance to apply this method upon.
value
,
String
The name of the resource.
name
)

Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.

public boolean

Returns:

true if the source module exports the supplied package to the target module.
isExported
(Object
The source module.
value
,
String
The name of the package to check.
aPackage
,
Object
The target module.
target
)

Returns true if the source module exports the supplied package to the target module.

public boolean

Returns:

true if the supplied value is a java.lang.Module.
isInstance
(Object
The instance to investigate.
value
)

Returns true if the supplied instance is of type java.lang.Module.

public boolean

Returns:

true if the supplied module is named.
isNamed
(Object
The java.lang.Module to check for the existence of a name.
value
)

Returns true if the supplied module is named.

public boolean

Returns:

true if the source module opens the supplied package to the target module.
isOpen
(Object
The source module.
value
,
String
The name of the package to check.
aPackage
,
Object
The target module.
target
)

Returns true if the source module opens the supplied package to the target module.

Method Detail

canReadback to summary
public boolean canRead(Object value, Object target)

Checks if the source module can read the target module.

Parameters
value:Object

The source module.

target:Object

The target module.

Returns:boolean

true if the source module can read the target module.

getClassLoaderback to summary
public ClassLoader getClassLoader(Object value)

Returns the class loader of a module.

Parameters
value:Object

The java.lang.Module for which to return a class loader.

Returns:ClassLoader

The module's class loader.

Annotations
@MaybeNull
getNameback to summary
public String getName(Object value)

Returns the module's name.

Parameters
value:Object

The java.lang.Module to check for its name.

Returns:String

The module's (implicit or explicit) name.

getPackagesback to summary
public Set<String> getPackages(Object value)

Returns the module's exported packages.

Parameters
value:Object

The java.lang.Module to check for its packages.

Returns:Set<String>

The module's packages.

getResourceAsStreamback to summary
public InputStream getResourceAsStream(Object value, String name) throws IOException

Returns a resource stream for this module for a resource of the given name or null if such a resource does not exist.

Parameters
value:Object

The java.lang.Module instance to apply this method upon.

name:String

The name of the resource.

Returns:InputStream

An input stream for the resource or null if it does not exist.

Annotations
@MaybeNull
Exceptions
IOException:
If an I/O exception occurs.
isExportedback to summary
public boolean isExported(Object value, String aPackage, Object target)

Returns true if the source module exports the supplied package to the target module.

Parameters
value:Object

The source module.

aPackage:String

The name of the package to check.

target:Object

The target module.

Returns:boolean

true if the source module exports the supplied package to the target module.

isInstanceback to summary
public boolean isInstance(Object value)

Returns true if the supplied instance is of type java.lang.Module.

Parameters
value:Object

The instance to investigate.

Returns:boolean

true if the supplied value is a java.lang.Module.

Annotations
@Instance
isNamedback to summary
public boolean isNamed(Object value)

Returns true if the supplied module is named.

Parameters
value:Object

The java.lang.Module to check for the existence of a name.

Returns:boolean

true if the supplied module is named.

isOpenback to summary
public boolean isOpen(Object value, String aPackage, Object target)

Returns true if the source module opens the supplied package to the target module.

Parameters
value:Object

The source module.

aPackage:String

The name of the package to check.

target:Object

The target module.

Returns:boolean

true if the source module opens the supplied package to the target module.

org.easymock.bytebuddy.utility back to summary

protected Interface JavaModule.Resolver

Annotations
@Proxied:Class

A proxy for resolving a Class's java.lang.Module.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

The type's module or null if the module system is not supported.
getModule
(Class<?>
The type for which to resolve the module.
type
)

Resolves the java.lang.Module of the supplied type.

Method Detail

getModuleback to summary
public Object getModule(Class<?> type)

Resolves the java.lang.Module of the supplied type.

Parameters
type:Class<?>

The type for which to resolve the module.

Returns:Object

The type's module or null if the module system is not supported.

Annotations
@MaybeNull
@Defaults