Use immutable collections types from Guava

bzip2
Graham 5 years ago
parent 012d5ed0db
commit 517032959e
  1. 70
      asm/src/main/java/dev/openrs2/asm/InsnMatcher.java
  2. 16
      asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.java
  3. 8
      asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.java
  4. 47
      asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.java
  5. 15
      asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.java
  6. 12
      decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.java
  7. 7
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java
  8. 4
      deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.java
  9. 8
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.java
  10. 5
      deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.java
  11. 7
      deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.java

@ -1,12 +1,12 @@
package dev.openrs2.asm; package dev.openrs2.asm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnList;
@ -15,8 +15,8 @@ import org.objectweb.asm.util.Printer;
public final class InsnMatcher { public final class InsnMatcher {
private static final int PRIVATE_USE_AREA = 0xE000; private static final int PRIVATE_USE_AREA = 0xE000;
private static final Map<String, int[]> OPCODE_GROUPS = Map.ofEntries( private static final ImmutableMap<String, int[]> OPCODE_GROUPS = ImmutableMap.<String, int[]>builder()
Map.entry("InsnNode", new int[] { .put("InsnNode", new int[] {
Opcodes.NOP, Opcodes.NOP,
Opcodes.ACONST_NULL, Opcodes.ACONST_NULL,
Opcodes.ICONST_M1, Opcodes.ICONST_M1,
@ -124,13 +124,13 @@ public final class InsnMatcher {
Opcodes.ATHROW, Opcodes.ATHROW,
Opcodes.MONITORENTER, Opcodes.MONITORENTER,
Opcodes.MONITOREXIT Opcodes.MONITOREXIT
}), })
Map.entry("IntInsnNode", new int[] { .put("IntInsnNode", new int[] {
Opcodes.BIPUSH, Opcodes.BIPUSH,
Opcodes.SIPUSH, Opcodes.SIPUSH,
Opcodes.NEWARRAY Opcodes.NEWARRAY
}), })
Map.entry("VarInsnNode", new int[] { .put("VarInsnNode", new int[] {
Opcodes.ILOAD, Opcodes.ILOAD,
Opcodes.LLOAD, Opcodes.LLOAD,
Opcodes.FLOAD, Opcodes.FLOAD,
@ -142,29 +142,29 @@ public final class InsnMatcher {
Opcodes.DSTORE, Opcodes.DSTORE,
Opcodes.ASTORE, Opcodes.ASTORE,
Opcodes.RET Opcodes.RET
}), })
Map.entry("TypeInsnNode", new int[] { .put("TypeInsnNode", new int[] {
Opcodes.NEW, Opcodes.NEW,
Opcodes.ANEWARRAY, Opcodes.ANEWARRAY,
Opcodes.CHECKCAST, Opcodes.CHECKCAST,
Opcodes.INSTANCEOF Opcodes.INSTANCEOF
}), })
Map.entry("FieldInsnNode", new int[] { .put("FieldInsnNode", new int[] {
Opcodes.GETSTATIC, Opcodes.GETSTATIC,
Opcodes.PUTSTATIC, Opcodes.PUTSTATIC,
Opcodes.GETFIELD, Opcodes.GETFIELD,
Opcodes.PUTFIELD Opcodes.PUTFIELD
}), })
Map.entry("MethodInsnNode", new int[] { .put("MethodInsnNode", new int[] {
Opcodes.INVOKEVIRTUAL, Opcodes.INVOKEVIRTUAL,
Opcodes.INVOKESPECIAL, Opcodes.INVOKESPECIAL,
Opcodes.INVOKESTATIC, Opcodes.INVOKESTATIC,
Opcodes.INVOKEINTERFACE Opcodes.INVOKEINTERFACE
}), })
Map.entry("InvokeDynamicInsnNode", new int[] { .put("InvokeDynamicInsnNode", new int[] {
Opcodes.INVOKEDYNAMIC Opcodes.INVOKEDYNAMIC
}), })
Map.entry("JumpInsnNode", new int[] { .put("JumpInsnNode", new int[] {
Opcodes.IFEQ, Opcodes.IFEQ,
Opcodes.IFNE, Opcodes.IFNE,
Opcodes.IFLT, Opcodes.IFLT,
@ -183,23 +183,23 @@ public final class InsnMatcher {
Opcodes.JSR, Opcodes.JSR,
Opcodes.IFNULL, Opcodes.IFNULL,
Opcodes.IFNONNULL Opcodes.IFNONNULL
}), })
Map.entry("LdcInsnNode", new int[] { .put("LdcInsnNode", new int[] {
Opcodes.LDC Opcodes.LDC
}), })
Map.entry("IincInsnNode", new int[] { .put("IincInsnNode", new int[] {
Opcodes.IINC Opcodes.IINC
}), })
Map.entry("TableSwitchInsnNode", new int[] { .put("TableSwitchInsnNode", new int[] {
Opcodes.TABLESWITCH Opcodes.TABLESWITCH
}), })
Map.entry("LookupSwitchInsnNode", new int[] { .put("LookupSwitchInsnNode", new int[] {
Opcodes.LOOKUPSWITCH Opcodes.LOOKUPSWITCH
}), })
Map.entry("MultiANewArrayInsnNode", new int[] { .put("MultiANewArrayInsnNode", new int[] {
Opcodes.MULTIANEWARRAY Opcodes.MULTIANEWARRAY
}), })
Map.entry("ICONST", new int[] { .put("ICONST", new int[] {
Opcodes.ICONST_M1, Opcodes.ICONST_M1,
Opcodes.ICONST_0, Opcodes.ICONST_0,
Opcodes.ICONST_1, Opcodes.ICONST_1,
@ -208,7 +208,7 @@ public final class InsnMatcher {
Opcodes.ICONST_4, Opcodes.ICONST_4,
Opcodes.ICONST_5 Opcodes.ICONST_5
}) })
); .build();
private static char opcodeToCodepoint(int opcode) { private static char opcodeToCodepoint(int opcode) {
return (char) (PRIVATE_USE_AREA + opcode); return (char) (PRIVATE_USE_AREA + opcode);
@ -295,19 +295,19 @@ public final class InsnMatcher {
this.pattern = pattern; this.pattern = pattern;
} }
public Stream<List<AbstractInsnNode>> match(MethodNode method) { public Stream<ImmutableList<AbstractInsnNode>> match(MethodNode method) {
return match(method.instructions); return match(method.instructions);
} }
public Stream<List<AbstractInsnNode>> match(InsnList list) { public Stream<ImmutableList<AbstractInsnNode>> match(InsnList list) {
Stream.Builder<List<AbstractInsnNode>> matches = Stream.builder(); Stream.Builder<ImmutableList<AbstractInsnNode>> matches = Stream.builder();
var insns = createRealInsnList(list); var insns = createRealInsnList(list);
var matcher = pattern.matcher(createCodepointSeq(insns)); var matcher = pattern.matcher(createCodepointSeq(insns));
while (matcher.find()) { while (matcher.find()) {
var start = matcher.start(); var start = matcher.start();
var end = matcher.end(); var end = matcher.end();
matches.add(Collections.unmodifiableList(insns.subList(start, end))); matches.add(ImmutableList.copyOf(insns.subList(start, end)));
} }
return matches.build(); return matches.build();

@ -1,8 +1,6 @@
package dev.openrs2.asm.classpath; package dev.openrs2.asm.classpath;
import java.util.List; import com.google.common.collect.ImmutableList;
import java.util.stream.Collectors;
import dev.openrs2.asm.MemberDesc; import dev.openrs2.asm.MemberDesc;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
@ -42,24 +40,24 @@ public final class AsmClassMetadata extends ClassMetadata {
} }
@Override @Override
public List<ClassMetadata> getSuperInterfaces() { public ImmutableList<ClassMetadata> getSuperInterfaces() {
return clazz.interfaces.stream() return clazz.interfaces.stream()
.map(classPath::get) .map(classPath::get)
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override
public List<MemberDesc> getFields() { public ImmutableList<MemberDesc> getFields() {
return clazz.fields.stream() return clazz.fields.stream()
.map(f -> new MemberDesc(f.name, f.desc)) .map(f -> new MemberDesc(f.name, f.desc))
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override
public List<MemberDesc> getMethods() { public ImmutableList<MemberDesc> getMethods() {
return clazz.methods.stream() return clazz.methods.stream()
.map(m -> new MemberDesc(m.name, m.desc)) .map(m -> new MemberDesc(m.name, m.desc))
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override

@ -1,8 +1,8 @@
package dev.openrs2.asm.classpath; package dev.openrs2.asm.classpath;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.MemberDesc; import dev.openrs2.asm.MemberDesc;
public abstract class ClassMetadata { public abstract class ClassMetadata {
@ -10,9 +10,9 @@ public abstract class ClassMetadata {
public abstract boolean isDependency(); public abstract boolean isDependency();
public abstract boolean isInterface(); public abstract boolean isInterface();
public abstract ClassMetadata getSuperClass(); public abstract ClassMetadata getSuperClass();
public abstract List<ClassMetadata> getSuperInterfaces(); public abstract ImmutableList<ClassMetadata> getSuperInterfaces();
public abstract List<MemberDesc> getFields(); public abstract ImmutableList<MemberDesc> getFields();
public abstract List<MemberDesc> getMethods(); public abstract ImmutableList<MemberDesc> getMethods();
public abstract boolean isNative(MemberDesc method); public abstract boolean isNative(MemberDesc method);
@Override @Override

@ -1,13 +1,10 @@
package dev.openrs2.asm.classpath; package dev.openrs2.asm.classpath;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import dev.openrs2.asm.MemberDesc; import dev.openrs2.asm.MemberDesc;
import dev.openrs2.asm.MemberRef; import dev.openrs2.asm.MemberRef;
import dev.openrs2.util.collect.DisjointSet; import dev.openrs2.util.collect.DisjointSet;
@ -16,21 +13,21 @@ import org.objectweb.asm.tree.ClassNode;
public final class ClassPath { public final class ClassPath {
private final ClassLoader runtime; private final ClassLoader runtime;
private final List<Library> dependencies, libraries; private final ImmutableList<Library> dependencies, libraries;
private final Map<String, ClassMetadata> cache = new HashMap<>(); private final Map<String, ClassMetadata> cache = new HashMap<>();
public ClassPath(ClassLoader runtime, List<Library> dependencies, List<Library> libraries) { public ClassPath(ClassLoader runtime, ImmutableList<Library> dependencies, ImmutableList<Library> libraries) {
this.runtime = runtime; this.runtime = runtime;
this.dependencies = dependencies; this.dependencies = dependencies;
this.libraries = libraries; this.libraries = libraries;
} }
public List<Library> getLibraries() { public ImmutableList<Library> getLibraries() {
return libraries; return libraries;
} }
public List<ClassMetadata> getLibraryClasses() { public ImmutableList<ClassMetadata> getLibraryClasses() {
var classes = new ArrayList<ClassMetadata>(); var classes = ImmutableList.<ClassMetadata>builder();
for (var library : libraries) { for (var library : libraries) {
for (var clazz : library) { for (var clazz : library) {
@ -38,7 +35,7 @@ public final class ClassPath {
} }
} }
return Collections.unmodifiableList(classes); return classes.build();
} }
public ClassMetadata get(String name) { public ClassMetadata get(String name) {
@ -91,7 +88,7 @@ public final class ClassPath {
public DisjointSet<MemberRef> createInheritedFieldSets() { public DisjointSet<MemberRef> createInheritedFieldSets() {
var disjointSet = new ForestDisjointSet<MemberRef>(); var disjointSet = new ForestDisjointSet<MemberRef>();
var ancestorCache = new HashMap<ClassMetadata, Set<MemberDesc>>(); var ancestorCache = new HashMap<ClassMetadata, ImmutableSet<MemberDesc>>();
for (var library : libraries) { for (var library : libraries) {
for (var clazz : library) { for (var clazz : library) {
@ -102,12 +99,12 @@ public final class ClassPath {
return disjointSet; return disjointSet;
} }
private Set<MemberDesc> populateInheritedFieldSets(Map<ClassMetadata, Set<MemberDesc>> ancestorCache, DisjointSet<MemberRef> disjointSet, ClassMetadata clazz) { private ImmutableSet<MemberDesc> populateInheritedFieldSets(Map<ClassMetadata, ImmutableSet<MemberDesc>> ancestorCache, DisjointSet<MemberRef> disjointSet, ClassMetadata clazz) {
var ancestors = ancestorCache.get(clazz); var ancestors = ancestorCache.get(clazz);
if (ancestors != null) { if (ancestors != null) {
return ancestors; return ancestors;
} }
ancestors = new HashSet<>(); var ancestorsBuilder = ImmutableSet.<MemberDesc>builder();
var superClass = clazz.getSuperClass(); var superClass = clazz.getSuperClass();
if (superClass != null) { if (superClass != null) {
@ -119,7 +116,7 @@ public final class ClassPath {
disjointSet.union(partition1, partition2); disjointSet.union(partition1, partition2);
} }
ancestors.addAll(fields); ancestorsBuilder.addAll(fields);
} }
for (var superInterface : clazz.getSuperInterfaces()) { for (var superInterface : clazz.getSuperInterfaces()) {
@ -131,22 +128,22 @@ public final class ClassPath {
disjointSet.union(partition1, partition2); disjointSet.union(partition1, partition2);
} }
ancestors.addAll(fields); ancestorsBuilder.addAll(fields);
} }
for (var field : clazz.getFields()) { for (var field : clazz.getFields()) {
disjointSet.add(new MemberRef(clazz.getName(), field)); disjointSet.add(new MemberRef(clazz.getName(), field));
ancestors.add(field); ancestorsBuilder.add(field);
} }
ancestors = Collections.unmodifiableSet(ancestors); ancestors = ancestorsBuilder.build();
ancestorCache.put(clazz, ancestors); ancestorCache.put(clazz, ancestors);
return ancestors; return ancestors;
} }
public DisjointSet<MemberRef> createInheritedMethodSets() { public DisjointSet<MemberRef> createInheritedMethodSets() {
var disjointSet = new ForestDisjointSet<MemberRef>(); var disjointSet = new ForestDisjointSet<MemberRef>();
var ancestorCache = new HashMap<ClassMetadata, Set<MemberDesc>>(); var ancestorCache = new HashMap<ClassMetadata, ImmutableSet<MemberDesc>>();
for (var library : libraries) { for (var library : libraries) {
for (var clazz : library) { for (var clazz : library) {
@ -157,12 +154,12 @@ public final class ClassPath {
return disjointSet; return disjointSet;
} }
private Set<MemberDesc> populateInheritedMethodSets(Map<ClassMetadata, Set<MemberDesc>> ancestorCache, DisjointSet<MemberRef> disjointSet, ClassMetadata clazz) { private ImmutableSet<MemberDesc> populateInheritedMethodSets(Map<ClassMetadata, ImmutableSet<MemberDesc>> ancestorCache, DisjointSet<MemberRef> disjointSet, ClassMetadata clazz) {
var ancestors = ancestorCache.get(clazz); var ancestors = ancestorCache.get(clazz);
if (ancestors != null) { if (ancestors != null) {
return ancestors; return ancestors;
} }
ancestors = new HashSet<>(); var ancestorsBuilder = ImmutableSet.<MemberDesc>builder();
var superClass = clazz.getSuperClass(); var superClass = clazz.getSuperClass();
if (superClass != null) { if (superClass != null) {
@ -174,7 +171,7 @@ public final class ClassPath {
disjointSet.union(partition1, partition2); disjointSet.union(partition1, partition2);
} }
ancestors.addAll(methods); ancestorsBuilder.addAll(methods);
} }
for (var superInterface : clazz.getSuperInterfaces()) { for (var superInterface : clazz.getSuperInterfaces()) {
@ -186,15 +183,15 @@ public final class ClassPath {
disjointSet.union(partition1, partition2); disjointSet.union(partition1, partition2);
} }
ancestors.addAll(methods); ancestorsBuilder.addAll(methods);
} }
for (var method : clazz.getMethods()) { for (var method : clazz.getMethods()) {
disjointSet.add(new MemberRef(clazz.getName(), method)); disjointSet.add(new MemberRef(clazz.getName(), method));
ancestors.add(method); ancestorsBuilder.add(method);
} }
ancestors = Collections.unmodifiableSet(ancestors); ancestors = ancestorsBuilder.build();
ancestorCache.put(clazz, ancestors); ancestorCache.put(clazz, ancestors);
return ancestors; return ancestors;
} }

@ -2,9 +2,8 @@ package dev.openrs2.asm.classpath;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.MemberDesc; import dev.openrs2.asm.MemberDesc;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
@ -42,24 +41,24 @@ public final class ReflectionClassMetadata extends ClassMetadata {
} }
@Override @Override
public List<ClassMetadata> getSuperInterfaces() { public ImmutableList<ClassMetadata> getSuperInterfaces() {
return Arrays.stream(clazz.getInterfaces()) return Arrays.stream(clazz.getInterfaces())
.map(i -> classPath.get(i.getName().replace('.', '/'))) .map(i -> classPath.get(i.getName().replace('.', '/')))
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override
public List<MemberDesc> getFields() { public ImmutableList<MemberDesc> getFields() {
return Arrays.stream(clazz.getDeclaredFields()) return Arrays.stream(clazz.getDeclaredFields())
.map(f -> new MemberDesc(f.getName(), Type.getDescriptor(f.getType()))) .map(f -> new MemberDesc(f.getName(), Type.getDescriptor(f.getType())))
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override
public List<MemberDesc> getMethods() { public ImmutableList<MemberDesc> getMethods() {
return Arrays.stream(clazz.getDeclaredMethods()) return Arrays.stream(clazz.getDeclaredMethods())
.map(m -> new MemberDesc(m.getName(), Type.getMethodDescriptor(m))) .map(m -> new MemberDesc(m.getName(), Type.getMethodDescriptor(m)))
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
} }
@Override @Override

@ -4,15 +4,15 @@ import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.java.decompiler.main.Fernflower; import org.jetbrains.java.decompiler.main.Fernflower;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
public final class Decompiler implements Closeable { public final class Decompiler implements Closeable {
private static final Map<String, Object> OPTIONS = Map.of( private static final ImmutableMap<String, Object> OPTIONS = ImmutableMap.of(
IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1", IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1",
IFernflowerPreferences.INDENT_STRING, "\t", IFernflowerPreferences.INDENT_STRING, "\t",
IFernflowerPreferences.SYNTHETIC_NOT_SET, "1" IFernflowerPreferences.SYNTHETIC_NOT_SET, "1"
@ -32,7 +32,7 @@ public final class Decompiler implements Closeable {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
var deobOutput = Paths.get("nonfree/code/deob"); var deobOutput = Paths.get("nonfree/code/deob");
var sources = List.of( var sources = ImmutableList.of(
deobOutput.resolve("runescape_gl.jar"), deobOutput.resolve("runescape_gl.jar"),
deobOutput.resolve("jaggl.jar"), deobOutput.resolve("jaggl.jar"),
deobOutput.resolve("jaggl_dri.jar"), deobOutput.resolve("jaggl_dri.jar"),
@ -49,9 +49,9 @@ public final class Decompiler implements Closeable {
private final DecompilerIo io; private final DecompilerIo io;
private final Fernflower fernflower; private final Fernflower fernflower;
private final List<Path> sources; private final ImmutableList<Path> sources;
public Decompiler(List<Path> sources, Function<String, Path> destination) { public Decompiler(ImmutableList<Path> sources, Function<String, Path> destination) {
this.io = new DecompilerIo(destination); this.io = new DecompilerIo(destination);
this.fernflower = new Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger.INSTANCE); this.fernflower = new Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger.INSTANCE);
this.sources = sources; this.sources = sources;

@ -6,6 +6,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.classpath.ClassPath; import dev.openrs2.asm.classpath.ClassPath;
import dev.openrs2.asm.classpath.Library; import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer; import dev.openrs2.asm.transform.Transformer;
@ -102,9 +103,9 @@ public final class Deobfuscator {
/* bundle libraries together into a common classpath */ /* bundle libraries together into a common classpath */
var runtime = ClassLoader.getPlatformClassLoader(); var runtime = ClassLoader.getPlatformClassLoader();
var classPath = new ClassPath(runtime, List.of(), List.of(client, loader, signLink, unpack, unpacker)); var classPath = new ClassPath(runtime, ImmutableList.of(), ImmutableList.of(client, loader, signLink, unpack, unpacker));
var glClassPath = new ClassPath(runtime, List.of(gl, glDri), List.of(glClient, glLoader, glSignLink, glUnpack, glUnpacker)); var glClassPath = new ClassPath(runtime, ImmutableList.of(gl, glDri), ImmutableList.of(glClient, glLoader, glSignLink, glUnpack, glUnpacker));
var unsignedClassPath = new ClassPath(runtime, List.of(), List.of(unsignedClient)); var unsignedClassPath = new ClassPath(runtime, ImmutableList.of(), ImmutableList.of(unsignedClient));
/* deobfuscate */ /* deobfuscate */
logger.info("Transforming client"); logger.info("Transforming client");

@ -1,8 +1,8 @@
package dev.openrs2.deob.analysis; package dev.openrs2.deob.analysis;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import dev.openrs2.asm.InsnNodeUtils; import dev.openrs2.asm.InsnNodeUtils;
@ -200,7 +200,7 @@ public final class IntInterpreter extends Interpreter<IntValue> {
public IntValue naryOperation(AbstractInsnNode insn, List<? extends IntValue> values) throws AnalyzerException { public IntValue naryOperation(AbstractInsnNode insn, List<? extends IntValue> values) throws AnalyzerException {
var args = values.stream() var args = values.stream()
.map(IntValue::getBasicValue) .map(IntValue::getBasicValue)
.collect(Collectors.toUnmodifiableList()); .collect(ImmutableList.toImmutableList());
var basicValue = basicInterpreter.naryOperation(insn, args); var basicValue = basicInterpreter.naryOperation(insn, args);
if (basicValue == null) { if (basicValue == null) {
return null; return null;

@ -3,9 +3,9 @@ package dev.openrs2.deob.remap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import dev.openrs2.asm.MemberDesc; import dev.openrs2.asm.MemberDesc;
import dev.openrs2.asm.MemberRef; import dev.openrs2.asm.MemberRef;
import dev.openrs2.asm.classpath.ClassMetadata; import dev.openrs2.asm.classpath.ClassMetadata;
@ -20,21 +20,21 @@ import org.slf4j.LoggerFactory;
public final class TypedRemapper extends Remapper { public final class TypedRemapper extends Remapper {
private static final Logger logger = LoggerFactory.getLogger(TypedRemapper.class); private static final Logger logger = LoggerFactory.getLogger(TypedRemapper.class);
public static final Set<String> EXCLUDED_CLASSES = Set.of( public static final ImmutableSet<String> EXCLUDED_CLASSES = ImmutableSet.of(
"client", "client",
"jagex3/jagmisc/jagmisc", "jagex3/jagmisc/jagmisc",
"loader", "loader",
"unpack", "unpack",
"unpackclass" "unpackclass"
); );
private static final Set<String> EXCLUDED_METHODS = Set.of( private static final ImmutableSet<String> EXCLUDED_METHODS = ImmutableSet.of(
"<clinit>", "<clinit>",
"<init>", "<init>",
"main", "main",
"providesignlink", "providesignlink",
"quit" "quit"
); );
private static final Set<String> EXCLUDED_FIELDS = Set.of( private static final ImmutableSet<String> EXCLUDED_FIELDS = ImmutableSet.of(
"cache" "cache"
); );
private static final int MAX_OBFUSCATED_NAME_LEN = 2; private static final int MAX_OBFUSCATED_NAME_LEN = 2;

@ -1,7 +1,6 @@
package dev.openrs2.deob.transform; package dev.openrs2.deob.transform;
import java.util.Set; import com.google.common.collect.ImmutableSet;
import dev.openrs2.asm.InsnMatcher; import dev.openrs2.asm.InsnMatcher;
import dev.openrs2.asm.InsnNodeUtils; import dev.openrs2.asm.InsnNodeUtils;
import dev.openrs2.asm.classpath.ClassPath; import dev.openrs2.asm.classpath.ClassPath;
@ -16,7 +15,7 @@ public final class BitShiftTransformer extends Transformer {
private static final Logger logger = LoggerFactory.getLogger(BitShiftTransformer.class); private static final Logger logger = LoggerFactory.getLogger(BitShiftTransformer.class);
private static final InsnMatcher CONST_SHIFT_MATCHER = InsnMatcher.compile("(ICONST | BIPUSH | SIPUSH | LDC) (ISHL | ISHR | IUSHR | LSHL | LSHR | LUSHR)"); private static final InsnMatcher CONST_SHIFT_MATCHER = InsnMatcher.compile("(ICONST | BIPUSH | SIPUSH | LDC) (ISHL | ISHR | IUSHR | LSHL | LSHR | LUSHR)");
private static final Set<Integer> LONG_SHIFTS = Set.of(Opcodes.LSHL, Opcodes.LSHR, Opcodes.LUSHR); private static final ImmutableSet<Integer> LONG_SHIFTS = ImmutableSet.of(Opcodes.LSHL, Opcodes.LSHR, Opcodes.LUSHR);
private int simplified; private int simplified;

@ -3,6 +3,7 @@ package dev.openrs2.deob.transform;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import dev.openrs2.asm.transform.Transformer; import dev.openrs2.asm.transform.Transformer;
import dev.openrs2.deob.annotation.OriginalArg; import dev.openrs2.deob.annotation.OriginalArg;
import dev.openrs2.deob.annotation.OriginalClass; import dev.openrs2.deob.annotation.OriginalClass;
@ -16,13 +17,13 @@ import org.objectweb.asm.tree.MethodNode;
public final class OriginalNameTransformer extends Transformer { public final class OriginalNameTransformer extends Transformer {
private static AnnotationNode createOriginalClassAnnotation(String name) { private static AnnotationNode createOriginalClassAnnotation(String name) {
var annotation = new AnnotationNode(Type.getDescriptor(OriginalClass.class)); var annotation = new AnnotationNode(Type.getDescriptor(OriginalClass.class));
annotation.values = List.of("value", name); annotation.values = ImmutableList.of("value", name);
return annotation; return annotation;
} }
private static AnnotationNode createOriginalMemberAnnotation(String owner, String name, String desc) { private static AnnotationNode createOriginalMemberAnnotation(String owner, String name, String desc) {
var annotation = new AnnotationNode(Type.getDescriptor(OriginalMember.class)); var annotation = new AnnotationNode(Type.getDescriptor(OriginalMember.class));
annotation.values = List.of( annotation.values = ImmutableList.of(
"owner", owner, "owner", owner,
"name", name, "name", name,
"descriptor", desc "descriptor", desc
@ -32,7 +33,7 @@ public final class OriginalNameTransformer extends Transformer {
private static AnnotationNode createOriginalArgAnnotation(int index) { private static AnnotationNode createOriginalArgAnnotation(int index) {
var annotation = new AnnotationNode(Type.getDescriptor(OriginalArg.class)); var annotation = new AnnotationNode(Type.getDescriptor(OriginalArg.class));
annotation.values = List.of("value", index); annotation.values = ImmutableList.of("value", index);
return annotation; return annotation;
} }

Loading…
Cancel
Save