< prev index next >
src/java.base/share/classes/jdk/internal/jmod/JmodFile.java
Print this page
*** 26,49 ****
package jdk.internal.jmod;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* Helper class to read JMOD file
*/
public class JmodFile implements AutoCloseable {
// jmod magic number and version number
! public static final int JMOD_MAJOR_VERSION = 0x01;
! public static final int JMOD_MINOR_VERSION = 0x00;
! public static final byte[] JMOD_MAGIC_NUMBER = {
0x4A, 0x4D, /* JM */
JMOD_MAJOR_VERSION, JMOD_MINOR_VERSION, /* version 1.0 */
};
public static void checkMagic(Path file) throws IOException {
--- 26,51 ----
package jdk.internal.jmod;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+ import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
+ import java.util.Iterator;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* Helper class to read JMOD file
*/
public class JmodFile implements AutoCloseable {
// jmod magic number and version number
! private static final int JMOD_MAJOR_VERSION = 0x01;
! private static final int JMOD_MINOR_VERSION = 0x00;
! private static final byte[] JMOD_MAGIC_NUMBER = {
0x4A, 0x4D, /* JM */
JMOD_MAJOR_VERSION, JMOD_MINOR_VERSION, /* version 1.0 */
};
public static void checkMagic(Path file) throws IOException {
*** 173,182 ****
--- 175,188 ----
checkMagic(file);
this.file = file;
this.zipfile = new ZipFile(file.toFile());
}
+ public static void writeMagicNumber(OutputStream os) throws IOException {
+ os.write(JMOD_MAGIC_NUMBER);
+ }
+
/**
* Returns the {@code Entry} for a resource in a JMOD file section
* or {@code null} if not found.
*/
public Entry getEntry(Section section, String name) {
< prev index next >