Jigsaw module-file format DRAFT

Mark Reinhold
2010/1/20 09:33 -0800 [4]

Copyright 2010 Sun Microsystems, Inc. · All Rights Reserved

Goals

Layout

A module file has the following sections, in the order listed.

The first two sections are required:

The remaining sections are optional:

Module file header

ModuleFileHeader {
  u4 magic;                 // FileConstants.MAGIC
  u2 type;                  // FileConstants.Type.MODULE_FILE
  u2 major;                 // FileConstants.ModuleFile.MAJOR_VERSION
  u2 minor;                 // FileConstants.ModuleFile.MINOR_VERSION
  u8 csize;                 // Size of entire file, compressed
  u8 usize;                 // Space required for uncompressed contents
                            //   (upper bound; need not be exact)
  u2 sections;              // Number of following sections
  u2 hashType;              // One of FileConstants.ModuleFile.HashType
                            //   (applies to all hashes in this file)
  u2 hashLength;            // Length of following hash
  b* hash;                  // Hash of entire file (except this hash)
}

All integers are in network byte order.

Sections

Each section (except the initial file header) has a header, which is then followed by the section’s content:

SectionHeader {
  u2 type;                  // One of FileConstants.ModuleFile.SectionType
  u2 compressor;            // One of FileConstants.ModuleFile.Compressor
  u4 csize;                 // Size of section content, compressed
  u2 subsections;           // Number of following subsections
  u2 hashLength;            // Length of following hash
  b* hash;                  // Hash of section content
}

Compression is only relevant to section content; it never applies to the headers defined here.

The subsection count is zero for sections that contain only one entity, i.e., module-info, classes, and hash sections. The subsection count is non-zero for sections that contain multiple entities, i.e., resources, native code, and config sections.

Subsections

If a section has subsections then each subsection has its own header. At the moment only file subsections are defined:

SubSectionFileHeader {
  u2 type;                  // FileConstants.ModuleFile.SubSectionType.FILE
  u4 csize;                 // Size of file, compressed
  u2 pathLength;            // Length of path name, in bytes
  b* path;                  // Path name, in Java-modified UTF-8
}

The ‘/’ character separates nested directories in path names. The module installer must transpose this to a different character, if needed, to suit the host system.

Path names are relative to an unspecified installation directory. Absolute path names, i.e., those starting with a separator, are not permitted. The path names of native-code files must not include more than one element.

There is no mode field on files within a section. The module installer must set the local mode as appropriate; it must, e.g., make native-code files executable as required by the host system.

Layout grammar

ModuleFileHeader
SectionHeader(MODULE_INFO) [module-info data]
(SectionHeader(CLASSES) [class data])?
(SectionHeader(RESOURCES) (SubSectionFileHeader [file data])+)?
(SectionHeader(NATIVE_LIBS) (SubSectionFileHeader [file data])+)?
(SectionHeader(NATIVE_CMDS) (SubSectionFileHeader [file data])+)?
(SectionHeader(CONFIG) (SubSectionFileHeader+ [file data])+)?

Open issues

Changes

Version 4:

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.