java.util.jar.Pack200 Java Examples
The following examples show how to use
java.util.jar.Pack200.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PackerImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #2
Source File: PackerImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarInputStream and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * <p> * The modification time and deflation hint attributes are not available, * for the jar-manifest file and the directory containing the file. * * @see #MODIFICATION_TIME * @see #DEFLATION_HINT * @param in a JarInputStream * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarInputStream in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #3
Source File: NativeUnpack.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private void updateProgress() { // Progress is a combination of segment reading and file writing. final double READ_WT = 0.33; final double WRITE_WT = 0.67; double readProgress = _segCount; if (_estByteLimit > 0 && _byteCount > 0) readProgress += (double)_byteCount / _estByteLimit; double writeProgress = _fileCount; double scaledProgress = READ_WT * readProgress / Math.max(_estSegLimit,1) + WRITE_WT * writeProgress / Math.max(_estFileLimit,1); int percent = (int) Math.round(100*scaledProgress); if (percent > 100) percent = 100; if (percent > _prevPercent) { _prevPercent = percent; _props.setInteger(Pack200.Unpacker.PROGRESS, percent); if (_verbose > 0) Utils.log.info("progress = "+percent); } }
Example #4
Source File: PackerImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #5
Source File: NativeUnpack.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void updateProgress() { // Progress is a combination of segment reading and file writing. final double READ_WT = 0.33; final double WRITE_WT = 0.67; double readProgress = _segCount; if (_estByteLimit > 0 && _byteCount > 0) readProgress += (double)_byteCount / _estByteLimit; double writeProgress = _fileCount; double scaledProgress = READ_WT * readProgress / Math.max(_estSegLimit,1) + WRITE_WT * writeProgress / Math.max(_estFileLimit,1); int percent = (int) Math.round(100*scaledProgress); if (percent > 100) percent = 100; if (percent > _prevPercent) { _prevPercent = percent; _props.setInteger(Pack200.Unpacker.PROGRESS, percent); if (_verbose > 0) Utils.log.info("progress = "+percent); } }
Example #6
Source File: NativeUnpack.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void updateProgress() { // Progress is a combination of segment reading and file writing. final double READ_WT = 0.33; final double WRITE_WT = 0.67; double readProgress = _segCount; if (_estByteLimit > 0 && _byteCount > 0) readProgress += (double)_byteCount / _estByteLimit; double writeProgress = _fileCount; double scaledProgress = READ_WT * readProgress / Math.max(_estSegLimit,1) + WRITE_WT * writeProgress / Math.max(_estFileLimit,1); int percent = (int) Math.round(100*scaledProgress); if (percent > 100) percent = 100; if (percent > _prevPercent) { _prevPercent = percent; _props.setInteger(Pack200.Unpacker.PROGRESS, percent); if (_verbose > 0) Utils.log.info("progress = "+percent); } }
Example #7
Source File: PackerImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #8
Source File: PackerImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert(Utils.currentInstance.get() == null); TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone.getDefault(); try { Utils.currentInstance.set(this); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (tz != null) TimeZone.setDefault(tz); in.close(); } }
Example #9
Source File: Pack.java From ramus with GNU General Public License v3.0 | 6 votes |
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { if (args.length != 2) { System.err.println("command unput-directory output-directory"); System.exit(1); } Packer packer = Pack200.newPacker(); Map p = packer.properties(); p.put(Packer.EFFORT, "9"); p.put(Packer.SEGMENT_LIMIT, "-1"); p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE); p.put(Packer.MODIFICATION_TIME, Packer.LATEST); p.put(Packer.DEFLATE_HINT, Packer.FALSE); p.put(Packer.CODE_ATTRIBUTE_PFX + "LineNumberTable", Packer.STRIP); p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR); File inputDirectory = new File(args[0]); File outputDirectory = new File(args[1]); pack(packer, inputDirectory, outputDirectory); }
Example #10
Source File: RepackJars.java From EclipseCodeFormatter with Apache License 2.0 | 6 votes |
private Map<String, String> properties() { // Create the Packer object Pack200.Packer packer = Pack200.newPacker(); Map<String, String> p = packer.properties(); p.put(Pack200.Packer.EFFORT, "9"); // default is "5" p.put(Pack200.Packer.SEGMENT_LIMIT, "-1"); p.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.FALSE); p.put(Pack200.Packer.MODIFICATION_TIME, Pack200.Packer.LATEST); p.put(Pack200.Packer.DEFLATE_HINT, Pack200.Packer.TRUE); // compression enabled // p.put("com.sun.java.util.jar.pack.verbose", Pack200.Packer.FALSE); // p.put("com.sun.java.util.jar.pack.nolog", Pack200.Packer.TRUE); String[] attributes = { UNKNOWN_ATTRIBUTE, CLASS_ATTRIBUTE_PFX, FIELD_ATTRIBUTE_PFX, METHOD_ATTRIBUTE_PFX, CODE_ATTRIBUTE_PFX, }; String[] stripCodeAttributes = { "SourceFile", "LineNumberTable", "LocalVariableTable", "Deprecated" }; for (String attribute : attributes) { for (String attributeName : stripCodeAttributes) { p.put(attribute + attributeName, Pack200.Packer.STRIP); } } p.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.STRIP); return p; }
Example #11
Source File: NativeUnpack.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void updateProgress() { // Progress is a combination of segment reading and file writing. final double READ_WT = 0.33; final double WRITE_WT = 0.67; double readProgress = _segCount; if (_estByteLimit > 0 && _byteCount > 0) readProgress += (double)_byteCount / _estByteLimit; double writeProgress = _fileCount; double scaledProgress = READ_WT * readProgress / Math.max(_estSegLimit,1) + WRITE_WT * writeProgress / Math.max(_estFileLimit,1); int percent = (int) Math.round(100*scaledProgress); if (percent > 100) percent = 100; if (percent > _prevPercent) { _prevPercent = percent; _props.setInteger(Pack200.Unpacker.PROGRESS, percent); if (_verbose > 0) Utils.log.info("progress = "+percent); } }
Example #12
Source File: PackerImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #13
Source File: PackerImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarInputStream and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * <p> * The modification time and deflation hint attributes are not available, * for the jar-manifest file and the directory containing the file. * * @see #MODIFICATION_TIME * @see #DEFLATION_HINT * @param in a JarInputStream * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarInputStream in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #14
Source File: PackerImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert(Utils.currentInstance.get() == null); TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone.getDefault(); try { Utils.currentInstance.set(this); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (tz != null) TimeZone.setDefault(tz); in.close(); } }
Example #15
Source File: PackerImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert(Utils.currentInstance.get() == null); TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone.getDefault(); try { Utils.currentInstance.set(this); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (tz != null) TimeZone.setDefault(tz); in.close(); } }
Example #16
Source File: PackerImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Takes a JarFile and converts into a pack-stream. * <p> * Closes its input but not its output. (Pack200 archives are appendable.) * * @param in a JarFile * @param out an OutputStream * @exception IOException if an error is encountered. */ public synchronized void pack(JarFile in, OutputStream out) throws IOException { assert (Utils.currentInstance.get() == null); boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE); try { Utils.currentInstance.set(this); if (needUTC) { Utils.changeDefaultTimeZoneToUtc(); } if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) { Utils.copyJarFile(in, out); } else { (new DoPack()).run(in, out); } } finally { Utils.currentInstance.set(null); if (needUTC) { Utils.restoreDefaultTimeZone(); } in.close(); } }
Example #17
Source File: PackageVersionTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void verify6991164() { Unpacker unpacker = Pack200.newUnpacker(); String versionStr = unpacker.toString(); String expected = "Pack200, Vendor: " + System.getProperty("java.vendor") + ", Version: " + JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; if (!versionStr.equals(expected)) { System.out.println("Expected: " + expected); System.out.println("Obtained: " + versionStr); throw new RuntimeException("did not get expected string " + expected); } }
Example #18
Source File: PackerImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
void flushPartial(OutputStream out, int nextCount) throws IOException { if (pkg.files.isEmpty() && pkg.classes.isEmpty()) { return; // do not flush an empty segment } flushPackage(out, Math.max(1, nextCount)); props.setInteger(Pack200.Packer.PROGRESS, 25); // In case there will be another segment: makeNextPackage(); segmentCount += 1; segmentTotalSize += segmentSize; segmentSize = 0; }
Example #19
Source File: PackageVersionTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static void verify6991164() { Unpacker unpacker = Pack200.newUnpacker(); String versionStr = unpacker.toString(); String expected = "Pack200, Vendor: " + System.getProperty("java.vendor") + ", Version: " + JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; if (!versionStr.equals(expected)) { System.out.println("Expected: " + expected); System.out.println("Obtained: " + versionStr); throw new RuntimeException("did not get expected string " + expected); } }
Example #20
Source File: Utils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void unpack0(File inFile, JarOutputStream jarStream, boolean useJavaUnpack) throws IOException { // Unpack the files Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> props = unpacker.properties(); if (useJavaUnpack) { props.put("com.sun.java.util.jar.pack.disable.native", "true"); } // Call the unpacker unpacker.unpack(inFile, jarStream); }
Example #21
Source File: PackerImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void flushPartial(OutputStream out, int nextCount) throws IOException { if (pkg.files.isEmpty() && pkg.classes.isEmpty()) { return; // do not flush an empty segment } flushPackage(out, Math.max(1, nextCount)); props.setInteger(Pack200.Packer.PROGRESS, 25); // In case there will be another segment: makeNextPackage(); segmentCount += 1; segmentTotalSize += segmentSize; segmentSize = 0; }
Example #22
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void unpack0(File inFile, JarOutputStream jarStream, boolean useJavaUnpack) throws IOException { // Unpack the files Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> props = unpacker.properties(); if (useJavaUnpack) { props.put("com.sun.java.util.jar.pack.disable.native", "true"); } // Call the unpacker unpacker.unpack(inFile, jarStream); }
Example #23
Source File: PackageVersionTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void verify6991164() { Unpacker unpacker = Pack200.newUnpacker(); String versionStr = unpacker.toString(); String expected = "Pack200, Vendor: " + System.getProperty("java.vendor") + ", Version: " + JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; if (!versionStr.equals(expected)) { System.out.println("Expected: " + expected); System.out.println("Obtained: " + versionStr); throw new RuntimeException("did not get expected string " + expected); } }
Example #24
Source File: Utils.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void unpack0(File inFile, JarOutputStream jarStream, boolean useJavaUnpack) throws IOException { // Unpack the files Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> props = unpacker.properties(); if (useJavaUnpack) { props.put("com.sun.java.util.jar.pack.disable.native", "true"); } // Call the unpacker unpacker.unpack(inFile, jarStream); }
Example #25
Source File: Utils.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void unpack0(File inFile, JarOutputStream jarStream, boolean useJavaUnpack) throws IOException { // Unpack the files Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> props = unpacker.properties(); if (useJavaUnpack) { props.put("com.sun.java.util.jar.pack.disable.native", "true"); } // Call the unpacker unpacker.unpack(inFile, jarStream); }
Example #26
Source File: PackageVersionTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static void verify6991164() { Unpacker unpacker = Pack200.newUnpacker(); String versionStr = unpacker.toString(); String expected = "Pack200, Vendor: " + System.getProperty("java.vendor") + ", Version: " + JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; if (!versionStr.equals(expected)) { System.out.println("Expected: " + expected); System.out.println("Obtained: " + versionStr); throw new RuntimeException("did not get expected string " + expected); } }
Example #27
Source File: PackerImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void flushAll(OutputStream out) throws IOException { props.setInteger(Pack200.Packer.PROGRESS, 50); flushPackage(out, 0); out.flush(); props.setInteger(Pack200.Packer.PROGRESS, 100); segmentCount += 1; segmentTotalSize += segmentSize; segmentSize = 0; if (verbose > 0 && segmentCount > 1) { Utils.log.info("Transmitted " +segmentTotalSize+" input bytes in " +segmentCount+" segments totaling " +totalOutputSize+" bytes"); } }
Example #28
Source File: Utils.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void unpack0(File inFile, JarOutputStream jarStream, boolean useJavaUnpack) throws IOException { // Unpack the files Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> props = unpacker.properties(); if (useJavaUnpack) { props.put("com.sun.java.util.jar.pack.disable.native", "true"); } // Call the unpacker unpacker.unpack(inFile, jarStream); }
Example #29
Source File: PackerImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void flushAll(OutputStream out) throws IOException { props.setInteger(Pack200.Packer.PROGRESS, 50); flushPackage(out, 0); out.flush(); props.setInteger(Pack200.Packer.PROGRESS, 100); segmentCount += 1; segmentTotalSize += segmentSize; segmentSize = 0; if (verbose > 0 && segmentCount > 1) { Utils.log.info("Transmitted " +segmentTotalSize+" input bytes in " +segmentCount+" segments totaling " +totalOutputSize+" bytes"); } }
Example #30
Source File: PackageVersionTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
static void verify6991164() { Unpacker unpacker = Pack200.newUnpacker(); String versionStr = unpacker.toString(); String expected = "Pack200, Vendor: " + System.getProperty("java.vendor") + ", Version: " + JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION; if (!versionStr.equals(expected)) { System.out.println("Expected: " + expected); System.out.println("Obtained: " + versionStr); throw new RuntimeException("did not get expected string " + expected); } }