From fd6a393d69dddce2e4cf6c824fab16a8dce04ce1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sun, 4 Apr 2021 12:15:55 -0700 Subject: [PATCH] Removing Pack200 support. It has been removed from the JDK for some time now. People still relying on it will have to stick to an older version of Getdown. --- .../com/threerings/getdown/data/Resource.java | 39 +++---------------- .../com/threerings/getdown/util/FileUtil.java | 17 -------- 2 files changed, 6 insertions(+), 50 deletions(-) diff --git a/core/src/main/java/com/threerings/getdown/data/Resource.java b/core/src/main/java/com/threerings/getdown/data/Resource.java index d1ccba3..2ea7798 100644 --- a/core/src/main/java/com/threerings/getdown/data/Resource.java +++ b/core/src/main/java/com/threerings/getdown/data/Resource.java @@ -56,23 +56,15 @@ public class Resource implements Comparable int read; boolean isZip = isJar(target) || isZip(target); // jar is a zip too - boolean isPacked200Jar = isPacked200Jar(target); // if this is a jar, we need to compute the digest in a "timestamp and file order" agnostic // manner to properly correlate jardiff patched jars with their unpatched originals - if (isPacked200Jar || isZip){ + if (isZip){ File tmpJarFile = null; ZipFile zip = null; try { // if this is a compressed zip file, uncompress it to compute the zip file digest - if (isPacked200Jar){ - tmpJarFile = new File(target.getPath() + ".tmp"); - tmpJarFile.deleteOnExit(); - FileUtil.unpackPacked200Jar(target, tmpJarFile); - zip = new ZipFile(tmpJarFile); - } else{ - zip = new ZipFile(target); - } + zip = new ZipFile(target); List entries = Collections.list(zip.entries()); Collections.sort(entries, ENTRY_COMP); @@ -140,16 +132,6 @@ public class Resource implements Comparable return path.endsWith(".jar") || path.endsWith(".jar_new"); } - /** - * Returns whether {@code file} is a {@code jar.pack} file. - */ - public static boolean isPacked200Jar (File file) - { - String path = file.getName(); - return path.endsWith(".jar.pack") || path.endsWith(".jar.pack_new") || - path.endsWith(".jar.pack.gz") || path.endsWith(".jar.pack.gz_new"); - } - /** * Creates a resource with the supplied remote URL and local path. */ @@ -163,14 +145,9 @@ public class Resource implements Comparable _attrs = attrs; _isZip = isJar(local) || isZip(local); - _isPacked200Jar = isPacked200Jar(local); boolean unpack = attrs.contains(Attr.UNPACK); if (unpack && _isZip) { _unpacked = _local.getParentFile(); - } else if(unpack && _isPacked200Jar) { - String dotJar = ".jar", lname = _local.getName(); - String uname = lname.substring(0, lname.lastIndexOf(dotJar) + dotJar.length()); - _unpacked = new File(_local.getParent(), uname); } } @@ -321,15 +298,11 @@ public class Resource implements Comparable public void unpack () throws IOException { // sanity check - if (!_isZip && !_isPacked200Jar) { + if (!_isZip) { throw new IOException("Requested to unpack non-jar file '" + _local + "'."); } - if (_isZip) { - try (ZipFile jar = new ZipFile(_local)) { - FileUtil.unpackJar(jar, _unpacked, _attrs.contains(Attr.CLEAN)); - } - } else { - FileUtil.unpackPacked200Jar(_local, _unpacked); + try (ZipFile jar = new ZipFile(_local)) { + FileUtil.unpackJar(jar, _unpacked, _attrs.contains(Attr.CLEAN)); } } @@ -393,7 +366,7 @@ public class Resource implements Comparable protected URL _remote; protected File _local, _localNew, _marker, _unpacked; protected EnumSet _attrs; - protected boolean _isZip, _isPacked200Jar; + protected boolean _isZip; /** Used to sort the entries in a jar file. */ protected static final Comparator ENTRY_COMP = new Comparator() { diff --git a/core/src/main/java/com/threerings/getdown/util/FileUtil.java b/core/src/main/java/com/threerings/getdown/util/FileUtil.java index 38dd1c3..513f104 100644 --- a/core/src/main/java/com/threerings/getdown/util/FileUtil.java +++ b/core/src/main/java/com/threerings/getdown/util/FileUtil.java @@ -167,23 +167,6 @@ public final class FileUtil } } - /** - * Unpacks a pack200 packed jar file from {@code packedJar} into {@code target}. - * If {@code packedJar} has a {@code .gz} extension, it will be gunzipped first. - */ - public static void unpackPacked200Jar (File packedJar, File target) throws IOException - { - try (InputStream packJarIn = new FileInputStream(packedJar); - JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(target))) { - boolean gz = (packedJar.getName().endsWith(".gz") || - packedJar.getName().endsWith(".gz_new")); - try (InputStream packJarIn2 = (gz ? new GZIPInputStream(packJarIn) : packJarIn)) { - Pack200.Unpacker unpacker = Pack200.newUnpacker(); - unpacker.unpack(packJarIn2, jarOut); - } - } - } - /** * Copies the given {@code source} file to the given {@code target}. */