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

public final Class ImageFileCreator

extends Object
Class Inheritance
Static Imports
jdk.tools.jlink.internal.LinkableRuntimeImage.DIFF_PATTERN, .LinkableRuntimeImage.RESPATH_PATTERN

An image (native endian.)
{
  u4 magic;
  u2 major_version;
  u2 minor_version;
  u4 resource_count;
  u4 table_length;
  u4 location_attributes_size;
  u4 strings_size;
  u4 redirect[table_length];
  u4 offsets[table_length];
  u1 location_attributes[location_attributes_size];
  u1 strings[strings_size];
  u1 content[if !EOF];
}

Field Summary

Modifier and TypeField and Description
private static final String
private static final byte[]
private final Map<String, List<Archive.Entry>>
private final boolean
private final ImagePluginStack
private static final String

Constructor Summary

AccessConstructor and Description
private
ImageFileCreator(ImagePluginStack plugins, boolean generateRuntimeImage)

Method Summary

Modifier and TypeMethod and Description
private static ResourcePool
addDiffResourcesFiles(Set<String> modules, Map<String, List<ResourceDiff>> perModDiffs, ResourcePool resultResources, BasicImageWriter writer)

private static ResourcePool

Returns:

A resource pool with meta-data files added.
addModuleResourceEntries
(ResourcePool
The resource pool to add files to.
resultResources
,
Map<String, List<String>>
The per module mapping for which to create the meta-data files for.
nonClassResEntries
,
BasicImageWriter
The image writer.
writer
)

Support for creating runtimes that can be used for linking from the run-time image.

private static ResourcePool

Returns:

An amended resource pool which includes meta-data files.
addNonClassResourcesTrackFiles
(ResourcePool
The original resources which serve as the basis for generating the meta-data files.
resultResources
,
BasicImageWriter
The image writer.
writer
)

Support for creating runtimes that can be used for linking from the run-time image.

private static ResourcePool

Returns:

The resource pool with the difference file resources added to the resultContent
addResourceDiffFiles
(ResourcePool
The resource pool view of packaged modules
jmodContent
,
ResourcePool
The optimized result generated from the jmodContent input by applying the plugin stack.
resultContent
,
BasicImageWriter
The image writer.
writer
)

Support for creating a runtime suitable for linking from the run-time image.

public static ExecutableImage

Returns:

The executable image.
create
(Set<Archive>
The set of input archives
archives
,
ByteOrder
The desired byte order of the result
byteOrder
,
ImagePluginStack
The plugin stack to apply to the input
plugins
,
boolean
if a runtime suitable for linking from the run-time image should get created.
generateRuntimeImage
)

Create an executable image based on a set of input archives and a given plugin stack for a given byte order.

private static ResourcePoolManager
private static ResourcePoolManager
createPoolManager(Set<Archive> archives, Map<String, List<Archive.Entry>> entriesForModule, ByteOrder byteOrder, BasicImageWriter writer)

private static ResourcePoolManager

Returns:

An appendable ResourcePoolManager.
createPoolManager
(ResourcePool
The existing resources to initially add.
resultResources
,
BasicImageWriter
The basic image writer.
writer
)

Creates a ResourcePoolManager from existing resources so that more resources can be appended.

private static ResourcePool

Returns:

A pool of the actual result resources.
generateJImage
(ResourcePoolManager
The content that needs to get added to the resulting lib/modules (jimage) file.
allContent
,
BasicImageWriter
The writer for the jimage file.
writer
,
ImagePluginStack
The stack of all plugins to apply.
pluginSupport
,
DataOutputStream
The output stream to write the jimage to.
out
,
boolean
if a runtime suitable for linking from the run-time image should get created.
generateRuntimeImage
)

Create a jimage based on content of the given ResourcePoolManager, optionally creating a runtime that can be used for linking from the run-time image

private static ResourcePool
getResourcePool(ResourcePoolManager allContent, BasicImageWriter writer, ImagePluginStack pluginSupport, boolean generateRuntimeImage)

private static Platform
private static Map<String, List<ResourceDiff>>
private void
private static Map<String, List<String>>

Returns:

A mapping with the module names as keys and the list of files not part of the modules image (jimage) as values.
recordAndFilterEntries
(ResourcePool
The resources from which the mapping gets generated
resultResources
)

Support for creating runtimes that can be used for linking from the run-time image.

public static void
recreateJimage(Path jimageFile, Set<Archive> archives, ImagePluginStack pluginSupport, boolean generateRuntimeImage)

private void
writeImage(Set<Archive> archives, ByteOrder byteOrder)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DIFF_PATHback to summary
private static final String DIFF_PATH
EMPTY_RESOURCE_BYTESback to summary
private static final byte[] EMPTY_RESOURCE_BYTES
entriesForModuleback to summary
private final Map<String, List<Archive.Entry>> entriesForModule
generateRuntimeImageback to summary
private final boolean generateRuntimeImage
pluginsback to summary
private final ImagePluginStack plugins
RESPATHback to summary
private static final String RESPATH

Constructor Detail

ImageFileCreatorback to summary
private ImageFileCreator(ImagePluginStack plugins, boolean generateRuntimeImage)

Method Detail

addDiffResourcesFilesback to summary
private static ResourcePool addDiffResourcesFiles(Set<String> modules, Map<String, List<ResourceDiff>> perModDiffs, ResourcePool resultResources, BasicImageWriter writer)
addModuleResourceEntriesback to summary
private static ResourcePool addModuleResourceEntries(ResourcePool resultResources, Map<String, List<String>> nonClassResEntries, BasicImageWriter writer)

Support for creating runtimes that can be used for linking from the run-time image. Adds the given mapping of files as a meta-data file to the given resource pool.

Parameters
resultResources:ResourcePool

The resource pool to add files to.

nonClassResEntries:Map<String, List<String>>

The per module mapping for which to create the meta-data files for.

writer:BasicImageWriter

The image writer.

Returns:ResourcePool

A resource pool with meta-data files added.

addNonClassResourcesTrackFilesback to summary
private static ResourcePool addNonClassResourcesTrackFiles(ResourcePool resultResources, BasicImageWriter writer)

Support for creating runtimes that can be used for linking from the run-time image. Adds meta-data files for resources not in the lib/modules file of the JDK. That is, mapping files for which on-disk files belong to which module.

Parameters
resultResources:ResourcePool

The original resources which serve as the basis for generating the meta-data files.

writer:BasicImageWriter

The image writer.

Returns:ResourcePool

An amended resource pool which includes meta-data files.

addResourceDiffFilesback to summary
private static ResourcePool addResourceDiffFiles(ResourcePool jmodContent, ResourcePool resultContent, BasicImageWriter writer)

Support for creating a runtime suitable for linking from the run-time image. Generates differences between the packaged modules "view" in jmodContent to the optimized image in resultContent and adds the result to the returned resource pool.

Parameters
jmodContent:ResourcePool

The resource pool view of packaged modules

resultContent:ResourcePool

The optimized result generated from the jmodContent input by applying the plugin stack.

writer:BasicImageWriter

The image writer.

Returns:ResourcePool

The resource pool with the difference file resources added to the resultContent

Annotations
@SuppressWarnings:try
createback to summary
public static ExecutableImage create(Set<Archive> archives, ByteOrder byteOrder, ImagePluginStack plugins, boolean generateRuntimeImage) throws IOException

Create an executable image based on a set of input archives and a given plugin stack for a given byte order. It optionally generates a runtime that can be used for linking from the run-time image if generateRuntimeImage is set to true.

Parameters
archives:Set<Archive>

The set of input archives

byteOrder:ByteOrder

The desired byte order of the result

plugins:ImagePluginStack

The plugin stack to apply to the input

generateRuntimeImage:boolean

if a runtime suitable for linking from the run-time image should get created.

Returns:ExecutableImage

The executable image.

createBasicResourcePoolManagerback to summary
private static ResourcePoolManager createBasicResourcePoolManager(ByteOrder byteOrder, BasicImageWriter writer)
createPoolManagerback to summary
private static ResourcePoolManager createPoolManager(Set<Archive> archives, Map<String, List<Archive.Entry>> entriesForModule, ByteOrder byteOrder, BasicImageWriter writer) throws IOException
createPoolManagerback to summary
private static ResourcePoolManager createPoolManager(ResourcePool resultResources, BasicImageWriter writer)

Creates a ResourcePoolManager from existing resources so that more resources can be appended.

Parameters
resultResources:ResourcePool

The existing resources to initially add.

writer:BasicImageWriter

The basic image writer.

Returns:ResourcePoolManager

An appendable ResourcePoolManager.

generateJImageback to summary
private static ResourcePool generateJImage(ResourcePoolManager allContent, BasicImageWriter writer, ImagePluginStack pluginSupport, DataOutputStream out, boolean generateRuntimeImage) throws IOException

Create a jimage based on content of the given ResourcePoolManager, optionally creating a runtime that can be used for linking from the run-time image

Parameters
allContent:ResourcePoolManager

The content that needs to get added to the resulting lib/modules (jimage) file.

writer:BasicImageWriter

The writer for the jimage file.

pluginSupport:ImagePluginStack

The stack of all plugins to apply.

out:DataOutputStream

The output stream to write the jimage to.

generateRuntimeImage:boolean

if a runtime suitable for linking from the run-time image should get created.

Returns:ResourcePool

A pool of the actual result resources.

getResourcePoolback to summary
private static ResourcePool getResourcePool(ResourcePoolManager allContent, BasicImageWriter writer, ImagePluginStack pluginSupport, boolean generateRuntimeImage) throws IOException
getTargetPlatformback to summary
private static Platform getTargetPlatform(ResourcePool in)
preparePerModuleDiffsback to summary
private static Map<String, List<ResourceDiff>> preparePerModuleDiffs(List<ResourceDiff> resDiffs, Set<String> modules)
readAllEntriesback to summary
private void readAllEntries(Set<Archive> archives)
recordAndFilterEntriesback to summary
private static Map<String, List<String>> recordAndFilterEntries(ResourcePool resultResources)

Support for creating runtimes that can be used for linking from the run-time image. Generates a per module mapping of files not part of the modules image (jimage). This mapping is needed so as to know which files of the installed JDK belong to which module.

Parameters
resultResources:ResourcePool

The resources from which the mapping gets generated

Returns:Map<String, List<String>>

A mapping with the module names as keys and the list of files not part of the modules image (jimage) as values.

recreateJimageback to summary
public static void recreateJimage(Path jimageFile, Set<Archive> archives, ImagePluginStack pluginSupport, boolean generateRuntimeImage) throws IOException
writeImageback to summary
private void writeImage(Set<Archive> archives, ByteOrder byteOrder) throws IOException