Format code

bzip2
Graham 5 years ago
parent 36995c46ef
commit 48f8c68500
  1. 16
      asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java
  2. 12
      asm/src/main/java/dev/openrs2/asm/Library.java

@ -4,22 +4,30 @@ import org.objectweb.asm.tree.AbstractInsnNode;
public final class InsnNodeUtils { public final class InsnNodeUtils {
public static AbstractInsnNode nextReal(AbstractInsnNode insn) { public static AbstractInsnNode nextReal(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1); while ((insn = insn.getNext()) != null && insn.getOpcode() == -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode previousReal(AbstractInsnNode insn) { public static AbstractInsnNode previousReal(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1); while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) { public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() != -1); while ((insn = insn.getNext()) != null && insn.getOpcode() != -1) {
/* empty */
}
return insn; return insn;
} }
public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) { public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1); while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1) {
/* empty */
}
return insn; return insn;
} }

@ -63,10 +63,12 @@ public final class Library implements Iterable<ClassNode> {
var temp = Files.createTempFile(TEMP_PREFIX, JAR_SUFFIX); var temp = Files.createTempFile(TEMP_PREFIX, JAR_SUFFIX);
try { try {
try (var header = new ByteArrayInputStream(GZIP_HEADER); try (
var header = new ByteArrayInputStream(GZIP_HEADER);
var data = Files.newInputStream(path); var data = Files.newInputStream(path);
var in = new GZIPInputStream(new SequenceInputStream(header, data)); var in = new GZIPInputStream(new SequenceInputStream(header, data));
var out = new JarOutputStream(Files.newOutputStream(temp))) { var out = new JarOutputStream(Files.newOutputStream(temp))
) {
Pack200.newUnpacker().unpack(in, out); Pack200.newUnpacker().unpack(in, out);
return readJar(temp); return readJar(temp);
} }
@ -138,8 +140,10 @@ public final class Library implements Iterable<ClassNode> {
try { try {
writeJar(temp, remapper); writeJar(temp, remapper);
try (var in = new JarInputStream(Files.newInputStream(temp)); try (
var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2))) { var in = new JarInputStream(Files.newInputStream(temp));
var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2))
) {
Pack200.newPacker().pack(in, out); Pack200.newPacker().pack(in, out);
} }
} finally { } finally {

Loading…
Cancel
Save