Commit 0fff1a67 authored by Skylot's avatar Skylot

core: fix warning from dx library

parent d95d268e
......@@ -121,7 +121,8 @@ public class InputFile {
byte[] ba = j2d.convert(jarFile.getAbsolutePath());
if (ba.length == 0) {
throw new JadxException(j2d.isError() ? j2d.getDxErrors() : "Empty dx output");
} else if (j2d.isError()) {
}
if (j2d.isError()) {
LOG.warn("dx message: {}", j2d.getDxErrors());
}
return new Dex(ba);
......
......@@ -5,6 +5,7 @@ import jadx.core.utils.exceptions.JadxException;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import com.android.dx.command.DxConsole;
import com.android.dx.command.dexer.Main;
......@@ -23,6 +24,8 @@ public class JavaToDex {
optimize = true;
localInfo = true;
coreLibrary = true;
debug = true;
}
}
......@@ -40,6 +43,7 @@ public class JavaToDex {
try {
System.setOut(new PrintStream(baos, true, CHARSET_NAME));
DxArgs args = new DxArgs("-", new String[]{javaFile});
resetOutDexVar();
Main.run(args);
baos.close();
} catch (Throwable e) {
......@@ -56,11 +60,21 @@ public class JavaToDex {
return baos.toByteArray();
}
private void resetOutDexVar() throws JadxException {
try {
Field outputDex = Main.class.getDeclaredField("outputDex");
outputDex.setAccessible(true);
outputDex.set(null, null);
} catch (Exception e) {
throw new JadxException("Failed to reset outputDex field", e);
}
}
public String getDxErrors() {
return dxErrors;
}
public boolean isError() {
return dxErrors != null && dxErrors.length() > 0;
return dxErrors != null && !dxErrors.isEmpty();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment