Add the ability to specify an empty bootclasspath

This commit is contained in:
Ben Gruver 2016-09-18 14:24:34 -07:00
parent 1d26e1be09
commit 12a3d71759

View File

@ -32,6 +32,7 @@
package org.jf.baksmali; package org.jf.baksmali;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.jf.dexlib2.analysis.ClassPath; import org.jf.dexlib2.analysis.ClassPath;
import org.jf.dexlib2.analysis.ClassPathResolver; import org.jf.dexlib2.analysis.ClassPathResolver;
@ -54,10 +55,11 @@ public class AnalysisArguments {
public int apiLevel = 15; public int apiLevel = 15;
@Parameter(names = {"-b", "--bootclasspath", "--bcp"}, @Parameter(names = {"-b", "--bootclasspath", "--bcp"},
description = "A colon separated list of the files to include in the bootclasspath when analyzing the dex " + description = "A colon separated list of the files to include in the bootclasspath when analyzing the " +
"file. If not specified, baksmali will attempt to choose an " + "dex file. If not specified, baksmali will attempt to choose an " +
"appropriate default. When analyzing oat files, this can simply be the path to the device's " + "appropriate default. When analyzing oat files, this can simply be the path to the device's " +
"boot.oat file. See baksmali help classpath for more information.", "boot.oat file. A single empty string can be used to specify that an empty bootclasspath should " +
"be used. (e.g. --bootclasspath \"\") See baksmali help classpath for more information.",
splitter = ColonParameterSplitter.class) splitter = ColonParameterSplitter.class)
@ExtendedParameter(argumentNames = "classpath") @ExtendedParameter(argumentNames = "classpath")
public List<String> bootClassPath = null; public List<String> bootClassPath = null;
@ -105,6 +107,10 @@ public class AnalysisArguments {
// TODO: we should be able to get the api from the Opcodes object associated with the dexFile.. // TODO: we should be able to get the api from the Opcodes object associated with the dexFile..
// except that the oat version -> api mapping doesn't fully work yet // except that the oat version -> api mapping doesn't fully work yet
resolver = new ClassPathResolver(filteredClassPathDirectories, classPath, dexFile, apiLevel); resolver = new ClassPathResolver(filteredClassPathDirectories, classPath, dexFile, apiLevel);
} else if (bootClassPath.size() == 1 && bootClassPath.get(0).length() == 0) {
// --bootclasspath "" is a special case, denoting that no bootclasspath should be used
resolver = new ClassPathResolver(
ImmutableList.<String>of(), ImmutableList.<String>of(), classPath, dexFile);
} else { } else {
resolver = new ClassPathResolver(filteredClassPathDirectories, bootClassPath, classPath, dexFile); resolver = new ClassPathResolver(filteredClassPathDirectories, bootClassPath, classPath, dexFile);
} }