mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 00:54:25 +02:00
When loading boot class path files, if a jar file doesn't have a classes.dex file, skip it and continue looking
git-svn-id: https://smali.googlecode.com/svn/trunk@670 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
8eaecd53d3
commit
cf52e5cd48
@ -93,42 +93,44 @@ public class ClassPath {
|
|||||||
|
|
||||||
private void loadBootClassPath(String[] classPathDirs, String bootClassPathEntry) {
|
private void loadBootClassPath(String[] classPathDirs, String bootClassPathEntry) {
|
||||||
for (String classPathDir: classPathDirs) {
|
for (String classPathDir: classPathDirs) {
|
||||||
File file = new File(classPathDir, bootClassPathEntry);
|
File file = null;
|
||||||
|
DexFile dexFile = null;
|
||||||
|
|
||||||
if (!file.exists()) {
|
int extIndex = bootClassPathEntry.lastIndexOf(".");
|
||||||
boolean found = false;
|
|
||||||
int extIndex = bootClassPathEntry.lastIndexOf(".");
|
|
||||||
|
|
||||||
String baseEntry;
|
String baseEntry;
|
||||||
if (extIndex == -1) {
|
if (extIndex == -1) {
|
||||||
baseEntry = bootClassPathEntry;
|
baseEntry = bootClassPathEntry;
|
||||||
|
} else {
|
||||||
|
baseEntry = bootClassPathEntry.substring(0, extIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ext: new String[]{"", ".odex", ".jar", ".apk", ".zip"}) {
|
||||||
|
if (ext.length() == 0) {
|
||||||
|
file = new File(classPathDir, bootClassPathEntry);
|
||||||
} else {
|
} else {
|
||||||
baseEntry = bootClassPathEntry.substring(0, extIndex);
|
file = new File(classPathDir, baseEntry + ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String ext: new String[]{".odex", ".jar", ".apk", ".zip"}) {
|
if (file.exists()) {
|
||||||
String newEntry = baseEntry + ext;
|
if (!file.canRead()) {
|
||||||
file = new File(classPathDir, newEntry);
|
System.err.println(String.format("warning: cannot open %s for reading. Will continue " +
|
||||||
if (file.exists()) {
|
"looking.", file.getPath()));
|
||||||
found = true;
|
continue;
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
dexFile = new DexFile(file, false, true);
|
||||||
|
} catch (DexFile.NoClassesDexException ex) {
|
||||||
|
continue;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw ExceptionWithContext.withContext(ex, "Error while reading boot class path entry \"" +
|
||||||
|
bootClassPathEntry + "\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (dexFile == null) {
|
||||||
if (!file.canRead()) {
|
continue;
|
||||||
throw new ExceptionWithContext("Cannot read ClassPath entry \"" + bootClassPathEntry + "\".");
|
|
||||||
}
|
|
||||||
|
|
||||||
DexFile dexFile;
|
|
||||||
try {
|
|
||||||
dexFile = new DexFile(file, false, true);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw ExceptionWithContext.withContext(ex, "Error while reading boot class path entry \"" +
|
|
||||||
bootClassPathEntry + "\".");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -305,7 +305,8 @@ public class DexFile
|
|||||||
zipFile = new ZipFile(file);
|
zipFile = new ZipFile(file);
|
||||||
ZipEntry zipEntry = zipFile.getEntry("classes.dex");
|
ZipEntry zipEntry = zipFile.getEntry("classes.dex");
|
||||||
if (zipEntry == null) {
|
if (zipEntry == null) {
|
||||||
throw new RuntimeException("zip file " + file.getName() + " does not contain a classes.dex file");
|
throw new NoClassesDexException("zip file " + file.getName() + " does not contain a classes.dex " +
|
||||||
|
"file");
|
||||||
}
|
}
|
||||||
fileLength = zipEntry.getSize();
|
fileLength = zipEntry.getSize();
|
||||||
if (fileLength < 40) {
|
if (fileLength < 40) {
|
||||||
@ -866,4 +867,10 @@ public class DexFile
|
|||||||
bytes[10] = (byte) (sum >> 16);
|
bytes[10] = (byte) (sum >> 16);
|
||||||
bytes[11] = (byte) (sum >> 24);
|
bytes[11] = (byte) (sum >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class NoClassesDexException extends ExceptionWithContext {
|
||||||
|
public NoClassesDexException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user