APIdia Launch Partner
Top Inners Fields Constructors Methods
jdk.internal.jimage

public Class ImageLocation

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.util.List, .Objects, java.util.function.Predicate

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
public static final int
ATTRIBUTE_BASE

String table offset of resource path base.

public static final int
ATTRIBUTE_COMPRESSED

In-image byte size of the compressed resource.

public static final int
ATTRIBUTE_COUNT

Number of attribute kinds.

public static final int
ATTRIBUTE_END

End of attribute stream marker.

public static final int
ATTRIBUTE_EXTENSION

String table offset of resource path extension.

public static final int
ATTRIBUTE_MODULE

String table offset of module name.

public static final int
ATTRIBUTE_OFFSET

Container byte offset of resource.

public static final int
ATTRIBUTE_PARENT

String table offset of resource path parent.

public static final int
ATTRIBUTE_PREVIEW_FLAGS

Flags relating to preview mode resources.

public static final int
ATTRIBUTE_UNCOMPRESSED

In-memory byte size of the uncompressed resource.

protected final long[]
private static final int
FLAGS_HAS_PREVIEW_VERSION

Indicates that a non-preview location is associated with preview resources.

private static final int
FLAGS_IS_PREVIEW_ONLY

Indicates that a location only exists due to preview resources.

private static final int
FLAGS_IS_PREVIEW_VERSION

Set on all locations in the /modules/xxx/META-INF/preview/...

pack-priv static final String
pack-priv static final String
pack-priv static final String
protected final ImageStrings

Constructor Summary

AccessConstructor and Description
public
ImageLocation(long[] attributes, ImageStrings strings)

Method Summary

Modifier and TypeMethod and Description
public static byte[]
compress(long[] attributes)

pack-priv static long[]
decompress(ByteBuffer bytes, int offset)

pack-priv long
getAttribute(int kind)

pack-priv String
public String
public int
public long
public long
public String
public int
public int
public String
public String
getFullName(boolean modulesPrefix)

public String
public int
public static int

Returns:

package flags for "/packages/xxx" directory entries.
getPackageFlags
(List<ModuleLink> moduleLinks)

Helper function to calculate package flags for "/packages/xxx" directory entries.

public String
public int
public static int

Returns:

flags for the ATTRIBUTE_PREVIEW_FLAGS attribute.
getPreviewFlags
(String
the jimage name of the resource or directory.
name
,
Predicate<String>
a predicate for jimage names returning whether an entry is present.
hasEntry
)

Helper function to calculate preview flags (ATTRIBUTE_PREVIEW_FLAGS).

pack-priv ImageStrings
public ImageLocation.LocationType
public long
public static boolean
hasPreviewVersion(int flags)

Tests a non-preview image location's flags to see if it has preview content associated with it.

public static boolean
isPreviewOnly(int flags)

Tests an image location's flags to see if it only exists in preview mode.

private boolean
pack-priv static ImageLocation
readFrom(BasicImageReader reader, int offset)

private static long
readValue(int length, ByteBuffer buffer, int offset, int limit)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
verify(String name)

pack-priv static boolean
verify(String name, long[] attributes, ImageStrings strings)

A simpler verification would be name.equals(getFullName()), but by not creating the full name and enabling early returns we allocate fewer objects.

pack-priv static boolean
verify(String module, String name, ByteBuffer locations, int locationOffset, ImageStrings strings)

pack-priv static boolean
verify(String module, String name, long[] attributes, ImageStrings strings)

private static boolean
verifyName(String module, String name, int index, int length, int moduleOffset, int parentOffset, int baseOffset, int extOffset, ImageStrings strings)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ATTRIBUTE_BASEback to summary
public static final int ATTRIBUTE_BASE

String table offset of resource path base.

ATTRIBUTE_COMPRESSEDback to summary
public static final int ATTRIBUTE_COMPRESSED

In-image byte size of the compressed resource.

ATTRIBUTE_COUNTback to summary
public static final int ATTRIBUTE_COUNT

Number of attribute kinds.

ATTRIBUTE_ENDback to summary
public static final int ATTRIBUTE_END

End of attribute stream marker.

ATTRIBUTE_EXTENSIONback to summary
public static final int ATTRIBUTE_EXTENSION

String table offset of resource path extension.

ATTRIBUTE_MODULEback to summary
public static final int ATTRIBUTE_MODULE

String table offset of module name.

ATTRIBUTE_OFFSETback to summary
public static final int ATTRIBUTE_OFFSET

Container byte offset of resource.

ATTRIBUTE_PARENTback to summary
public static final int ATTRIBUTE_PARENT

String table offset of resource path parent.

ATTRIBUTE_PREVIEW_FLAGSback to summary
public static final int ATTRIBUTE_PREVIEW_FLAGS

Flags relating to preview mode resources.

ATTRIBUTE_UNCOMPRESSEDback to summary
public static final int ATTRIBUTE_UNCOMPRESSED

In-memory byte size of the uncompressed resource.

attributesback to summary
protected final long[] attributes
FLAGS_HAS_PREVIEW_VERSIONback to summary
private static final int FLAGS_HAS_PREVIEW_VERSION

Indicates that a non-preview location is associated with preview resources.

This can apply to both resources and directories in the /modules/xxx/... namespace, as well as /packages/xxx directories.

For /packages/xxx directories, it indicates that the package has preview resources in one of the modules in which it exists.

FLAGS_IS_PREVIEW_ONLYback to summary
private static final int FLAGS_IS_PREVIEW_ONLY

Indicates that a location only exists due to preview resources.

This can apply to both resources and directories in the /modules/xxx/... namespace, as well as /packages/xxx directories.

For /packages/xxx directories it indicates that, for every module in which the package exists, it is preview only.

This flag is mutually exclusive with FLAGS_HAS_PREVIEW_VERSION and need not imply that FLAGS_IS_PREVIEW_VERSION is set (i.e. for /packages/xxx directories).

FLAGS_IS_PREVIEW_VERSIONback to summary
private static final int FLAGS_IS_PREVIEW_VERSION

Set on all locations in the /modules/xxx/META-INF/preview/... namespace.

This flag is mutually exclusive with FLAGS_HAS_PREVIEW_VERSION.

MODULES_PREFIXback to summary
pack-priv static final String MODULES_PREFIX
PACKAGES_PREFIXback to summary
pack-priv static final String PACKAGES_PREFIX
PREVIEW_INFIXback to summary
pack-priv static final String PREVIEW_INFIX
stringsback to summary
protected final ImageStrings strings

Constructor Detail

ImageLocationback to summary
public ImageLocation(long[] attributes, ImageStrings strings)

Method Detail

compressback to summary
public static byte[] compress(long[] attributes)
decompressback to summary
pack-priv static long[] decompress(ByteBuffer bytes, int offset)
getAttributeback to summary
pack-priv long getAttribute(int kind)
getAttributeStringback to summary
pack-priv String getAttributeString(int kind)
getBaseback to summary
public String getBase()
getBaseOffsetback to summary
public int getBaseOffset()
getCompressedSizeback to summary
public long getCompressedSize()
getContentOffsetback to summary
public long getContentOffset()
getExtensionback to summary
public String getExtension()
getExtensionOffsetback to summary
public int getExtensionOffset()
getFlagsback to summary
public int getFlags()
getFullNameback to summary
public String getFullName()
getFullNameback to summary
public String getFullName(boolean modulesPrefix)
getModuleback to summary
public String getModule()
getModuleOffsetback to summary
public int getModuleOffset()
getPackageFlagsback to summary
public static int getPackageFlags(List<ModuleLink> moduleLinks)

Helper function to calculate package flags for "/packages/xxx" directory entries.

Based on the module links, the flags are:

  • FLAGS_HAS_PREVIEW_VERSION if any referenced package has a preview version.
  • FLAGS_IS_PREVIEW_ONLY if all referenced packages are preview only.
Returns:int

package flags for "/packages/xxx" directory entries.

getParentback to summary
public String getParent()
getParentOffsetback to summary
public int getParentOffset()
getPreviewFlagsback to summary
public static int getPreviewFlags(String name, Predicate<String> hasEntry)

Helper function to calculate preview flags (ATTRIBUTE_PREVIEW_FLAGS).

Since preview flags are calculated separately for resource nodes and directory nodes (in two quite different places) it's useful to have a common helper.

Based on the entry name, the flags are:

  • "[/modules]/<module>/<path>" normal resource or directory:
    Zero, or FLAGS_HAS_PREVIEW_VERSION if a preview entry exists.
  • "[/modules]/<module>/META-INF/preview/<path>" preview resource or directory:
    FLAGS_IS_PREVIEW_VERSION, and additionally FLAGS_IS_PREVIEW_ONLY if no normal version of the resource or directory exists.
  • In all other cases, returned flags are zero (note that "/packages/xxx" entries may have flags, but these are calculated elsewhere).
Parameters
name:String

the jimage name of the resource or directory.

hasEntry:Predicate<String>

a predicate for jimage names returning whether an entry is present.

Returns:int

flags for the ATTRIBUTE_PREVIEW_FLAGS attribute.

getStringsback to summary
pack-priv ImageStrings getStrings()
getTypeback to summary
public ImageLocation.LocationType getType()
getUncompressedSizeback to summary
public long getUncompressedSize()
hasPreviewVersionback to summary
public static boolean hasPreviewVersion(int flags)

Tests a non-preview image location's flags to see if it has preview content associated with it.

isPreviewOnlyback to summary
public static boolean isPreviewOnly(int flags)

Tests an image location's flags to see if it only exists in preview mode.

isRootDirback to summary
private boolean isRootDir()
readFromback to summary
pack-priv static ImageLocation readFrom(BasicImageReader reader, int offset)
readValueback to summary
private static long readValue(int length, ByteBuffer buffer, int offset, int limit)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
verifyback to summary
public boolean verify(String name)
verifyback to summary
pack-priv static boolean verify(String name, long[] attributes, ImageStrings strings)

A simpler verification would be name.equals(getFullName()), but by not creating the full name and enabling early returns we allocate fewer objects.

verifyback to summary
pack-priv static boolean verify(String module, String name, ByteBuffer locations, int locationOffset, ImageStrings strings)
verifyback to summary
pack-priv static boolean verify(String module, String name, long[] attributes, ImageStrings strings)
verifyNameback to summary
private static boolean verifyName(String module, String name, int index, int length, int moduleOffset, int parentOffset, int baseOffset, int extOffset, ImageStrings strings)
jdk.internal.jimage back to summary

public final Enum ImageLocation.LocationType

extends Enum<ImageLocation.LocationType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ImageLocation.LocationType
public static final ImageLocation.LocationType
public static final ImageLocation.LocationType
public static final ImageLocation.LocationType
public static final ImageLocation.LocationType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ImageLocation.LocationType
public static ImageLocation.LocationType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

MODULES_DIRback to summary
public static final ImageLocation.LocationType MODULES_DIR
MODULES_ROOTback to summary
public static final ImageLocation.LocationType MODULES_ROOT
PACKAGES_DIRback to summary
public static final ImageLocation.LocationType PACKAGES_DIR
PACKAGES_ROOTback to summary
public static final ImageLocation.LocationType PACKAGES_ROOT
RESOURCEback to summary
public static final ImageLocation.LocationType RESOURCE

Constructor Detail

LocationTypeback to summary
private LocationType()

Method Detail

valueOfback to summary
public static ImageLocation.LocationType valueOf(String name)
valuesback to summary
public static ImageLocation.LocationType[] values()