summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/bytecode
diff options
context:
space:
mode:
authorGravatar jeff2015-01-19 22:22:57 -0500
committerGravatar jeff2015-01-19 22:22:57 -0500
commit2fbcf8e5c4eec0aa4a4fc59c7cc8abac33b1429c (patch)
tree0e9c23d6838d3e0299831dbc24b6d736c268cd8b /src/cuchaz/enigma/bytecode
parentadded inverse operation for moving classes out of the default package (diff)
downloadenigma-fork-2fbcf8e5c4eec0aa4a4fc59c7cc8abac33b1429c.tar.gz
enigma-fork-2fbcf8e5c4eec0aa4a4fc59c7cc8abac33b1429c.tar.xz
enigma-fork-2fbcf8e5c4eec0aa4a4fc59c7cc8abac33b1429c.zip
solved tricky issue with incorrect translation of fields/methods referenced by a subclass instead of the declaring class
Diffstat (limited to 'src/cuchaz/enigma/bytecode')
-rw-r--r--src/cuchaz/enigma/bytecode/ClassTranslator.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/bytecode/ClassTranslator.java b/src/cuchaz/enigma/bytecode/ClassTranslator.java
index 735a8fa..6441830 100644
--- a/src/cuchaz/enigma/bytecode/ClassTranslator.java
+++ b/src/cuchaz/enigma/bytecode/ClassTranslator.java
@@ -38,6 +38,7 @@ public class ClassTranslator {
38 } 38 }
39 39
40 public void translate(CtClass c) { 40 public void translate(CtClass c) {
41
41 // NOTE: the order of these translations is very important 42 // NOTE: the order of these translations is very important
42 43
43 // translate all the field and method references in the code by editing the constant pool 44 // translate all the field and method references in the code by editing the constant pool
@@ -45,7 +46,9 @@ public class ClassTranslator {
45 ConstPoolEditor editor = new ConstPoolEditor(constants); 46 ConstPoolEditor editor = new ConstPoolEditor(constants);
46 for (int i = 1; i < constants.getSize(); i++) { 47 for (int i = 1; i < constants.getSize(); i++) {
47 switch (constants.getTag(i)) { 48 switch (constants.getTag(i)) {
49
48 case ConstPool.CONST_Fieldref: { 50 case ConstPool.CONST_Fieldref: {
51
49 // translate the name 52 // translate the name
50 FieldEntry entry = new FieldEntry( 53 FieldEntry entry = new FieldEntry(
51 new ClassEntry(Descriptor.toJvmName(constants.getFieldrefClassName(i))), 54 new ClassEntry(Descriptor.toJvmName(constants.getFieldrefClassName(i))),
@@ -53,6 +56,11 @@ public class ClassTranslator {
53 ); 56 );
54 FieldEntry translatedEntry = m_translator.translateEntry(entry); 57 FieldEntry translatedEntry = m_translator.translateEntry(entry);
55 58
59 // TEMP
60 if (entry.toString().equals("none/bxq.m")) {
61 System.out.println("FIELD: " + entry + " -> " + translatedEntry);
62 }
63
56 // translate the type 64 // translate the type
57 String type = constants.getFieldrefType(i); 65 String type = constants.getFieldrefType(i);
58 String translatedType = m_translator.translateSignature(type); 66 String translatedType = m_translator.translateSignature(type);
@@ -65,6 +73,7 @@ public class ClassTranslator {
65 73
66 case ConstPool.CONST_Methodref: 74 case ConstPool.CONST_Methodref:
67 case ConstPool.CONST_InterfaceMethodref: { 75 case ConstPool.CONST_InterfaceMethodref: {
76
68 // translate the name and type 77 // translate the name and type
69 BehaviorEntry entry = BehaviorEntryFactory.create( 78 BehaviorEntry entry = BehaviorEntryFactory.create(
70 Descriptor.toJvmName(editor.getMemberrefClassname(i)), 79 Descriptor.toJvmName(editor.getMemberrefClassname(i)),