APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.tools.jlink.internal

public Class JRTArchive

extends Object
implements Archive
Class Inheritance
All Implemented Interfaces
jdk.tools.jlink.internal.Archive, java.io.Closeable, java.lang.AutoCloseable
Static Imports
jdk.tools.jlink.internal.LinkableRuntimeImage.RESPATH_PATTERN

An archive implementation based on the JDK's run-time image. That is, classes and resources from the modules image (lib/modules, or jimage) and other associated files from the filesystem of the JDK installation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record
pack-priv static interface
pack-priv static record
public static record

Field Summary

Modifier and TypeField and Description
private static final Path
private final boolean
private final List<JRTArchive.JRTFile>
private final ResourceEntries
private final String
private final List<String>
private final Path
private final Map<String, ResourceDiff>
private final TaskHelper
private final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv
JRTArchive(String
The module name this archive refers to
module
,
Path
The JRT filesystem path.
path
,
boolean
Whether or not modified files of the JDK install aborts the link.
errorOnModifiedFile
,
List<ResourceDiff>
The lib/modules (a.k.a jimage) diff for this module, possibly an empty list if there are no differences.
perModDiff
,
TaskHelper
The task helper instance.
taskHelper
,
Set<String>
The set of files that are allowed for upgrades.
upgradeableFiles
)

JRTArchive constructor

Method Summary

Modifier and TypeMethod and Description
private void
public void
close()

Implements jdk.tools.jlink.internal.Archive.close.

Closes this stream and releases any system resources associated with it.

private void
public Stream<Archive.Entry>
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public Path
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private boolean
private boolean

Returns:

true if the file is upgradeable. false otherwise.
isUpgradeableFile
(String
The resource path of the file to check for upgradeability.
resPath
)

Certain files in a module are considered upgradeable.

public String
public void
private static List<String>
pack-priv static boolean
shaSumMismatch(Path res, String expectedSha, boolean isSymlink)

private static Archive.Entry.EntryType
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

BASEback to summary
private static final Path BASE
errorOnModifiedFileback to summary
private final boolean errorOnModifiedFile
filesback to summary
private final List<JRTArchive.JRTFile> files
imageResourcesback to summary
private final ResourceEntries imageResources
moduleback to summary
private final String module
otherResback to summary
private final List<String> otherRes
pathback to summary
private final Path path
resDiffback to summary
private final Map<String, ResourceDiff> resDiff
taskHelperback to summary
private final TaskHelper taskHelper
upgradeableFilesback to summary
private final Set<String> upgradeableFiles

Constructor Detail

JRTArchiveback to summary
pack-priv JRTArchive(String module, Path path, boolean errorOnModifiedFile, List<ResourceDiff> perModDiff, TaskHelper taskHelper, Set<String> upgradeableFiles)

JRTArchive constructor

Parameters
module:String

The module name this archive refers to

path:Path

The JRT filesystem path.

errorOnModifiedFile:boolean

Whether or not modified files of the JDK install aborts the link.

perModDiff:List<ResourceDiff>

The lib/modules (a.k.a jimage) diff for this module, possibly an empty list if there are no differences.

taskHelper:TaskHelper

The task helper instance.

upgradeableFiles:Set<String>

The set of files that are allowed for upgrades.

Method Detail

addNonClassResourcesback to summary
private void addNonClassResources()
closeback to summary
public void close() throws IOException

Implements jdk.tools.jlink.internal.Archive.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
collectFilesback to summary
private void collectFiles() throws IOException
entriesback to summary
public Stream<Archive.Entry> entries()

Implements jdk.tools.jlink.internal.Archive.entries.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

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.

Annotations
@Override
getPathback to summary
public Path getPath()

Implements jdk.tools.jlink.internal.Archive.getPath.

Annotations
@Override
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.
Annotations
@Override
isNormalOrModifiedDiffback to summary
private boolean isNormalOrModifiedDiff(String name)
isUpgradeableFileback to summary
private boolean isUpgradeableFile(String resPath)

Certain files in a module are considered upgradeable. That is, their hash sums aren't checked.

Parameters
resPath:String

The resource path of the file to check for upgradeability.

Returns:boolean

true if the file is upgradeable. false otherwise.

moduleNameback to summary
public String moduleName()

Implements jdk.tools.jlink.internal.Archive.moduleName.

Annotations
@Override
openback to summary
public void open() throws IOException

Implements jdk.tools.jlink.internal.Archive.open.

Annotations
@Override
readModuleResourceFileback to summary
private static List<String> readModuleResourceFile(String modName)
shaSumMismatchback to summary
pack-priv static boolean shaSumMismatch(Path res, String expectedSha, boolean isSymlink)
toEntryTypeback to summary
private static Archive.Entry.EntryType toEntryType(ResourcePoolEntry.Type input)
jdk.tools.jlink.internal back to summary

pack-priv final Record JRTArchive.JrtClassOrResource

extends Record
implements JRTFile
Class Inheritance
All Implemented Interfaces
jdk.tools.jlink.internal.JRTArchive.JRTFile
Record Components
archive:JRTArchive 
resPath:String 
diff:ResourceDiff 

Field Summary

Modifier and TypeField and Description
private final JRTArchive
archive

Record Component accessed by archive().

private final ResourceDiff
diff

Record Component accessed by diff().

private final String
resPath

Record Component accessed by resPath().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public JRTArchive
archive()

Record Component getter of archive.

public ResourceDiff
diff()

Record Component getter of diff.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
resPath()

Record Component getter of resPath.

public Archive.Entry
public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

archiveback to summary
private final JRTArchive archive

Record Component accessed by archive().

diffback to summary
private final ResourceDiff diff

Record Component accessed by diff().

resPathback to summary
private final String resPath

Record Component accessed by resPath().

Constructor Detail

JrtClassOrResourceback to summary
pack-priv JrtClassOrResource(JRTArchive archive, String resPath, ResourceDiff diff)

Method Detail

archiveback to summary
public JRTArchive archive()

Record Component getter of archive.

diffback to summary
public ResourceDiff diff()

Record Component getter of diff.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

resPathback to summary
public String resPath()

Record Component getter of resPath.

toEntryback to summary
public Archive.Entry toEntry()

Implements jdk.tools.jlink.internal.JRTArchive.JRTFile.toEntry.

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.tools.jlink.internal back to summary

pack-priv Interface JRTArchive.JRTFile

Known Direct Implementers
jdk.tools.jlink.internal.JRTArchive.JrtClassOrResource, jdk.tools.jlink.internal.JRTArchive.JrtOtherFile

Method Summary

Modifier and TypeMethod and Description
public Archive.Entry

Method Detail

toEntryback to summary
public Archive.Entry toEntry()
jdk.tools.jlink.internal back to summary

pack-priv final Record JRTArchive.JrtOtherFile

extends Record
implements JRTFile
Class Inheritance
All Implemented Interfaces
jdk.tools.jlink.internal.JRTArchive.JRTFile
Record Components
archive:JRTArchive 
resPath:String 
resType:Archive.Entry.EntryType 
sha:String 
symlink:boolean 

Field Summary

Modifier and TypeField and Description
private final JRTArchive
archive

Record Component accessed by archive().

private final String
resPath

Record Component accessed by resPath().

private final Archive.Entry.EntryType
resType

Record Component accessed by resType().

private final String
sha

Record Component accessed by sha().

private final boolean
symlink

Record Component accessed by symlink().

Constructor Summary

AccessConstructor and Description
pack-priv
JrtOtherFile(JRTArchive archive, String resPath, Archive.Entry.EntryType resType, String sha, boolean symlink)

Method Summary

Modifier and TypeMethod and Description
public JRTArchive
archive()

Record Component getter of archive.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
resPath()

Record Component getter of resPath.

public Archive.Entry.EntryType
resType()

Record Component getter of resType.

public String
sha()

Record Component getter of sha.

pack-priv Path
public Archive.Entry
public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

archiveback to summary
private final JRTArchive archive

Record Component accessed by archive().

resPathback to summary
private final String resPath

Record Component accessed by resPath().

resTypeback to summary
private final Archive.Entry.EntryType resType

Record Component accessed by resType().

shaback to summary
private final String sha

Record Component accessed by sha().

Constructor Detail

JrtOtherFileback to summary
pack-priv JrtOtherFile(JRTArchive archive, String resPath, Archive.Entry.EntryType resType, String sha, boolean symlink)

Method Detail

archiveback to summary
public JRTArchive archive()

Record Component getter of archive.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

resPathback to summary
public String resPath()

Record Component getter of resPath.

resTypeback to summary
public Archive.Entry.EntryType resType()

Record Component getter of resType.

shaback to summary
public String sha()

Record Component getter of sha.

targetPathback to summary
pack-priv Path targetPath()
toEntryback to summary
public Archive.Entry toEntry()

Implements jdk.tools.jlink.internal.JRTArchive.JRTFile.toEntry.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.tools.jlink.internal back to summary

public final Record JRTArchive.ResourceFileEntry

extends Record
Class Inheritance
Record Components
resType:ResourcePoolEntry.Type 
symlink:boolean 
hashOrTarget:String 
resPath:String 

Field Summary

Modifier and TypeField and Description
private static final String
private final String
hashOrTarget

Record Component accessed by hashOrTarget().

private static final String
private final String
resPath

Record Component accessed by resPath().

private final ResourcePoolEntry.Type
resType

Record Component accessed by resType().

private final boolean
symlink

Record Component accessed by symlink().

private static final String
private static final Map<Integer, ResourcePoolEntry.Type>

Constructor Summary

AccessConstructor and Description
public
ResourceFileEntry(ResourcePoolEntry.Type resType, boolean symlink, String hashOrTarget, String resPath)

Method Summary

Modifier and TypeMethod and Description
private static String
pack-priv static JRTArchive.ResourceFileEntry
private static String
public String
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
hashOrTarget()

Record Component getter of hashOrTarget.

private static boolean
isWindows(Platform platform)

private static String
public String
resPath()

Record Component getter of resPath.

public ResourcePoolEntry.Type
resType()

Record Component getter of resType.

public static JRTArchive.ResourceFileEntry
public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

BIN_DIRNAMEback to summary
private static final String BIN_DIRNAME
hashOrTargetback to summary
private final String hashOrTarget

Record Component accessed by hashOrTarget().

LIB_DIRNAMEback to summary
private static final String LIB_DIRNAME
resPathback to summary
private final String resPath

Record Component accessed by resPath().

resTypeback to summary
private final ResourcePoolEntry.Type resType

Record Component accessed by resType().

TYPE_FILE_FORMATback to summary
private static final String TYPE_FILE_FORMAT
typeMapback to summary
private static final Map<Integer, ResourcePoolEntry.Type> typeMap

Constructor Detail

ResourceFileEntryback to summary
public ResourceFileEntry(ResourcePoolEntry.Type resType, boolean symlink, String hashOrTarget, String resPath)

Method Detail

computeSha512back to summary
private static String computeSha512(ResourcePoolEntry entry)
decodeFromStringback to summary
pack-priv static JRTArchive.ResourceFileEntry decodeFromString(String line)
dropModuleFromPathback to summary
private static String dropModuleFromPath(ResourcePoolEntry entry, Platform platform)
encodeToStringback to summary
public String encodeToString()
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

hashOrTargetback to summary
public String hashOrTarget()

Record Component getter of hashOrTarget.

isWindowsback to summary
private static boolean isWindows(Platform platform)
nativeDirback to summary
private static String nativeDir(ResourcePoolEntry entry, String resPath)
resPathback to summary
public String resPath()

Record Component getter of resPath.

resTypeback to summary
public ResourcePoolEntry.Type resType()

Record Component getter of resType.

toResourceFileEntryback to summary
public static JRTArchive.ResourceFileEntry toResourceFileEntry(ResourcePoolEntry entry, Platform platform)
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.