diff --git a/android/guava/pom.xml b/android/guava/pom.xml index f83ab7e0b068..826b88d18182 100644 --- a/android/guava/pom.xml +++ b/android/guava/pom.xml @@ -47,6 +47,16 @@ + + + .. + + LICENSE + proguard/* + + META-INF + + maven-jar-plugin diff --git a/guava/pom.xml b/guava/pom.xml index 150831cc8ae7..ccbcbd6cb3dd 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -47,6 +47,16 @@ + + + .. + + LICENSE + proguard/* + + META-INF + + maven-jar-plugin diff --git a/proguard/base.pro b/proguard/base.pro new file mode 100644 index 000000000000..d696db4dbf09 --- /dev/null +++ b/proguard/base.pro @@ -0,0 +1,33 @@ +# Note: We intentionally don't add the flags we'd need to make Flags and Enums +# work. That's because the Proguard configuration required to make them work on +# optimized code would preclude lots of optimization, like converting enums +# into ints. + +# Throwables uses internal APIs for lazy stack trace resolution +-dontnote sun.misc.SharedSecrets +-keep class sun.misc.SharedSecrets { + *** getJavaLangAccess(...); +} +-dontnote sun.misc.JavaLangAccess +-keep class sun.misc.JavaLangAccess { + *** getStackTraceElement(...); + *** getStackTraceDepth(...); +} + +# FinalizableReferenceQueue calls this reflectively +# Proguard is intelligent enough to spot the use of reflection onto this, so we +# only need to keep the names, and allow it to be stripped out if +# FinalizableReferenceQueue is unused. +-keepnames class com.google.common.base.internal.Finalizer { + *** startFinalizer(...); +} +# However, it cannot "spot" that this method needs to be kept IF the class is. +-keepclassmembers class com.google.common.base.internal.Finalizer { + *** startFinalizer(...); +} +-keepnames class com.google.common.base.FinalizableReference { + void finalizeReferent(); +} +-keepclassmembers class com.google.common.base.FinalizableReference { + void finalizeReferent(); +} diff --git a/proguard/cache.pro b/proguard/cache.pro new file mode 100644 index 000000000000..a67733b9ea33 --- /dev/null +++ b/proguard/cache.pro @@ -0,0 +1,12 @@ +# Striped64 uses this +-dontwarn sun.misc.Unsafe + +# Striped64 appears to make some assumptions about object layout that +# really might not be safe. This should be investigated. +-keepclassmembers class com.google.common.cache.Striped64 { + *** base; + *** busy; +} +-keepclassmembers class com.google.common.cache.Striped64$Cell { + ; +} diff --git a/proguard/collect.pro b/proguard/collect.pro new file mode 100644 index 000000000000..107706d2f484 --- /dev/null +++ b/proguard/collect.pro @@ -0,0 +1,34 @@ +-dontwarn java.lang.SafeVarargs + +# The nested FieldSettersHolder class looks these up. +# +# We use -keepclassmembernames because we want for ImmutableMultimap and its +# fields to be stripped if it's unused: -keepclassmembernames says that, *if* +# you're keeping the fields, you need to leave their names untouched. (Anyone +# who is using ImmutableMultimap will certainly be using its fields. So we +# don't need to worry that an ImmutableMultimap user will have the fields +# optimized away.) +# +# This configuration is untested.... +-keepclassmembernames class com.google.common.collect.ImmutableMultimap { + *** map; + *** size; +} +# similarly: +-keepclassmembernames class com.google.common.collect.ConcurrentHashMultiset { + *** countMap; +} +# similarly: +-keepclassmembernames class com.google.common.collect.ImmutableSetMultimap { + *** emptySet; +} +# similarly: +-keepclassmembernames class com.google.common.collect.AbstractSortedMultiset { + *** comparator; +} +# similarly: +-keepclassmembernames class com.google.common.collect.TreeMultiset { + *** range; + *** rootReference; + *** header; +} diff --git a/proguard/concurrent.pro b/proguard/concurrent.pro new file mode 100644 index 000000000000..a73c22a66e95 --- /dev/null +++ b/proguard/concurrent.pro @@ -0,0 +1,40 @@ +# Futures.getChecked, in both of its variants, is incompatible with proguard. + +# Used by AtomicReferenceFieldUpdater and sun.misc.Unsafe +-keepclassmembers class com.google.common.util.concurrent.AbstractFuture** { + *** waiters; + *** value; + *** listeners; + *** thread; + *** next; +} +-keepclassmembers class com.google.common.util.concurrent.AtomicDouble { + *** value; +} +-keepclassmembers class com.google.common.util.concurrent.AggregateFutureState { + *** remaining; + *** seenExceptions; +} + +# Since Unsafe is using the field offsets of these inner classes, we don't want +# to have class merging or similar tricks applied to these classes and their +# fields. It's safe to allow obfuscation, since the by-name references are +# already preserved in the -keep statement above. +-keep,allowshrinking,allowobfuscation class com.google.common.util.concurrent.AbstractFuture** { + ; +} + +# AbstractFuture uses this +-dontwarn sun.misc.Unsafe + +# MoreExecutors references AppEngine +-dontnote com.google.appengine.api.ThreadManager +-keep class com.google.appengine.api.ThreadManager { + static *** currentRequestThreadFactory(...); +} +-dontnote com.google.apphosting.api.ApiProxy +-keep class com.google.apphosting.api.ApiProxy { + static *** getCurrentEnvironment (...); +} + +-dontwarn java.lang.SafeVarargs diff --git a/proguard/hash.pro b/proguard/hash.pro new file mode 100644 index 000000000000..bc6f0adbcdf1 --- /dev/null +++ b/proguard/hash.pro @@ -0,0 +1,12 @@ +# LittleEndianByteArray uses this +-dontwarn sun.misc.Unsafe + +# Striped64 appears to make some assumptions about object layout that +# really might not be safe. This should be investigated. +-keepclassmembers class com.google.common.hash.Striped64 { + *** base; + *** busy; +} +-keepclassmembers class com.google.common.hash.Striped64$Cell { + ; +} diff --git a/proguard/io.pro b/proguard/io.pro new file mode 100644 index 000000000000..f0df3cc3cdf4 --- /dev/null +++ b/proguard/io.pro @@ -0,0 +1,3 @@ +-keep class java.lang.Throwable { + *** addSuppressed(...); +} diff --git a/proguard/primitives.pro b/proguard/primitives.pro new file mode 100644 index 000000000000..6968e0fa5894 --- /dev/null +++ b/proguard/primitives.pro @@ -0,0 +1,2 @@ +# UnsignedBytes uses this +-dontwarn sun.misc.Unsafe diff --git a/proguard/reflect.pro b/proguard/reflect.pro new file mode 100644 index 000000000000..620cbd3145dc --- /dev/null +++ b/proguard/reflect.pro @@ -0,0 +1,9 @@ +# Warning: common.reflect (like reflection in general) is typically slow and +# unreliable under Android. We do not recommend using it. This Proguard config +# exists only to avoid breaking the builds of users who already have +# common.reflect in their transitive dependencies. +# +-dontwarn com.google.common.reflect.Invokable +-dontwarn com.google.common.reflect.Invokable$ConstructorInvokable +-dontwarn com.google.common.reflect.Invokable$MethodInvokable +-dontwarn com.google.common.reflect.Parameter