summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/bytecode
diff options
context:
space:
mode:
authorGravatar Gegy2019-02-19 21:00:43 +0200
committerGravatar GitHub2019-02-19 21:00:43 +0200
commitc0b0388aae76d39d780c2b4ad2531feb9d633e62 (patch)
tree92ed3273d7961c2309c732d39cebd99e687a1532 /src/main/java/cuchaz/enigma/bytecode
parentAdded Basic Search (#102) (diff)
downloadenigma-fork-c0b0388aae76d39d780c2b4ad2531feb9d633e62.tar.gz
enigma-fork-c0b0388aae76d39d780c2b4ad2531feb9d633e62.tar.xz
enigma-fork-c0b0388aae76d39d780c2b4ad2531feb9d633e62.zip
Bridge Method Fixes (#111)
* Detect synthetic bridges not marked as bridges, and add back flags to produced bytecode * Remove debug check * Remove more test code * Remove unneeded change to `TranslationClassVisitor`
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode')
-rw-r--r--src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java b/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java
new file mode 100644
index 0000000..99eef6a
--- /dev/null
+++ b/src/main/java/cuchaz/enigma/bytecode/translators/SourceFixVisitor.java
@@ -0,0 +1,43 @@
1package cuchaz.enigma.bytecode.translators;
2
3import cuchaz.enigma.analysis.index.BridgeMethodIndex;
4import cuchaz.enigma.analysis.index.JarIndex;
5import cuchaz.enigma.translation.representation.entry.ClassDefEntry;
6import cuchaz.enigma.translation.representation.entry.MethodDefEntry;
7import cuchaz.enigma.translation.representation.entry.MethodEntry;
8import org.objectweb.asm.ClassVisitor;
9import org.objectweb.asm.MethodVisitor;
10import org.objectweb.asm.Opcodes;
11
12public class SourceFixVisitor extends ClassVisitor {
13 private final JarIndex index;
14 private ClassDefEntry ownerEntry;
15
16 public SourceFixVisitor(int api, ClassVisitor visitor, JarIndex index) {
17 super(api, visitor);
18 this.index = index;
19 }
20
21 @Override
22 public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
23 ownerEntry = ClassDefEntry.parse(access, name, signature, superName, interfaces);
24 super.visit(version, access, name, signature, superName, interfaces);
25 }
26
27 @Override
28 public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
29 MethodDefEntry methodEntry = MethodDefEntry.parse(ownerEntry, access, name, descriptor, signature);
30
31 BridgeMethodIndex bridgeIndex = index.getBridgeMethodIndex();
32 if (bridgeIndex.isBridgeMethod(methodEntry)) {
33 access |= Opcodes.ACC_BRIDGE;
34 } else {
35 MethodEntry bridgeMethod = bridgeIndex.getBridgeFromAccessed(methodEntry);
36 if (bridgeMethod != null) {
37 name = bridgeMethod.getName();
38 }
39 }
40
41 return super.visitMethod(access, name, descriptor, signature, exceptions);
42 }
43}