--- old/src/java.base/share/classes/jdk/internal/jimage/Archive.java 2015-06-23 14:28:50.000000000 +0200 +++ new/src/java.base/share/classes/jdk/internal/jimage/Archive.java 2015-06-23 14:28:50.000000000 +0200 @@ -24,42 +24,95 @@ */ package jdk.internal.jimage; +import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Path; -import java.util.function.Consumer; +import java.util.stream.Stream; /** * An Archive of all content, classes, resources, configuration files, and * other, for a module. */ public interface Archive { + /** - * The module name. + * Entry is contained in an Archive */ - String moduleName(); + public abstract class Entry { + + public static enum EntryType { + + MODULE_NAME, + CLASS_OR_RESOURCE, + NATIVE_LIB, + NATIVE_CMD, + CONFIG, + SERVICE; + } + + private final String name; + private final EntryType type; + private final Archive archive; + private final String path; + + public Entry(Archive archive, String path, String name, EntryType type) { + this.archive = archive; + this.path = path; + this.name = name; + this.type = type; + } + + public Archive archive() { + return archive; + } + + public String path() { + return path; + } + + public EntryType type() { + return type; + } + + /** + * Returns the name of this entry. + */ + public String name() { + return name; + } + + @Override + public String toString() { + return "type " + type.name() + " path " + path; + } + + /** + * Returns the number of uncompressed bytes for this entry. + */ + public abstract long size(); + + public abstract InputStream stream() throws IOException; + } /** - * Visits all classes and resources. + * The module name. */ - void visitResources(Consumer consumer); + String moduleName(); /** - * Visits all entries in the Archive. + * Stream of Entry. + * The stream of entries needs to be closed after use since + * (eg: it might cover lazy I/O based resources). + * So callers will need to use a try-with-resources block. */ - void visitEntries(Consumer consumer) ; + Stream entries(); /** - * An entries in the Archive. + * Open the archive */ - interface Entry { - String getName(); - InputStream getInputStream(); - boolean isDirectory(); - } + void open() throws IOException; /** - * A Consumer suitable for writing Entries from this Archive. + * Close the archive */ - Consumer defaultImageWriter(Path path, OutputStream out); + void close() throws IOException; }