Fix NPE when using a custom inline method table

This commit is contained in:
Ben Gruver 2014-01-29 19:39:34 -08:00 committed by Connor Tumbleson
parent 8aa0f31127
commit 838b35e477
3 changed files with 11 additions and 4 deletions

View File

@ -34,6 +34,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import org.jf.baksmali.Adaptors.ClassDefinition;
import org.jf.dexlib2.analysis.ClassPath;
import org.jf.dexlib2.analysis.CustomInlineMethodResolver;
import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.DexFile;
import org.jf.dexlib2.util.SyntheticAccessorResolver;
@ -67,6 +68,11 @@ public class baksmali {
options.classPath = ClassPath.fromClassPath(options.bootClassPathDirs,
Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile,
options.apiLevel);
if (options.customInlineDefinitions != null) {
options.inlineResolver = new CustomInlineMethodResolver(options.classPath,
options.customInlineDefinitions);
}
} catch (Exception ex) {
System.err.println("\n\nError occurred while loading boot class path files. Aborting.");
ex.printStackTrace(System.err);

View File

@ -36,6 +36,7 @@ import org.jf.dexlib2.analysis.ClassPath;
import org.jf.dexlib2.analysis.InlineMethodResolver;
import org.jf.dexlib2.util.SyntheticAccessorResolver;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -73,6 +74,7 @@ public class baksmaliOptions {
public boolean deodex = false;
public boolean ignoreErrors = false;
public boolean checkPackagePrivateAccess = false;
public File customInlineDefinitions = null;
public InlineMethodResolver inlineResolver = null;
public int registerInfo = 0;
public ClassPath classPath = null;

View File

@ -31,7 +31,6 @@ package org.jf.baksmali;
import com.google.common.collect.Lists;
import org.apache.commons.cli.*;
import org.jf.dexlib2.DexFileFactory;
import org.jf.dexlib2.analysis.CustomInlineMethodResolver;
import org.jf.dexlib2.analysis.InlineMethodResolver;
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.dexbacked.DexBackedOdexFile;
@ -217,7 +216,7 @@ public class main {
options.ignoreErrors = true;
break;
case 'T':
options.inlineResolver = new CustomInlineMethodResolver(options.classPath, new File(commandLine.getOptionValue("T")));
options.customInlineDefinitions = new File(commandLine.getOptionValue("T"));
break;
default:
assert false;
@ -270,7 +269,7 @@ public class main {
}
}
if (options.inlineResolver == null && dexFile instanceof DexBackedOdexFile) {
if (options.customInlineDefinitions == null && dexFile instanceof DexBackedOdexFile) {
options.inlineResolver =
InlineMethodResolver.createInlineMethodResolver(((DexBackedOdexFile)dexFile).getOdexVersion());
}
@ -529,4 +528,4 @@ public class main {
"/system/framework/apache-xml.jar");
}
}
}
}