APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ModuleOpenInfo

permits UnboundModuleOpenInfo
Known Direct Implementers
jdk.internal.classfile.impl.UnboundAttribute.UnboundModuleOpenInfo
Imports
java.lang.classfile.constantpool.ModuleEntry, .PackageEntry, java.lang.constant.ModuleDesc, .PackageDesc, java.lang.invoke.MethodHandles, java.lang.module.ModuleDescriptor, java.lang.reflect.AccessFlag, java.util.Collection, .List, .Set, jdk.internal.classfile.impl.TemporaryConstantPool, .UnboundAttribute, .Util

Models a single "opens" declaration in the ModuleAttribute.

API Note

Opening a package to another module allows that other module to gain the same full privilege access as members in this module. See MethodHandles#privateLookupIn for more details.

Since
24
Java Virtual Machine Specification
4.7.25 The Module Attribute
See Also
ModuleAttribute#exports(), ModuleDescriptor.Opens

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

whether the open declaration has the specified access flag set
has
(AccessFlag
the access flag
flag
)

Returns whether the open declaration has the specified access flag set.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageEntry
the package to open
opens
,
int
the open flags
opensFlags
,
List<ModuleEntry>
the modules to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageEntry
the package to open
opens
,
Collection<AccessFlag>
the open flags
opensFlags
,
List<ModuleEntry>
the modules to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageEntry
the package to open
opens
,
int
the open flags
opensFlags
,
ModuleEntry...
the modules to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageEntry
the package to open
opens
,
Collection<AccessFlag>
the open flags
opensFlags
,
ModuleEntry...
the modules to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageDesc
the package to open
opens
,
int
the open flags
opensFlags
,
List<ModuleDesc>
the modules to which this package is opened, if it is a qualified open, or empty
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageDesc
the package to open
opens
,
Collection<AccessFlag>
the open flags
opensFlags
,
List<ModuleDesc>
the modules to which this package is opened, if it is a qualified open, or empty
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageDesc
the package to open
opens
,
int
the open flags
opensFlags
,
ModuleDesc...
the packages to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public static ModuleOpenInfo

Returns:

a module open description
of
(PackageDesc
the package to open
opens
,
Collection<AccessFlag>
the open flags
opensFlags
,
ModuleDesc...
the packages to which this package is opened, or empty if this is an unqualified open
opensTo
)

Returns a module open description.

public PackageEntry

Returns:

the package being opened
openedPackage
()

Returns the package being opened.

public default Set<AccessFlag>

Returns:

the flags associated with this open declaration, as a set of flag enums
opensFlags
()

Returns the flags associated with this open declaration, as a set of flag enums.

public int

Returns:

the flags associated with this open declaration, as a bit mask
opensFlagsMask
()

Returns the flags associated with this open declaration, as a bit mask.

public List<ModuleEntry>

Returns:

the modules to which this package is opened, or empty if this is an unqualified open
opensTo
()

Returns the modules to which this package is opened, or empty if this is an unqualified open.

Method Detail

hasback to summary
public default boolean has(AccessFlag flag)

Returns whether the open declaration has the specified access flag set.

Parameters
flag:AccessFlag

the access flag

Returns:boolean

whether the open declaration has the specified access flag set

See Also
AccessFlag.Location#MODULE_OPENS
ofback to summary
public static ModuleOpenInfo of(PackageEntry opens, int opensFlags, List<ModuleEntry> opensTo)

Returns a module open description.

Parameters
opens:PackageEntry

the package to open

opensFlags:int

the open flags

opensTo:List<ModuleEntry>

the modules to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if opensFlags is not u2 or if the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageEntry opens, Collection<AccessFlag> opensFlags, List<ModuleEntry> opensTo)

Returns a module open description.

Parameters
opens:PackageEntry

the package to open

opensFlags:Collection<AccessFlag>

the open flags

opensTo:List<ModuleEntry>

the modules to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if any flag cannot be applied to the AccessFlag.Location#MODULE_OPENS location, or the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageEntry opens, int opensFlags, ModuleEntry... opensTo)

Returns a module open description.

Parameters
opens:PackageEntry

the package to open

opensFlags:int

the open flags

opensTo:ModuleEntry[]

the modules to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if opensFlags is not u2 or if the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageEntry opens, Collection<AccessFlag> opensFlags, ModuleEntry... opensTo)

Returns a module open description.

Parameters
opens:PackageEntry

the package to open

opensFlags:Collection<AccessFlag>

the open flags

opensTo:ModuleEntry[]

the modules to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if any flag cannot be applied to the AccessFlag.Location#MODULE_OPENS location, or the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageDesc opens, int opensFlags, List<ModuleDesc> opensTo)

Returns a module open description.

Parameters
opens:PackageDesc

the package to open

opensFlags:int

the open flags

opensTo:List<ModuleDesc>

the modules to which this package is opened, if it is a qualified open, or empty

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if opensFlags is not u2 or if the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageDesc opens, Collection<AccessFlag> opensFlags, List<ModuleDesc> opensTo)

Returns a module open description.

Parameters
opens:PackageDesc

the package to open

opensFlags:Collection<AccessFlag>

the open flags

opensTo:List<ModuleDesc>

the modules to which this package is opened, if it is a qualified open, or empty

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if any flag cannot be applied to the AccessFlag.Location#MODULE_OPENS location, or the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageDesc opens, int opensFlags, ModuleDesc... opensTo)

Returns a module open description.

Parameters
opens:PackageDesc

the package to open

opensFlags:int

the open flags

opensTo:ModuleDesc[]

the packages to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if opensFlags is not u2 or if the number of modules exceeds the limit of u2
ofback to summary
public static ModuleOpenInfo of(PackageDesc opens, Collection<AccessFlag> opensFlags, ModuleDesc... opensTo)

Returns a module open description.

Parameters
opens:PackageDesc

the package to open

opensFlags:Collection<AccessFlag>

the open flags

opensTo:ModuleDesc[]

the packages to which this package is opened, or empty if this is an unqualified open

Returns:ModuleOpenInfo

a module open description

Exceptions
IllegalArgumentException:
if any flag cannot be applied to the AccessFlag.Location#MODULE_OPENS location, or the number of modules exceeds the limit of u2
openedPackageback to summary
public PackageEntry openedPackage()

Returns the package being opened.

Returns:PackageEntry

the package being opened

See Also
ModuleDescriptor.Opens#source()
opensFlagsback to summary
public default Set<AccessFlag> opensFlags()

Returns the flags associated with this open declaration, as a set of flag enums.

Returns:Set<AccessFlag>

the flags associated with this open declaration, as a set of flag enums

Exceptions
IllegalArgumentException:
if the flags mask has any undefined bit set
See Also
ModuleDescriptor.Opens#accessFlags(), AccessFlag.Location#MODULE_OPENS
opensFlagsMaskback to summary
public int opensFlagsMask()

Returns the flags associated with this open declaration, as a bit mask. It is a u2 value.

Returns:int

the flags associated with this open declaration, as a bit mask

See Also
ModuleDescriptor.Opens#modifiers(), AccessFlag.Location#MODULE_OPENS
opensToback to summary
public List<ModuleEntry> opensTo()

Returns the modules to which this package is opened, or empty if this is an unqualified open.

Returns:List<ModuleEntry>

the modules to which this package is opened, or empty if this is an unqualified open

See Also
ModuleDescriptor.Opens#isQualified(), ModuleDescriptor.Opens#targets()