ProGuard fails to process guava-10.0.jar

1,349 views
Skip to first unread message

Szabolcs Berecz

unread,
Oct 6, 2011, 12:53:33 PM10/6/11
to guava-discuss
Hi,

I have a problem with the guava 10.0 jar found in maven central:

Everything works fine (I'm using it on Android), but when I run
ProGuard on the jars, it fails to process guava-10.0.jar:

[2011-10-06 18:17:57 - combined_app] Proguard returned with error code
1. See console
[2011-10-06 18:17:57 - combined_app] Warning:
com.google.common.collect.MinMaxPriorityQueue: can't find referenced
field 'int UNSET_EXPECTED_SIZE' in class
com.google.common.collect.MinMaxPriorityQueue$Builder
[2011-10-06 18:17:57 - combined_app] You should check if you
need to specify additional program jars.
[2011-10-06 18:17:57 - combined_app] Warning: there were 1 unresolved
references to program class members.
[2011-10-06 18:17:57 - combined_app] Your input classes
appear to be inconsistent.
[2011-10-06 18:17:57 - combined_app] You may need to
recompile them and try again.
[2011-10-06 18:17:57 - combined_app] Alternatively, you may
have to specify the options
[2011-10-06 18:17:57 - combined_app]
'-dontskipnonpubliclibraryclasses' and/or
[2011-10-06 18:17:57 - combined_app]
'-dontskipnonpubliclibraryclassmembers'.
[2011-10-06 18:17:57 - combined_app] java.io.IOException: Please
correct the above warnings first.
[2011-10-06 18:17:57 - combined_app] at
proguard.Initializer.execute(Initializer.java:308)
[2011-10-06 18:17:57 - combined_app] at
proguard.ProGuard.initialize(ProGuard.java:210)
[2011-10-06 18:17:57 - combined_app] at
proguard.ProGuard.execute(ProGuard.java:85)
[2011-10-06 18:17:57 - combined_app] at
proguard.ProGuard.main(ProGuard.java:499)

The jar SHA1 Checksum matches with the one in maven central.

I've tried to rebuild guava, so I cloned the git repo, checked out
v10.0 and executed mvn install. It was not successful using OpenJDK
1.6.0_22:

/home/szabi/aaa/guava-libraries/guava/src/com/google/common/collect/SortedMaps.java:[219,48]
incompatible types; no instance(s) of type variable(s) K,V exist so
that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
found : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
/home/szabi/aaa/guava-libraries/guava/src/com/google/common/collect/SortedMaps.java:[220,49]
incompatible types; no instance(s) of type variable(s) K,V exist so
that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
found : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
/home/szabi/aaa/guava-libraries/guava/src/com/google/common/collect/SortedMaps.java:[222,44]
incompatible types; no instance(s) of type variable(s) K,V exist so
that java.util.TreeMap<K,V> conforms to java.util.SortedMap<K,V>
found : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
/home/szabi/aaa/guava-libraries/guava/src/com/google/common/collect/SortedMaps.java:[224,23]
incompatible types; no instance(s) of type variable(s) K,V exist so
that java.util.TreeMap<K,V> conforms to
java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>
found : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>

Switching to Sun java 1.6.0_26 solves this problem and the build is
successful. Also, the resulting jar can be processed using ProGuard.

So, the question is, are these problems expected? I can create a new
issue if it's any use.

Apart from this small glitch, it's an awesome work you do with guava!

Best regards,
Szabolcs Berecz

Kevin Bourrillion

unread,
Oct 6, 2011, 1:15:22 PM10/6/11
to Szabolcs Berecz, guava-discuss
On Thu, Oct 6, 2011 at 9:53 AM, Szabolcs Berecz <szabolc...@gmail.com> wrote:

Everything works fine (I'm using it on Android), but when I run
ProGuard on the jars, it fails to process guava-10.0.jar:

How interesting.  It appears to give warnings and then give you an error saying that you have to fix the warnings.  I actually laughed out loud a bit at that for some reason.


[2011-10-06 18:17:57 - combined_app] Warning:
com.google.common.collect.MinMaxPriorityQueue: can't find referenced
field 'int UNSET_EXPECTED_SIZE' in class
com.google.common.collect.MinMaxPriorityQueue$Builder

Huh.  It's like ProGuard does not understand about the mechanism by which classes access private fields of other classes that are defined in the same source file.  (Apparently synthetic setter/getter methods are created by... javac?  I'm not an expert in this stuff.)

ProGuard bug, maybe?

 

--
Kevin Bourrillion @ Google
Java Core Libraries Team
http://guava-libraries.googlecode.com

ray.j.greenwell

unread,
Oct 6, 2011, 8:08:10 PM10/6/11
to guava-discuss
On Oct 6, 10:15 am, Kevin Bourrillion <kev...@google.com> wrote:

>
> ProGuard bug, maybe?


I think so.

We had to add the following line to our proguard configuration file:

-dontwarn com.google.common.collect.MinMaxPriorityQueue

(We have not filed a bug with proguard.)

Eric Lafortune

unread,
Oct 12, 2011, 8:01:14 PM10/12/11
to guava-discuss
Not really a ProGuard bug, as far as I can see. The class
MinMaxPriorityQueue contains a straight reference to the private field
UNSET_EXPECTED_SIZEUNSET_EXPECTED_SIZE in its inner class Builder
(without any synthetic accessors). The reference isn't actually used
in the code, because the constant is inlined, but such a reference is
generally not allowed in bytecode. It seems like sloppiness of the
compiler. Which one are you guys using for the official releases? The
code looks and processes fine when compiled with Sun's JDK 1.6.

ProGuard has three levels of messages: notes, warnings, and errors. A
warning is an indication that the input looks wrong or incomplete,
potentially causing invalid output. By default, ProGuard then stops,
but the developer can tell ProGuard to ignore the warning if he
wishes.

Eric Lafortune
Developer of ProGuard
Reply all
Reply to author
Forward
0 new messages