Skip to content
Permalink
Browse files

fix build error

  • Loading branch information...
pxb1988 committed Apr 2, 2018
1 parent 9b80989 commit ffd6e395b82d954a9cc31a793edb0266076e536c
@@ -53,14 +53,13 @@ public S(Class<?> klass) throws InitializationError {
List<Path> runners = new ArrayList<>();

public void init(final Class<?> testClass) throws InitializationError {
URL url = testClass.getResource("/" + testClass.getName().replace('.', '/') + ".class");
URL url = testClass.getResource("/jasmins/type.j");
Assert.assertNotNull(url);

final String file = url.getFile();
Assert.assertNotNull(file);
String dirx = file.substring(0, file.length() - testClass.getName().length() - ".class".length());

basePath = new File(dirx, "jasmins").toPath();
basePath = new File(file).toPath().getParent();

System.out.println("jasmins dir is " + basePath);

@@ -28,7 +28,9 @@
@Test
public void test() throws IOException {
DexFileNode dfn = new DexFileNode();
Smali.smaliFile(new File("src/test/resources/a.smali").toPath(), dfn);
try (InputStream is = SmaliTest.class.getResourceAsStream("/a.smali")) {
Smali.smaliFile("a.smali", is, dfn);
}
for (DexClassNode dcn : dfn.clzs) {
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
new BaksmaliDumper(true, true).baksmaliClass(dcn, new BaksmaliDumpOut(w));
@@ -49,19 +51,26 @@ public void test() throws IOException {

@Test
public void test2() throws IOException {
File dir=new File( "../dex-translator/src/test/resources/dexes");
File[]fs=dir.listFiles();
if(fs!=null) {
File dir = new File("../dex-translator/src/test/resources/dexes");
File[] fs = dir.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.getName().endsWith(".dex") || f.getName().endsWith(".apk")) {
System.out.println(f.getName());
dotest(f);
}
}
}
}

private void dotest(File dexFile) throws IOException {
DexBackedDexFile dex = DexFileFactory.loadDexFile(dexFile, 14, false);
DexBackedDexFile dex;
try {
dex = DexFileFactory.loadDexFile(dexFile, 14, false);
} catch (DexBackedDexFile.NotADexFile ex) {
ex.printStackTrace();
return;
}
Map<String, DexClassNode> map = readDex(dexFile);

for (DexBackedClassDef def : dex.getClasses()) {
@@ -56,7 +56,7 @@ public int compare(Local local, Local t1) {
public boolean transformReportChanged(IrMethod method) {
boolean changed = false;
List<AssignStmt> assignStmtList = new ArrayList<>();
Map<Local, Object> cstMap = new TreeMap<>(LOCAL_COMPARATOR);
Map<Local, Object> cstMap = new HashMap<>();
for (Stmt p = method.stmts.getFirst(); p != null; p = p.getNext()) {
if (p.st == Stmt.ST.ASSIGN) {
AssignStmt as = (AssignStmt) p;
@@ -74,7 +74,7 @@ public boolean transformReportChanged(IrMethod method) {
return false;
}
RemoveLocalFromSSA.fixReplace(cstMap);
final Map<Local, Value> toReplace = new TreeMap<>(LOCAL_COMPARATOR);
final Map<Local, Value> toReplace = new HashMap<>();
Set<Value> usedInPhi = new HashSet<>();
List<LabelStmt> phiLabels = method.phiLabels;
if (phiLabels != null) {
@@ -207,10 +207,17 @@ private boolean removeLoopFromPhi(List<LabelStmt> phiLabels, Map<Local, Local> t
}

static <T> void fixReplace(Map<Local, T> toReplace) {
TreeSet<Map.Entry<Local, T>> set = new TreeSet<>(new Comparator<Map.Entry<Local, T>>() {
@Override
public int compare(Map.Entry<Local, T> localTEntry, Map.Entry<Local, T> t1) {
return Integer.compare(localTEntry.getKey()._ls_index, t1.getKey()._ls_index);
}
});
set.addAll(toReplace.entrySet());
boolean changed = true;
while (changed) {
changed = false;
for (Map.Entry<Local, T> e : toReplace.entrySet()) {
for (Map.Entry<Local, T> e : set) {
T b = e.getValue();
if(b instanceof Local) {
T n = toReplace.get(b);
@@ -5,7 +5,6 @@ dependencies {
compile project(':dex-ir')
compile project(':d2j-base-cmd')
compile 'org.ow2.asm:asm-debug-all:5.0.3'
testCompile "com.google.android.tools:dx:23.0.0"
testCompile project(':d2j-smali')
testCompile project(':d2j-jasmin')
}
File renamed without changes.
@@ -58,23 +58,16 @@ public S(Class<?> klass) throws InitializationError {
List<Runner> runners;

public void init(final Class<?> testClass) throws InitializationError {
URL url = testClass.getResource("/" + testClass.getName().replace('.', '/') + ".class");
URL url = testClass.getResource("/smalis/writeString.smali");
System.out.println("url is " + url);
Assert.assertNotNull(url);

final String file = url.getFile();
Assert.assertNotNull(file);
String dirx = file.substring(0, file.length() - testClass.getName().length() - ".class".length());

System.out.println("dirx is " + dirx);
Path dirxpath = new File(dirx).toPath();
Path dirxpath = new File(file).toPath();

Path basePath0 = dirxpath.resolve("smalis");
if (!Files.exists(basePath0)) {
basePath0 = dirxpath.resolve("../resources/smalis/");
}

final Path basePath = basePath0;
final Path basePath = dirxpath.getParent();

final Set<Path> files = new TreeSet<>();
try {
@@ -18,6 +18,7 @@
import com.android.dx.cf.direct.DirectClassFile;
import com.android.dx.cf.direct.StdAttributeFactory;
import com.android.dx.cf.iface.ParseException;
import com.android.dx.command.dexer.DxContext;
import com.android.dx.dex.DexOptions;
import com.android.dx.dex.cf.CfOptions;
import com.android.dx.dex.cf.CfTranslator;
@@ -344,7 +345,7 @@ public ClassVisitor create(String classInternalName) {
dcf.setAttributeFactory(new StdAttributeFactory());
com.android.dx.dex.file.DexFile dxFile = new com.android.dx.dex.file.DexFile(dexOptions);
try {
CfTranslator.translate(dcf, data, cfOptions, dexOptions, dxFile);
CfTranslator.translate(new DxContext(), dcf, data, cfOptions, dexOptions, dxFile);
} catch (ParseException e) {
if ("MethodHandle not supported".equals(e.getMessage())) {
e.printStackTrace();

0 comments on commit ffd6e39

Please sign in to comment.
You can’t perform that action at this time.