RFR: Module constraints on targets

Chris Hegarty chris.hegarty at oracle.com
Thu Oct 11 09:37:56 PDT 2012


This is a proposal to fulfill the 'module constraints on targets' 
requirement [1]. Essentially, support setting OS and Arch values on 
module-files and libraries. It meets the common use-cases, like 
installing platform specific modules into the wrong module library, when 
cross compiling, etc..

1) Extend the Jigsaw module-file format [2] (jmod) to accommodate 
Operating System and Architecture values in the module 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)
     u2 osLength;       // Length of following Operating System, in 
bytes <<< ADDED
     b* os;             // Operating System, in Java-modified UTF-8 <<< 
ADDED
     u2 archLength;     // Length of following Architecture, in bytes 
<<< ADDED
     b* arch;           // Architecture, in Java-modified UTF-8  <<< ADDED
}

The os and arch values are Java-modified UTF-8 strings, representing the 
Operating System and Architecture where the module-file/library is 
intended to be deployed.

A value of 0 is a valid value for both osLength and archLength. This 
effectively means that these values are unset, and the 
module-file/library is agnostic of Operating System and Architecture. It 
should be considered a candidate for any module library.

2) Update CLIs

Both jmod and jpkg need to be updated to support passing of os and arch 
values during creation.

Define two new arguments -os, -arch for both jmod and jpkg. These 
arguments are optional. If specified, can only be specified once. For 
example:

./bin/jmod create -L m.lib -os linux -arch x64

./bin/jmod id -L m.lib
path /export/chris/repos/jigsaw/constraints/test/m.lib
version 0.1
os: linux
arch: x64

./bin/jmod install -L m.lib jigsaw-pkgs/jmod/jdk.logging at 8-ea.jmod
java.io.IOException: Module architecture [linux-i586] does not match 
library [linux-x64]
org.openjdk.jigsaw.cli.Command$Exception: java.io.IOException: Module 
architecture [linux-i586] does not match library [linux-x64]
	at org.openjdk.jigsaw.cli.Librarian$Install.go(Librarian.java:230)
	at org.openjdk.jigsaw.cli.Librarian$Install.go(Librarian.java:189)
	at org.openjdk.jigsaw.cli.Command.run(Command.java:100)
   .....


3) Update the build to produce images and module-files that are
$PLATFORM and $ARCH specific ( matching the bundles ).

Webrev:
   http://cr.openjdk.java.net/~chegar/jigsaw/constraints.00/webrev/


-Chris.

[1] 
http://openjdk.java.net/projects/jigsaw/doc/draft-java-module-system-requirements-12#module-constraints-on-targets
[2] http://cr.openjdk.java.net/~mr/jigsaw/notes/module-file-format/



More information about the jigsaw-dev mailing list