Class ModuleBinding
- All Implemented Interfaces:
IUpdatableModule
- Direct Known Subclasses:
BinaryModuleBinding
,ModuleBinding.UnNamedModule
,SourceModuleBinding
First, it canonically represents modules in the world of bindings.
Secondly, it adds a graph layer on top of LookupEnvironment
:
ModuleBindins are linked through "read" edges as per JPMS (see java.lang.module.Configuration).
Additionally, each ModuleBinding holds its own instance of LookupEnviroment,
capturing all packages and types that are visible to the current module.
As a subset of all visible types, the ModuleBinding knows the set of
packages locally declared in this module.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.env.IUpdatableModule
IUpdatableModule.AddExports, IUpdatableModule.AddReads, IUpdatableModule.UpdateKind, IUpdatableModule.UpdatesByKind
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char[]
Name to represent unnamed modules in --add-exports and --add-reads options.static final char[]
Module name for package/type lookup that doesn't care about modules.static final char[]
Module name for package/type lookup that should look into all named modules.Packages declared in this module (indexed by qualified name).int
protected PlainPackageBinding[]
char[]
int
char[]
protected PlainPackageBinding[]
protected ModuleBinding[]
protected ModuleBinding[]
protected TypeBinding[]
long
static final char[]
Name of the unnamed module.static final char[]
Module name for an unobservable moduleprotected TypeBinding[]
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding
ANY_EXCEPTION, ARRAY_TYPE, BASE_TYPE, DefaultLocationArrayContents, DefaultLocationField, DefaultLocationParameter, DefaultLocationReturnType, DefaultLocationsForTrueValue, DefaultLocationTypeArgument, DefaultLocationTypeBound, DefaultLocationTypeParameter, FIELD, GENERIC_TYPE, IMPORT, INTERSECTION_TYPE, INTERSECTION_TYPE18, LOCAL, METHOD, MODULE, NO_ANNOTATIONS, NO_COMPONENTS, NO_ELEMENT_VALUE_PAIRS, NO_EXCEPTIONS, NO_FIELDS, NO_MEMBER_TYPES, NO_METHODS, NO_MODULES, NO_NULL_DEFAULT, NO_PACKAGES, NO_PARAMETER_NAMES, NO_PARAMETERS, NO_PERMITTEDTYPES, NO_PLAIN_PACKAGES, NO_REFERENCE_TYPES, NO_SUPERINTERFACES, NO_TYPE_VARIABLES, NO_TYPES, NULL_UNSPECIFIED_BY_DEFAULT, NullnessDefaultMASK, PACKAGE, PARAMETERIZED_TYPE, PATTERN, POLY_TYPE, RAW_TYPE, RECORD_COMPONENT, TYPE, TYPE_PARAMETER, TYPE_USE, UNINITIALIZED_COMPONENTS, UNINITIALIZED_FIELDS, UNINITIALIZED_METHODS, UNINITIALIZED_REFERENCE_TYPES, VARIABLE, WILDCARD_TYPE
-
Constructor Summary
ModifierConstructorDescriptionprotected
ModuleBinding
(char[] moduleName, LookupEnvironment existingEnvironment) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExports
(char[] packageName, char[][] targetModules) Perform an --add-exports update on the module.void
addReads
(char[] requiredModuleName) Perform an --add-reads update on the module.void
addResolvedExport
(PlainPackageBinding declaredPackage, char[][] targetModules) void
addResolvedOpens
(PlainPackageBinding declaredPackage, char[][] targetModules) boolean
canAccess
(PackageBinding pkg) Check if the given package is accessible by this module.char[]
computeUniqueKey
(boolean isLeaf) Get all the modules required by this module All required modules include modules explicitly specified as required in the module declaration as well as implicit dependencies - those specified as ' requires transitive ' by one of the dependenciesint
String[]
getImplementations
(TypeBinding binding) String[]
getOpens()
getOrCreateDeclaredPackage
(char[][] compoundName) char[][]
getTopLevelPackage
(char[] name) Return a package binding if there exists a package named name in this module's context and it can be seen by this module.getUses()
getVisiblePackage
(char[][] qualifiedPackageName) Answer the package of the given qualified name and visible in this module, ornull
if no such package exists.boolean
boolean
boolean
boolean
isOpen()
boolean
isPackageExportedTo
(PackageBinding pkg, ModuleBinding client) Check if the specified package is owned by the current module and exported to the client module.boolean
isTransitivelyRequired
(ModuleBinding otherModule) boolean
int
kind()
char[]
name()
Answer the name of this module.char[]
Answer the name of this module as it should be used for hasCompilationUnit() checks.char[]
Answer the name of this module as it should be used for package or type lookup.char[]
protected void
recordExportRestrictions
(PlainPackageBinding exportedPackage, char[][] targetModules) protected void
recordOpensRestrictions
(PlainPackageBinding openedPackage, char[][] targetModules) retrieveAnnotationHolder
(Binding binding, boolean forceInitialization) void
setAnnotations
(AnnotationBinding[] annotations, boolean forceStore) void
setMainClassName
(char[] mainClassName) Define the ModuleMainClass to be recorded in the generated module-info.class.void
setPackageNames
(SimpleSetOfCharArray packageNames) Passes names of packages to be recorded in the ModulePackages classfile attribute.toString()
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding
computeUniqueKey, getAnnotations, getAnnotationTagBits, initializeDeprecatedAnnotationTagBits, isAnnotationType, isParameter, isPatternVariable, isTaggedRepeatable, isValid, isValidBinding, isVolatile, problemId, setAnnotations, shortReadableName
-
Field Details
-
UNNAMED
public static final char[] UNNAMEDName of the unnamed module. -
ALL_UNNAMED
public static final char[] ALL_UNNAMEDName to represent unnamed modules in --add-exports and --add-reads options. -
ANY
public static final char[] ANYModule name for package/type lookup that doesn't care about modules. -
ANY_NAMED
public static final char[] ANY_NAMEDModule name for package/type lookup that should look into all named modules. -
UNOBSERVABLE
public static final char[] UNOBSERVABLEModule name for an unobservable module -
moduleName
public char[] moduleName -
requires
-
requiresTransitive
-
exportedPackages
-
openedPackages
-
uses
-
services
-
implementations
-
mainClassName
public char[] mainClassName -
modifiers
public int modifiers -
environment
-
tagBits
public long tagBits -
defaultNullness
public int defaultNullness -
declaredPackages
Packages declared in this module (indexed by qualified name). We consider a package as declared in a module, if a compilation unit associated with the module declares the package or a subpackage thereof.A package in this structures is always represented by a
PlainPackageBinding
, as opposed toSplitPackageBinding
, which are only maintained in the trees belowLookupEnvironment.knownPackages
.This structure is populated early during compilation with all packages that are referenced in exports and opens directives, plus their parent packages.
-
-
Constructor Details
-
ModuleBinding
-
-
Method Details
-
getExports
-
getExportRestrictions
-
getOpens
-
getOpenRestrictions
-
getImplementations
-
getRequires
-
getRequiresTransitive
-
getUses
-
getServices
-
addReads
public void addReads(char[] requiredModuleName) Description copied from interface:IUpdatableModule
Perform an --add-reads update on the module.- Specified by:
addReads
in interfaceIUpdatableModule
-
addExports
public void addExports(char[] packageName, char[][] targetModules) Description copied from interface:IUpdatableModule
Perform an --add-exports update on the module.- Specified by:
addExports
in interfaceIUpdatableModule
-
setMainClassName
public void setMainClassName(char[] mainClassName) Description copied from interface:IUpdatableModule
Define the ModuleMainClass to be recorded in the generated module-info.class.- Specified by:
setMainClassName
in interfaceIUpdatableModule
-
setPackageNames
Description copied from interface:IUpdatableModule
Passes names of packages to be recorded in the ModulePackages classfile attribute.- Specified by:
setPackageNames
in interfaceIUpdatableModule
-
getPackageNamesForClassFile
public char[][] getPackageNamesForClassFile()- Returns:
- array of names, which may contain nulls.
-
getOrCreateDeclaredPackage
-
addResolvedExport
-
addResolvedOpens
-
recordExportRestrictions
protected void recordExportRestrictions(PlainPackageBinding exportedPackage, char[][] targetModules) -
recordOpensRestrictions
-
dependencyGraphCollector
-
dependencyCollector
-
getAllRequiredModules
Get all the modules required by this module All required modules include modules explicitly specified as required in the module declaration as well as implicit dependencies - those specified as ' requires transitive ' by one of the dependencies- Returns:
- An array of all required modules
-
name
public char[] name()Answer the name of this module. The unnamed module is identified byUNNAMED
.- Specified by:
name
in interfaceIUpdatableModule
-
nameForLookup
public char[] nameForLookup() -
nameForCUCheck
public char[] nameForCUCheck()Answer the name of this module as it should be used for hasCompilationUnit() checks. -
isPackageExportedTo
Check if the specified package is owned by the current module and exported to the client module. True if the package appears in the list of exported packages and when the export is targeted, the module appears in the targets of the exports statement.- Parameters:
pkg
- - the package whose visibility is to be checkedclient
- - the module that wishes to use the package- Returns:
- true if the package is visible to the client module, false otherwise
-
getTopLevelPackage
Return a package binding if there exists a package named name in this module's context and it can be seen by this module. A package can be seen by this module if it is declared in this module or any other module read by this module (JLS 7.4.3 for packages based on JLS 7.3 for compilation units). Package exports are not considered for visibility check (only when checking "uniquely visible" (JLS 7.4.3)).The returned package may be a
SplitPackageBinding
, if more than one package of the given name is visible.When asked via the unnamed module or an automatic module all other named modules are considered visible.
-
getVisiblePackage
Answer the package of the given qualified name and visible in this module, ornull
if no such package exists. Accessibility (based on package exports) is not checked.May answer a
SplitPackageBinding
. -
canAccess
Check if the given package is accessible by this module. True when the package is declared in this module or exported by some required module to this module. SeeisPackageExportedTo(PackageBinding, ModuleBinding)
- Parameters:
pkg
-- Returns:
- True, if the package is accessible by this module, false otherwise
-
computeUniqueKey
public char[] computeUniqueKey(boolean isLeaf) - Overrides:
computeUniqueKey
in classBinding
-
kind
public int kind() -
readableName
public char[] readableName()- Specified by:
readableName
in classBinding
-
toString
-
isUnnamed
public boolean isUnnamed() -
isAutomatic
public boolean isAutomatic() -
isOpen
public boolean isOpen() -
isDeprecated
public boolean isDeprecated() -
hasUnstableAutoName
public boolean hasUnstableAutoName() -
isTransitivelyRequired
-
getDefaultNullness
public int getDefaultNullness() -
retrieveAnnotationHolder
-
setAnnotations
- Overrides:
setAnnotations
in classBinding
-