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 static AbstractInsnNode nextReal(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1);
while ((insn = insn.getNext()) != null && insn.getOpcode() == -1) {
/* empty */
}
return 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;
}
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;
}
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;
}

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

Loading…
Cancel
Save