master
Stiver 10 years ago
parent c975f11ecc
commit 6d03229b91
  1. 14
      src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java
  2. BIN
      testData/classes/pkg/TestClassSimpleBytecodeMapping.class
  3. 36
      testData/results/TestClassSimpleBytecodeMapping.dec
  4. 20
      testData/src/pkg/TestClassSimpleBytecodeMapping.java

@ -1,6 +1,9 @@
package org.jetbrains.java.decompiler.main.collectors;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.jetbrains.java.decompiler.main.DecompilerContext;
@ -55,9 +58,14 @@ public class BytecodeSourceMapper {
}
buffer.appendIndent(1).append("method " + method_entry.getKey() + "{" + lineSeparator);
for(Entry<Integer, Integer> line : method_mapping.entrySet()) {
String strOffset = offsetsToHex ? Integer.toHexString(line.getKey()): line.getKey().toString();
buffer.appendIndent(2).append(strOffset).appendIndent(2).append((line.getValue() + offset_total) + lineSeparator);
List<Integer> lstBytecodeOffsets = new ArrayList<Integer>(method_mapping.keySet());
Collections.sort(lstBytecodeOffsets);
for(Integer offset : lstBytecodeOffsets) {
Integer line = method_mapping.get(offset);
String strOffset = offsetsToHex ? Integer.toHexString(offset): line.toString();
buffer.appendIndent(2).append(strOffset).appendIndent(2).append((line + offset_total) + lineSeparator);
}
buffer.appendIndent(1).append("}").appendLineSeparator();
is_first_method = false;

@ -0,0 +1,36 @@
package pkg;
public class TestClassSimpleBytecodeMapping {
public int test() {
System.out.println("before");
if(Math.random() > 0.0D) {
System.out.println("0");
return 0;
} else {
System.out.println("1");
return 1;
}
}
}
class test/TestClassSimpleBytecodeMapping{
method test ()I{
0 4
3 4
5 4
8 5
b 5
c 5
d 5
10 6
13 6
15 6
18 7
19 7
1a 9
1d 9
1f 9
22 10
23 10
}
}

@ -0,0 +1,20 @@
package pkg;
public class TestClassSimpleBytecodeMapping {
public TestClassSimpleBytecodeMapping() {}
public int test() {
System.out.println("before");
if(Math.random() > 0) {
System.out.println("0");
return 0;
} else {
System.out.println("1");
return 1;
}
}
}
Loading…
Cancel
Save