saker.nest Documentation TaskDoc JavaDoc Packages
public final class BundleInformation implements BundleIdentifierHolder, Externalizable
Holds information about Nest bundles.

The information in this class consists of the following:

  • Bundle identifier
  • Classpath information
  • Dependencies
  • Tasks
  • Other meta-data
These information is present in the manifest file of the bundle, and under the META-INF/nest/ directory.

When an instance of this class is constructed, all of the information are validated to have a valid format. A Nest bundle that is any way malformatted is considered invalid.

During construction, other structural integrity changes are also validated to prevent possible malicious use-case:

  • There may not be duplicate entries in the bundle. The entry names are checked in a case-insensitive manner, and ensured that an entry with a given name can only occurr once.
  • Bundle entry names must use the forward slash as a name separator.
  • Bundle entry names cannot contain path names that correspond to specially interpreted relative names. ("." and "..")
  • Bundle entry names cannot contain colon (':') and semicolon (';') characters.
  • The class files for the declared tasks must exist in the bundle.
The manifest file must contain the "Nest-Bundle-Format-Version" attribute that is set to a valid version recognized by this class. Currently it must be 1.

The manifest file must contain an attribute for "Nest-Bundle-Identifier". However, it is not required for that to contain a version qualifier.

Any other possible and optional manifest attributes are declared in this class with the MANIFEST_NAME_* name. Other attributes which start with "Nest-" are reserved, and may not appear.

The bundles can contain meta-data files under the path META-INF/nest/ which are described in the appropriate entry name declaration in this class. The bundle is not verified if it contains any extra unrecognized files under the nest meta-data directory. See ENTRY_BUNDLE_TASKS and ENTRY_BUNDLE_DEPENDENCIES.

The class can be instantiated using one of the declared constructors, except the no-arg one which is reserved for Externalizable implementation.

Fields
public static final String
Dependency kind for specifying that the dependency is required to be on the classpath.
public static final String
DEPENDENCY_META_BUILD_SYSTEM_VERSION = "buildsystem-version"
Dependency meta-data name for specifying the saker.build systems versions the dependency applies to.
public static final String
Dependency meta-data name for specifying the Java Runtime versions the dependency applies to.
public static final String
DEPENDENCY_META_NATIVE_ARCHITECTURE = "native-architecture"
Dependency meta-data name for specifying the architectures that the dependency applies to.
public static final String
Bundle dependency meta data name for specifying that a dependency is optional.
public static final String
Bundle dependency meta data name for specifying that a dependency is optional.
public static final String
Dependency meta-data name for specifying the Nest repository versions the dependency applies to.
public static final String
DIR_META_INF_NEST = "META-INF/nest/"
Name of the bundle directory entry under which the meta-information files for the saker.nest bundles reside.
public static final String
ENTRY_BUNDLE_DEPENDENCIES = "META-INF/nest/dependencies"
Bundle entry name for the bundle dependencies.
public static final String
ENTRY_BUNDLE_EXTERNAL_DEPENDENCIES = "META-INF/nest/external_dependencies"
Bundle entry name for external dependencies.
public static final String
ENTRY_BUNDLE_TASKS = "META-INF/nest/tasks"
Bundle entry name for the task declarations.
public static final Name
Manifest attribute name for the bundle information version number.
public static final Name
Manifest attribute name for the bundle identifier.
public static final Name
Manifest attribute name for specifying special dependencies on the classpath of the bundle.
public static final Name
Manifest attribute name for specifying the architecture that the bundle's classpath may be loaded on.
public static final Name
Manifest attribute name for specifying the suitable build system versions that this bundle can load its classpath on.
public static final Name
Manifest attribute name for specifying the suitable Java versions this bundle can load its classpath on.
public static final Name
Manifest attribute name for specifying the suitable repository versions that this bundle can load its classpath on.
public static final Name
Manifest attribute name containing a BundleIdentifier of the associated documentation for this bundle.
public static final Name
Manifest attribute name containing a BundleIdentifier of the sources for this bundle.
public static final String
Constant for the manifest attribute MANIFEST_NAME_CLASSPATH_SPECIAL_DEPENDENCY.
public static final String
Constant for the manifest attribute MANIFEST_NAME_CLASSPATH_SPECIAL_DEPENDENCY.
Constructors
public
public
Creates a new instance based on the contents of the argument JAR file.
public
Creates a new instance based on the contents of the argument JAR input stream.
public
Creates a new instance based on the contents of the argument ZIP file.
Methods
public static BundleInformation
Creates a new instance based on the contents of the argument JAR file.
public static BundleInformation
Creates a new instance based on the contents of the argument JAR input stream.
public static BundleInformation
Creates a new instance based on the contents of the argument ZIP file.
public boolean
Indicates whether some other object is "equal to" this one.
public BundleIdentifier
Gets the bundle identifier.
public BundleDependencyInformation
Gets the dependency information for this bundle.
public BundleIdentifier
Gets the documentation attachment for this bundle.
public ExternalDependencyInformation
Gets the external dependencies of this bundle.
public String
Gets the declared main class in the manifest of this bundle.
public BundleIdentifier
Gets the source attachment for this bundle.
public Set<String>
Gets the set of supported classpath architectures by this bundle.
public VersionRange
Gets the version range declaration of the supported saker.build system versions.
public VersionRange
Gets the version range declaration of the supported classpath Java Runtime versions.
public VersionRange
Gets the version range declaration of the supported Nest repository versions.
public NavigableMap<TaskName, String>
Gets the declared tasks mapped to their class names in this bundle.
public int
Returns a hash code value for the object.
public boolean
Checks if this bundle requires the opened jdk.compiler module (or Java tools belov Java 9) on the classpath.
public boolean
Checks if this bundle requires the JDK tools to be present on the classpath.
public void
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
public String
Returns a string representation of the object.
public void
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
Inherited methods
From: Object
public static final String DEPENDENCY_KIND_CLASSPATH = "classpath"
Dependency kind for specifying that the dependency is required to be on the classpath.

The denoted archive is used to lookup classes which are required by classes contained in this bundle.

public static final String DEPENDENCY_META_BUILD_SYSTEM_VERSION = "buildsystem-version"
Dependency meta-data name for specifying the saker.build systems versions the dependency applies to.

The value of the meta-data is a VersionRange that specifies the build system version number range that the dependency should be applied to. If the current build system version constraint is not included in the specified version range, the associated dependency will be omitted.

This works similarly to MANIFEST_NAME_CLASSPATH_SUPPORTED_BUILD_SYSTEM_VERSIONS, but is declared on a dependency level instead of on the bundles.

Dependency resolvers may or may not take this meta-data into account. The repository will use this meta-data when creating the ClassLoader for the bundle.

public static final String DEPENDENCY_META_JRE_VERSION = "jre-version"
Dependency meta-data name for specifying the Java Runtime versions the dependency applies to.

The value of the meta-data is a VersionRange that specifies the JRE major version number range that the dependency should be applied to. If the current JRE version constraint is not included in the specified version range, the associated dependency will be omitted.

This works similarly to MANIFEST_NAME_CLASSPATH_SUPPORTED_JRE_VERSIONS, but is declared on a dependency level instead of on the bundles.

Dependency resolvers may or may not take this meta-data into account. The repository will use this meta-data when creating the ClassLoader for the bundle.

E.g. This meta-data name can be used to load different bundles on different Java versions:

 bundle.for.jdk8
     classpath: [0)
         jre-version: 8
 bundle.for.jdk9
     classpath: [0)
         jre-version: 9
 
This will cause the bundle.for.jdk8 to be loaded on Java 8, and bundle.for.jdk9 to be loaded on Java 9. Only one of them will be on the classpath.
public static final String DEPENDENCY_META_NATIVE_ARCHITECTURE = "native-architecture"
Dependency meta-data name for specifying the architectures that the dependency applies to.

The value of the meta-data is a comma separated architecture list that contains the architectures the dependency applies to. If the current architecture constraint is not included in the specified list, the associated dependency will be omitted.

This works similarly to MANIFEST_NAME_CLASSPATH_SUPPORTED_ARCHITECTURES, but is declared on a dependency level instead of on the bundles.

Dependency resolvers may or may not take this meta-data into account. The repository will use this meta-data when creating the ClassLoader for the bundle.

E.g. This meta-data can be used to load different bundles for different architectures:

 bundle.for.x86
     classpath: [0)
         native-architecture: x86
 bundle.for.x64
     classpath: [0)
         native-architecture: amd64
 
This will cause bundle.for.x86 to be loaded on x86 and bundle.for.x64 to be loaded on amd64. Only one of them will be on the classpath.
public static final String DEPENDENCY_META_OPTIONAL = "optional"
Bundle dependency meta data name for specifying that a dependency is optional.

The denoted bundle dependency is not required for the safe operation of this bundle.

public static final String DEPENDENCY_META_PRIVATE = "private"
Bundle dependency meta data name for specifying that a dependency is optional.

A private bundle dependency is considered to be an implementation detail for the bundle. The bundle doesn't publish data from a private through it's API.

saker.nest 0.8.1
public static final String DEPENDENCY_META_REPOSITORY_VERSION = "repo-version"
Dependency meta-data name for specifying the Nest repository versions the dependency applies to.

The value of the meta-data is a VersionRange that specifies the Nest repository version number range that the dependency should be applied to. If the current repository version constraint is not included in the specified version range, the associated dependency will be omitted.

This works similarly to MANIFEST_NAME_CLASSPATH_SUPPORTED_REPOSITORY_VERSIONS, but is declared on a dependency level instead of on the bundles.

Dependency resolvers may or may not take this meta-data into account. The repository will use this meta-data when creating the ClassLoader for the bundle.

public static final String DIR_META_INF_NEST = "META-INF/nest/"
Name of the bundle directory entry under which the meta-information files for the saker.nest bundles reside.
saker.nest 0.8.5
public static final String ENTRY_BUNDLE_DEPENDENCIES = "META-INF/nest/dependencies"
Bundle entry name for the bundle dependencies.

The file contains BundleDependencyInformation data in the format specified by BundleDependencyInformation.readFrom(InputStream, BundleIdentifier).

The this tokens in version ranges will be resolved to be the same as the enclosing bundle.

The "classpath" dependency kind is used to create the runtime ClassLoader for the classes in the bundle. These dependencies are transitively resolved to create the classpath for the bundle.

The classpath dependencies can have various meta-datas that can be used to configure the classpath loading for various environments. See the DEPENDENCY_META_* constants declared in this class.

public static final String ENTRY_BUNDLE_EXTERNAL_DEPENDENCIES = "META-INF/nest/external_dependencies"
Bundle entry name for external dependencies.

The file contains ExternalDependencyInformation data in the format specified by ExternalDependencyInformation.readFrom(InputStream).

Dependencies declared with the "classpath" kind will be added tot he runtime classpath of the bundle.

The classpath dependencies can have various meta-datas that can be used to configure the classpath loading for various environments. See the DEPENDENCY_META_* constants declared in this class.

saker.nest 0.8.5
public static final String ENTRY_BUNDLE_TASKS = "META-INF/nest/tasks"
Bundle entry name for the task declarations.

If a bundle entry is present at the value of this constant, then that file is used to read the declared tasks in the bundle. The file must have the following format in each line:

 [task.name]=[class-name]
 
Extra whitespace is allowed around the equals ('=') sign, and before and after the line contents. Lines that contain only whitespace are ignored.

Comments are not allowed.

The task name part must have the format defined by the TaskName class. It must not have qualifiers.

The class name must be the binary name of the task. It will be verified that the associated class file is present in the bundle.

Duplicate task declarations may not exists.

Manifest attribute name for the bundle information version number.

Allowed values are:

  • 1: The initial version.
Manifest attribute name for the bundle identifier.

The manifest attribute is required and must contain a valid BundleIdentifier for the bundle.

Manifest attribute name for specifying special dependencies on the classpath of the bundle.

This manifest attribute can be used to specify comma separated names that should be included in the classpath when loading the ClassLoader for this bundle.

Currently the following special classpath dependencies are allowed:

Manifest attribute name for specifying the architecture that the bundle's classpath may be loaded on.

The value is a comma (,) separated list of architecture names that the bundle classpath can be loaded on.

When the bundle classpath is loaded, the JVM reported architecture (os.arch property) is used to test if the bundle supports it. The architecture value is searched for in the attribute value. It is compared in a case-sensitive way.

If the manifest attribute is not specified, no restriction is placed for the supported architectures.

If the attribute is specified, it must specify at least one architecture, it cannot be empty.

Manifest attribute name for specifying the suitable build system versions that this bundle can load its classpath on.

The value of the attribute is a VersionRange that specifies the allowed build system versons on which the bundle's classpath can be loaded. The full version of saker.build is tested for the specified range.

If the attribute is not specified, no restriction is placed on the build system version.

Manifest attribute name for specifying the suitable Java versions this bundle can load its classpath on.

The value of the attribute is a VersionRange that specifies which version can the enclosing bundle's classpath loaded on. The version range may only contain version numbers with a single major number. E.g.

  • 8: The bundle may be loaded only on version 8. Same as [8].
  • [8, 10]: Allows the bundle to be loaded on JDK 8, 9, and 10, but not on later versions.
  • {8, 10, 12}: The bundle may be loaded only on versions 8, 10 and 12.
  • 8.0.1: Invalid version range, as it may only contain version numbers with a single component.
Manifest attribute name for specifying the suitable repository versions that this bundle can load its classpath on.

The value of the attribute is a VersionRange that specifies the allowed repository versons on which the bundle's classpath can be loaded. The full version of the Nest repository is tested for the specified range.

If the attribute is not specified, no restriction is placed on the repository version.

Manifest attribute name containing a BundleIdentifier of the associated documentation for this bundle.

The bundle that is specified by the value of this attribute is considered to contain the documentation for this bundle. The format of the files are unspecified. It may include documentation for different languages as well.

Manifest attribute name containing a BundleIdentifier of the sources for this bundle.

The bundle that is specified by the value of this attribute is considered to contain the sources for this bundle. The format of the files are unspecified. It may include sources from different languages, other from Java as well.

public static final String SPECIAL_CLASSPATH_DEPENDENCY_JDK_COMPILER_OPEN = "jdk.compiler-open"
Constant for the manifest attribute MANIFEST_NAME_CLASSPATH_SPECIAL_DEPENDENCY.

Requires the Java compiler related classes as the parent to the bundle class loader.
On JDK8 this works the same way as SPECIAL_CLASSPATH_DEPENDENCY_JDK_TOOLS, it loads the tools.jar for the classpath.
On later JDK versions, the repository runtime will load the jdk.compiler module in a way that it opens its packages to the bundle classloader. This means that the bundle classes will be able to access non-exported classes and packages from the jdk.compiler module.

Special care should be taken as the jdk.compiler module is essentially reloaded by the repository runtime. Its classes will be defined multiple times in the same JVM specifically for the repository operation. Bundles that use this feature should perform testing on the JDK versions it's expected to run. You will not be able to typecast object from the opened jdk.compiler module to types in the boot jdk.compilermodule.

If both this value and "jdktools" are specified, this takes precedence.

saker.nest 0.8.5
public static final String SPECIAL_CLASSPATH_DEPENDENCY_JDK_TOOLS = "jdktools"
Constant for the manifest attribute MANIFEST_NAME_CLASSPATH_SPECIAL_DEPENDENCY.

Requires the Java compiler related classes as the parent to the bundle class loader.
On JDK8 this will mean that the tools.jar in the JDK will be loaded and used as parent.
On later JDK version the platform class loader will be present as a parent class loader.

Creates a new instance based on the contents of the argument JAR file.
jfThe JAR file.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
InvalidNestBundleExceptionIf the bundle validation fails.
Creates a new instance based on the contents of the argument JAR input stream.
jisThe JAR input.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
InvalidNestBundleExceptionIf the bundle validation fails.
Creates a new instance based on the contents of the argument ZIP file.
zfThe Zip file.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
InvalidNestBundleExceptionIf the bundle validation fails.
Creates a new instance based on the contents of the argument JAR file.

The method also performs strict validation of the bundle properties. Strict validation ensures that the bundle declares facilities only that is supported by the current repository runtime.

jfThe JAR file.
The created bundle information.
InvalidNestBundleExceptionIf the bundle validation fails.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
saker.nest 0.8.5
Creates a new instance based on the contents of the argument JAR input stream.

The method also performs strict validation of the bundle properties. Strict validation ensures that the bundle declares facilities only that is supported by the current repository runtime.

jisThe JAR input.
The created bundle information.
InvalidNestBundleExceptionIf the bundle validation fails.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
saker.nest 0.8.5
Creates a new instance based on the contents of the argument ZIP file.

The method also performs strict validation of the bundle properties. Strict validation ensures that the bundle declares facilities only that is supported by the current repository runtime.

zfThe Zip file.
The created bundle information.
InvalidNestBundleExceptionIf the bundle validation fails.
NullPointerExceptionIf the argument is null.
IOExceptionIn case of I/O error.
saker.nest 0.8.5
public boolean equals(Object obj)
Overridden from: Object
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.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

objthe reference object with which to compare.
true if this object is the same as the obj argument; false otherwise.
Gets the bundle identifier.
The bundle identifier. Never null.
Gets the dependency information for this bundle.
The dependency information. Never null.
Gets the documentation attachment for this bundle.
The documentation attachment bundle identifier or null if none.
Gets the external dependencies of this bundle.

If the bundle declares no external dependencies, an empty informaiton object is returned.

The external dependency information. Never null.
saker.nest 0.8.5
Gets the declared main class in the manifest of this bundle.

This is determined using the Main-Class attribute.

The declared main class or null if none.
Gets the source attachment for this bundle.
The source attachment bundle identifier or null if none.
Gets the set of supported classpath architectures by this bundle.

The architectures correspond to the manifest attribute MANIFEST_NAME_CLASSPATH_SUPPORTED_ARCHITECTURES.

The set os supported architectures or null if not restricted by this bundle.
Gets the version range declaration of the supported saker.build system versions.

The version range corresponds to the manifest attribute MANIFEST_NAME_CLASSPATH_SUPPORTED_BUILD_SYSTEM_VERSIONS.

The supported version range or null if not restricted by this bundle.
Gets the version range declaration of the supported classpath Java Runtime versions.

The version range corresponds to the manifest attribute MANIFEST_NAME_CLASSPATH_SUPPORTED_JRE_VERSIONS.

The supported version range or null if not restricted by this bundle.
Gets the version range declaration of the supported Nest repository versions.

The version range corresponds to the manifest attribute MANIFEST_NAME_CLASSPATH_SUPPORTED_REPOSITORY_VERSIONS.

The supported version range or null if not restricted by this bundle.
Gets the declared tasks mapped to their class names in this bundle.
An unmodifiable map of task names to class names.
public int hashCode()
Overridden from: Object
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by 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(Object) 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 Object.equals(Object) 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.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

a hash code value for this object.
Checks if this bundle requires the opened jdk.compiler module (or Java tools belov Java 9) on the classpath.
true if the bundle requires the opened JDK compiler classes.
saker.nest 0.8.5
public boolean isJdkToolsDependent()
Checks if this bundle requires the JDK tools to be present on the classpath.
true if the bundle requires the JDK tools classes.
Overridden from: Externalizable
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
inthe stream to read data from in order to restore the object
IOExceptionif I/O errors occur
ClassNotFoundExceptionIf the class for an object being restored cannot be found.
public String toString()
Overridden from: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
a string representation of the object.
public void writeExternal(ObjectOutput out) throws IOException
Overridden from: Externalizable
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
outthe stream to write the object to
IOExceptionIncludes any I/O exceptions that may occur