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) {
|
||||
for (String classPathDir: classPathDirs) {
|
||||
File file = new File(classPathDir, bootClassPathEntry);
|
||||
File file = null;
|
||||
DexFile dexFile = null;
|
||||
|
||||
if (!file.exists()) {
|
||||
boolean found = false;
|
||||
int extIndex = bootClassPathEntry.lastIndexOf(".");
|
||||
int extIndex = bootClassPathEntry.lastIndexOf(".");
|
||||
|
||||
String baseEntry;
|
||||
if (extIndex == -1) {
|
||||
baseEntry = bootClassPathEntry;
|
||||
String baseEntry;
|
||||
if (extIndex == -1) {
|
||||
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 {
|
||||
baseEntry = bootClassPathEntry.substring(0, extIndex);
|
||||
file = new File(classPathDir, baseEntry + ext);
|
||||
}
|
||||
|
||||
for (String ext: new String[]{".odex", ".jar", ".apk", ".zip"}) {
|
||||
String newEntry = baseEntry + ext;
|
||||
file = new File(classPathDir, newEntry);
|
||||
if (file.exists()) {
|
||||
found = true;
|
||||
break;
|
||||
if (file.exists()) {
|
||||
if (!file.canRead()) {
|
||||
System.err.println(String.format("warning: cannot open %s for reading. Will continue " +
|
||||
"looking.", file.getPath()));
|
||||
continue;
|
||||
}
|
||||
|
||||
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 (!file.canRead()) {
|
||||
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 + "\".");
|
||||
if (dexFile == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -305,7 +305,8 @@ public class DexFile
|
||||
zipFile = new ZipFile(file);
|
||||
ZipEntry zipEntry = zipFile.getEntry("classes.dex");
|
||||
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();
|
||||
if (fileLength < 40) {
|
||||
@ -866,4 +867,10 @@ public class DexFile
|
||||
bytes[10] = (byte) (sum >> 16);
|
||||
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