decompiler: fixed bytecode test

master
Egor.Ushakov 10 years ago
parent 32e7765874
commit 309aca1d29
  1. 9
      src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java
  2. 20
      testData/results/TestClassSimpleBytecodeMapping.dec

@ -1,9 +1,6 @@
package org.jetbrains.java.decompiler.main.collectors; package org.jetbrains.java.decompiler.main.collectors;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.jetbrains.java.decompiler.main.DecompilerContext; import org.jetbrains.java.decompiler.main.DecompilerContext;
@ -14,13 +11,13 @@ public class BytecodeSourceMapper {
private int offset_total; private int offset_total;
// class, method, bytecode offset, source line // class, method, bytecode offset, source line
private HashMap<String, HashMap<String, HashMap<Integer, Integer>>> mapping = new HashMap<String, HashMap<String, HashMap<Integer, Integer>>>(); private final HashMap<String, HashMap<String, HashMap<Integer, Integer>>> mapping = new LinkedHashMap<String, HashMap<String, HashMap<Integer, Integer>>>(); // need to preserve order
public void addMapping(String classname, String methodname, int bytecode_offset, int source_line) { public void addMapping(String classname, String methodname, int bytecode_offset, int source_line) {
HashMap<String, HashMap<Integer, Integer>> class_mapping = mapping.get(classname); HashMap<String, HashMap<Integer, Integer>> class_mapping = mapping.get(classname);
if(class_mapping == null) { if(class_mapping == null) {
mapping.put(classname, class_mapping = new HashMap<String, HashMap<Integer, Integer>>()); mapping.put(classname, class_mapping = new LinkedHashMap<String, HashMap<Integer, Integer>>()); // need to preserve order
} }
HashMap<Integer, Integer> method_mapping = class_mapping.get(methodname); HashMap<Integer, Integer> method_mapping = class_mapping.get(methodname);

@ -22,11 +22,14 @@ public class TestClassSimpleBytecodeMapping {
} }
} }
class pkg/TestClassSimpleBytecodeMapping{ class pkg/TestClassSimpleBytecodeMapping$1{
method run (Ljava/lang/Runnable;)V{ method run ()V{
1 20 0 7
3 7
5 7
} }
}
class pkg/TestClassSimpleBytecodeMapping{
method test ()I{ method test ()I{
0 4 0 4
3 4 3 4
@ -47,11 +50,8 @@ class pkg/TestClassSimpleBytecodeMapping{
2e 15 2e 15
2f 15 2f 15
} }
}
class pkg/TestClassSimpleBytecodeMapping$1{ method run (Ljava/lang/Runnable;)V{
method run ()V{ 1 20
0 7
3 7
5 7
} }
} }

Loading…
Cancel
Save