java-decompiler: test fix

This commit is contained in:
Roman Shevchenko 2014-10-17 20:14:28 +02:00
parent 3199686543
commit ce721c7acd
2 changed files with 17 additions and 13 deletions

View File

@ -29,7 +29,7 @@ public class BytecodeSourceMapper {
private final Map<String, Map<String, Map<Integer, Integer>>> mapping = new LinkedHashMap<String, Map<String, Map<Integer, Integer>>>();
// original line to decompiled line
private final Map<Integer, Integer> linesMapping = new LinkedHashMap<Integer, Integer>();
private final Map<Integer, Integer> linesMapping = new HashMap<Integer, Integer>();
public void addMapping(String className, String methodName, int bytecodeOffset, int sourceLine) {
Map<String, Map<Integer, Integer>> class_mapping = mapping.get(className);
@ -56,6 +56,10 @@ public class BytecodeSourceMapper {
}
public void dumpMapping(TextBuffer buffer, boolean offsetsToHex) {
if (mapping.isEmpty() && linesMapping.isEmpty()) {
return;
}
String lineSeparator = DecompilerContext.getNewLineSeparator();
for (Entry<String, Map<String, Map<Integer, Integer>>> class_entry : mapping.entrySet()) {
@ -91,9 +95,9 @@ public class BytecodeSourceMapper {
// lines mapping
buffer.append("Lines mapping:").appendLineSeparator();
int[] mapping = getOriginalLinesMapping();
for (int i = 0; i < mapping.length; i += 2) {
buffer.append(mapping[i]).append(" <-> ").append(mapping[i + 1]).appendLineSeparator();
Map<Integer, Integer> sorted = new TreeMap<Integer, Integer>(linesMapping);
for (Entry<Integer, Integer> entry : sorted.entrySet()) {
buffer.append(entry.getKey()).append(" <-> ").append(entry.getValue()).appendLineSeparator();
}
}

View File

@ -58,12 +58,12 @@ class 'pkg/TestClassSimpleBytecodeMapping' {
}
Lines mapping:
17 <-> 8
21 <-> 11
22 <-> 12
23 <-> 13
25 <-> 15
26 <-> 16
12 <-> 5
14 <-> 6
31 <-> 21
12 <-> 2
14 <-> 3
17 <-> 5
21 <-> 8
22 <-> 9
23 <-> 10
25 <-> 12
26 <-> 13
31 <-> 18