Make the checkPackagePrivateAccess functionality an option

This is only needed for 4.2.0, but not 4.2.1. Both are api 17, so we can't
tie this functionality to an api level.
This commit is contained in:
Ben Gruver 2014-12-28 15:03:02 -08:00 committed by Connor Tumbleson
parent 89e6b06521
commit 52482802dc
3 changed files with 12 additions and 6 deletions

View File

@ -211,6 +211,9 @@ public class main {
case 'e':
options.dexEntry = commandLine.getOptionValue("e");
break;
case 'k':
options.checkPackagePrivateAccess = true;
break;
case 'N':
disassemble = false;
break;
@ -241,10 +244,6 @@ public class main {
}
}
if (options.apiLevel == 17) {
options.checkPackagePrivateAccess = true;
}
String inputDexFileName = remainingArgs[0];
File dexFileFile = new File(inputDexFileName);
@ -430,6 +429,12 @@ public class main {
.withDescription("Don't use implicit (type-less) method and field references")
.create("t");
Option checkPackagePrivateAccessOption = OptionBuilder.withLongOpt("check-package-private-access")
.withDescription("When deodexing, use the package-private access check when calculating vtable " +
"indexes. It should only be needed for 4.2.0 odexes. The functionality was reverted for " +
"4.2.1.")
.create("k");
Option dumpOption = OptionBuilder.withLongOpt("dump-to")
.withDescription("dumps the given dex file into a single annotated dump file named FILE" +
" (<dexfile>.dump by default), along with the normal disassembly")
@ -477,6 +482,7 @@ public class main {
basicOptions.addOption(resourceIdFilesOption);
basicOptions.addOption(noImplicitReferencesOption);
basicOptions.addOption(dexEntryOption);
basicOptions.addOption(checkPackagePrivateAccessOption);
debugOptions.addOption(dumpOption);
debugOptions.addOption(ignoreErrorsOption);

View File

@ -164,7 +164,7 @@ public class ClassPath {
return unknownClass;
}
public boolean needCheckPackagePrivateAccess() {
public boolean shouldCheckPackagePrivateAccess() {
return checkPackagePrivateAccess;
}

View File

@ -628,7 +628,7 @@ public class ClassProto implements TypeProto {
for (int i=0; i<vtable.size(); i++) {
Method superMethod = vtable.get(i);
if (methodSignaturesMatch(superMethod, virtualMethod)) {
if (!classPath.needCheckPackagePrivateAccess() || canAccess(superMethod)) {
if (!classPath.shouldCheckPackagePrivateAccess() || canAccess(superMethod)) {
if (replaceExisting) {
vtable.set(i, virtualMethod);
}