summaryrefslogtreecommitdiff
path: root/src/proguard/InputReader.java
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2017-11-10 14:20:59 +0000
committerPaul Duffin <paulduffin@google.com>2018-01-08 19:51:15 +0000
commit45e52b5ab37a26149ce031caa44bb167da217667 (patch)
tree61a3b7248024bbf31d1f180e9c2477696f042517 /src/proguard/InputReader.java
parente8bc3b2a283ea35317a8096dcf2c3d9959af40b2 (diff)
downloadproguard-45e52b5ab37a26149ce031caa44bb167da217667.tar.gz
Try and address the problem of using Proguard with applications that duplicate some classes in android.jar, e.g. applications that statically include junit. See https://sourceforge.net/p/proguard/discussion/182455/thread/76430d9e/ for more information. Rebuilt proguard with ant 1.10.1 and gradle 2.1 Bug: 30188076 Bug: 69156675 Test: make checkbuild Change-Id: I574becf07ed4a247e966f2c023e4b95b5ffc4011
Diffstat (limited to 'src/proguard/InputReader.java')
-rw-r--r--src/proguard/InputReader.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/proguard/InputReader.java b/src/proguard/InputReader.java
index 503ce7e..488b6ff 100644
--- a/src/proguard/InputReader.java
+++ b/src/proguard/InputReader.java
@@ -59,6 +59,28 @@ public class InputReader
DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter);
+ // Android-added: Read the classes from the systemjars.
+ // These are read into the library ClassPool before the programjars so that any duplicates
+ // between these are programjars will result in the classes in the programjars being
+ // ignored.
+ // Read the system class files, if any.
+ if (configuration.systemJars != null)
+ {
+ // Prepare a data entry reader to filter all classes,
+ // which are then decoded to classes by a class reader,
+ // which are then filtered by removing any that already exist in the libraryClassPool.
+ // which are then put in the class pool by a class pool filler.
+ readInput("Reading system ",
+ configuration.systemJars,
+ new ClassFilter(
+ new ClassReader(true /* isLibrary */,
+ configuration.skipNonPublicLibraryClasses,
+ configuration.skipNonPublicLibraryClassMembers,
+ warningPrinter,
+ new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter,
+ new ClassPoolFiller(libraryClassPool)))));
+ }
+
// Read the program class files.
// Prepare a data entry reader to filter all classes,
// which are then decoded to classes by a class reader,
@@ -71,7 +93,9 @@ public class InputReader
configuration.skipNonPublicLibraryClassMembers,
warningPrinter,
new ClassPresenceFilter(programClassPool, duplicateClassPrinter,
- new ClassPoolFiller(programClassPool)))));
+ // Android-changed: Filter out classes already read from systemjars.
+ new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter,
+ new ClassPoolFiller(programClassPool))))));
// Check if we have at least some input classes.
if (programClassPool.size() == 0)