"/packages/xxx"
image locations (package subdirectories).
Package subdirectories store their data differently to all other jimage
entries. Instead of storing a sequence of offsets to their child entries,
they store a flattened representation of the child's data in an interleaved
buffer. These entries also use flags which are similar to, but distinct from,
the ImageLocation flags.
This class encapsulates that complexity to help avoid confusion.
Implementation Note
This class needs to maintain JDK 8 source compatibility. It is used internally in the JDK to implement jimage/jrtfs access, but also compiled and delivered as part of the jrtfs.jar to support access to the jimage file provided by the shipped JDK by tools running on JDK 8.
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private static final int | FLAGS_PKG_HAS_NORMAL_VERSION
If set, this package exists in non-preview mode. |
| private static final int | FLAGS_PKG_HAS_PREVIEW_VERSION
If set, this package exists in preview mode. |
| private static final int | FLAGS_PKG_HAS_RESOURCES
If set, the associated module has resources (in normal or preview mode). |
| private final String | |
| private static final Comparator | PREVIEW_FIRST
Links are ordered with preview versions first, which permits early
exit when processing preview entries (it's reversed because the default
order for a boolean is |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compareTo(ModuleLink rhs)
Implements java. Compares this object with the specified object for order. |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public static ModuleLink | forEmptyPackage(String
the name of the module in which this package exits. moduleName, boolean whether the associated package is defined for preview mode. isPreview)Returns a link for empty packages in a given module. |
| public static ModuleLink | forPackage(String
the name of the module in which this package exits. moduleName, boolean whether the associated package is defined for preview mode. isPreview)Returns a link for non-empty packages (those with resources) in a given module. |
| public int | |
| public boolean | hasPreviewVersion()
Returns whether the package associated with this module link has a preview version (empty or otherwise) in this link's module. |
| public boolean | hasResources()
Returns whether the package associated with this link contains resources in its module. |
| public boolean | |
| public ModuleLink | |
| public String | |
| private static int | previewFlag(boolean isPreview)
Returns the appropriate FLAGS_PKG_HAS_XXX_VERSION constant according to whether the associated package is defined for preview mode. |
| public static Iterator | Returns: an iterator of module name offsets.the content buffer of an buffer, boolean ImageLocation with type
PACKAGES_DIR.whether to include name offsets for modules present
in normal (non-preview) mode. includeNormal, boolean whether to include name offsets for modules present
in preview mode. includePreview)Reads the content buffer of a package subdirectory to return a sequence of module name offsets in the jimage. |
| public String | |
| public static void |
| flags | back to summary |
|---|---|
| private final int flags | |
| FLAGS_PKG_HAS_NORMAL_VERSION | back to summary |
|---|---|
| private static final int FLAGS_PKG_HAS_NORMAL_VERSION If set, this package exists in non-preview mode. | |
| FLAGS_PKG_HAS_PREVIEW_VERSION | back to summary |
|---|---|
| private static final int FLAGS_PKG_HAS_PREVIEW_VERSION If set, this package exists in preview mode. | |
| FLAGS_PKG_HAS_RESOURCES | back to summary |
|---|---|
| private static final int FLAGS_PKG_HAS_RESOURCES If set, the associated module has resources (in normal or preview mode). | |
| name | back to summary |
|---|---|
| private final String name | |
| PREVIEW_FIRST | back to summary |
|---|---|
| private static final Comparator<ModuleLink> PREVIEW_FIRST Links are ordered with preview versions first, which permits early
exit when processing preview entries (it's reversed because the default
order for a boolean is | |
| ModuleLink | back to summary |
|---|---|
| private ModuleLink(String moduleName, int flags) | |
| compareTo | back to summary |
|---|---|
| public int compareTo(ModuleLink rhs) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
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.
| |
| forEmptyPackage | back to summary |
|---|---|
| public static ModuleLink forEmptyPackage(String moduleName, boolean isPreview) Returns a link for empty packages in a given module. The same link can be used for multiple packages in the same module.
| |
| forPackage | back to summary |
|---|---|
| public static ModuleLink forPackage(String moduleName, boolean isPreview) Returns a link for non-empty packages (those with resources) in a given module. The same link can be used for multiple packages in the same module.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| hasPreviewVersion | back to summary |
|---|---|
| public boolean hasPreviewVersion() Returns whether the package associated with this module link has a preview version (empty or otherwise) in this link's module. | |
| hasResources | back to summary |
|---|---|
| public boolean hasResources() Returns whether the package associated with this link contains resources in its module. An invariant of the module system is that while a package may exist under many modules, it only has resources in one. | |
| isPreviewOnly | back to summary |
|---|---|
| public boolean isPreviewOnly() Returns whether this module link exists only in preview mode. | |
| merge | back to summary |
|---|---|
| public ModuleLink merge(ModuleLink other) Merges two links for the same module (combining their flags). | |
| name | back to summary |
|---|---|
| public String name() Returns the module name of this link. | |
| previewFlag | back to summary |
|---|---|
| private static int previewFlag(boolean isPreview) Returns the appropriate FLAGS_PKG_HAS_XXX_VERSION constant according to whether the associated package is defined for preview mode. | |
| readNameOffsets | back to summary |
|---|---|
| public static Iterator Reads the content buffer of a package subdirectory to return a sequence of module name offsets in the jimage. Package subdirectories store their entries using pairs of integers in an interleaved buffer:
...
[ entry-N flags ]
[ entry-N name offset ]
[ entry-(N+1) flags ]
[ entry-(N+1) name offset ]
...
Entry flags control whether an entry name should be included by the returned iterator, depending on the given include-flags.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| write | back to summary |
|---|---|
| public static void write(List<ModuleLink> links, IntBuffer buffer, Function<String, Integer> nameEncoder) Writes a list of module links to a given buffer. The given entry list is checked carefully to ensure the written buffer will be valid. Entries are written in order, taking two integer slots per entry as
| |