Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19rc2 regression: Using ImmutableMutlimap and annotation processors fails compile on jdk6 #2173

Closed
jbgi opened this issue Sep 29, 2015 · 28 comments
Labels
Milestone

Comments

@jbgi
Copy link

jbgi commented Sep 29, 2015

The following test case fails on jdk6u45 (trigger a jdk6 bug probably fixed in jdk7). It happens as soon as an annotation processor is present in the classpath (not only auto-value).

package test;
import com.google.common.collect.ImmutableMultimap;
public final class Test {{
    ImmutableMultimap.class.toString();
}}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>guava-19rc2-regression</groupId>
    <artifactId>immutablemultimap</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0-rc2</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value</artifactId>
            <version>1.1</version>
            <optional>true</optional>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <compilerArgs combine.self="append">
                            <arg>-verbose</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
@jbgi
Copy link
Author

jbgi commented Sep 29, 2015

javac trace with 19rc2:

[parsing started E:\projects\immutablemultimap\src\main\java\test\Test.java]
[parsing completed 17ms]
[search path for source files: E:\projects\immutablemultimap\src\main\java,]
[search path for class files: C:\Program Files\Java\jdk1.6.0_45\jre\lib\resources.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\rt.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\sunrsasign.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jsse.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jce.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\charsets.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\modules\jdk.boot.jar,C:\Program Files\Java\jdk1.6.0_45\jre\classes,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\dnsns.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\localedata.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunjce_provider.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunmscapi.jar,E:\projects\immutablemultimap\target\classes,E:\projects\maven\maven-local-repo\com\google\guava\guava\19.0-rc2\guava-19.0-rc2.jar,E:\projects\maven\maven-local-repo\com\google\auto\value\auto-value\1.1\auto-value-1.1.jar,.]
[loading com\google\common\collect\ImmutableMultimap.class(com\google\common\collect:ImmutableMultimap.class)]
[loading com\google\common\annotations\GwtCompatible.class(com\google\common\annotations:GwtCompatible.class)]
[loading java\lang\annotation\Retention.class(java\lang\annotation:Retention.class)]
[loading java\lang\annotation\RetentionPolicy.class(java\lang\annotation:RetentionPolicy.class)]
[loading java\lang\annotation\Target.class(java\lang\annotation:Target.class)]
[loading java\lang\annotation\ElementType.class(java\lang\annotation:ElementType.class)]
An exception has occurred in the compiler (1.6.0_45). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
    at com.sun.tools.javac.code.Symbol$MethodSymbol.params(Symbol.java:1196)
    at com.sun.tools.javac.jvm.ClassReader.attachParameterAnnotations(ClassReader.java:1111)
    ...

@jbgi
Copy link
Author

jbgi commented Sep 29, 2015

javac trace with 19rc1:

[parsing started E:\projects\immutablemultimap\src\main\java\test\Test.java]
[parsing completed 13ms]
[search path for source files: E:\projects\immutablemultimap\src\main\java,]
[search path for class files: C:\Program Files\Java\jdk1.6.0_45\jre\lib\resources.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\rt.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\sunrsasign.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jsse.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jce.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\charsets.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\modules\jdk.boot.jar,C:\Program Files\Java\jdk1.6.0_45\jre\classes,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\dnsns.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\localedata.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunjce_provider.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunmscapi.jar,E:\projects\immutablemultimap\target\classes,E:\projects\maven\maven-local-repo\com\google\guava\guava\19.0-rc1\guava-19.0-rc1.jar,E:\projects\maven\maven-local-repo\com\google\auto\value\auto-value\1.1\auto-value-1.1.jar,.]
[loading com\google\common\collect\ImmutableMultimap.class(com\google\common\collect:ImmutableMultimap.class)]
[loading java\lang\Object.class(java\lang:Object.class)]
[loading com\google\common\annotations\GwtCompatible.class(com\google\common\annotations:GwtCompatible.class)]
[loading java\lang\annotation\Retention.class(java\lang\annotation:Retention.class)]
[loading java\lang\annotation\RetentionPolicy.class(java\lang\annotation:RetentionPolicy.class)]
[loading java\lang\annotation\Target.class(java\lang\annotation:Target.class)]
[loading java\lang\annotation\ElementType.class(java\lang\annotation:ElementType.class)]
Round 1:
    input files: {test.Test}
    annotations: []
    last round: false
Round 2:
    input files: {}
    annotations: []
    last round: true
[search path for source files: E:\projects\immutablemultimap\src\main\java,]
[search path for class files: C:\Program Files\Java\jdk1.6.0_45\jre\lib\resources.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\rt.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\sunrsasign.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jsse.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\jce.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\charsets.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\modules\jdk.boot.jar,C:\Program Files\Java\jdk1.6.0_45\jre\classes,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\dnsns.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\localedata.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunjce_provider.jar,C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext\sunmscapi.jar,E:\projects\immutablemultimap\target\classes,E:\projects\maven\maven-local-repo\com\google\guava\guava\19.0-rc1\guava-19.0-rc1.jar,E:\projects\maven\maven-local-repo\com\google\auto\value\auto-value\1.1\auto-value-1.1.jar,.]
[loading com\google\common\collect\ImmutableMultimap.class(com\google\common\collect:ImmutableMultimap.class)]
[loading java\lang\Object.class(java\lang:Object.class)]
[loading com\google\common\annotations\GwtCompatible.class(com\google\common\annotations:GwtCompatible.class)]
[loading java\lang\annotation\Retention.class(java\lang\annotation:Retention.class)]
[loading java\lang\annotation\RetentionPolicy.class(java\lang\annotation:RetentionPolicy.class)]
[loading java\lang\annotation\Target.class(java\lang\annotation:Target.class)]
[loading java\lang\annotation\ElementType.class(java\lang\annotation:ElementType.class)]
[checking test.Test]
[loading java\lang\Class.class(java\lang:Class.class)]
[loading java\lang\String.class(java\lang:String.class)]
[wrote E:\projects\immutablemultimap\target\classes\test\Test.class]
[total 525ms]

@jbgi
Copy link
Author

jbgi commented Sep 29, 2015

I suspect this is due to c62b07d

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

We assume that anyone who wants to compile Guava will do so with javac 7. That said, if anyone wants to propose a noninvasive fix, we could merge it.

@cpovirk cpovirk closed this as completed Sep 29, 2015
@eamonnmcmanus
Copy link
Member

This looks like this JDK bug but I think that should be fixed in the 1.6.0_45 version.

@cpovirk the issue occurs when compiling with Guava in the classpath, not when compiling Guava itself.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Oh, sorry, thanks. We should figure this out.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Thanks for the easy way of reproducing the problem.

I've tried backing out your suggested commit and everything else related to j2objc (c62b07d 9615497daa21fd9eba838949c52af979184fdf19 b21afd3bab31518b4a1c74784d3fd7f95783cb23 a02e1656a4be29fd6f8441f444c3b30cc62467c6 4fe1c9c76ba9e7a9cfd8073ab750a73404c685a0), but this didn't help. I'm kind of glad, since I don't know what we would do if that were the problem :) Not that I'm sure what we'll do, anyway.... I'll binary search from here.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

@cgruber, is it possible for us to configure Travis to run with Java 6?

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

The problem seems to be 26342f6.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Or maybe I'm doing git bisect wrong. Or maybe there's more than one problem commit.

@jbgi
Copy link
Author

jbgi commented Sep 29, 2015

@cpovirk I hope there is more to it than this commit, otherwise jdk6 javac is seriously fucked up!

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

From the sound of the bug Éamonn linked, I would guess that it is :) That one would at least be easy to fix :)

But I do think I got the commit wrong. I'm suspecting that I need to learn more about git bisect in the presence of branching/merging.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Actually, if I now rebuild 19.0-rc1, I get the failure there, too. The problem seems to be that we've upgraded the compiler on our workstations between when we built 19.0-rc1 and 19.0-rc2. Hermetic builds are overrated, so Maven doesn't care :-P

I'll see if we can build with an older compiler.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Yep, that's the problem. I've updated our release instructions to include building with an older JDK. We will do so for 19.0-rc3. @cgdecker as an FYI.

Thanks again for the report.

Ideally we would report this to Oracle, but I envision that a small enough example program will be painful to produce.

@cpovirk cpovirk closed this as completed Sep 29, 2015
@cpovirk cpovirk added this to the 19.0 milestone Sep 29, 2015
@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

A workaround:

diff --git a/guava/src/com/google/common/collect/ImmutableMultimap.java b/guava/src/com/google/common/collect/ImmutableMultimap.java
index 5790218..b75d6fb 100644
--- a/guava/src/com/google/common/collect/ImmutableMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableMultimap.java
@@ -696,4 +696,9 @@ public abstract class ImmutableMultimap<K, V> extends AbstractMultimap<K, V>
   }

   private static final long serialVersionUID = 0;
+
+  @Override
+  public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
+    return super.containsEntry(key, value);
+  }
 }

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

"Alternative" "fix" that would not be very helpful in practice:

diff --git a/guava/src/com/google/common/collect/AbstractMultimap.java b/guava/src/com/google/common/collect/AbstractMultimap.java
index 6b94c12..3d79361 100644
--- a/guava/src/com/google/common/collect/AbstractMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractMultimap.java
@@ -55,8 +55,7 @@ abstract class AbstractMultimap<K, V> implements Multimap<K, V> {

   @Override
   public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
-    Collection<V> collection = asMap().get(key);
-    return collection != null && collection.contains(value);
+    return false;
   }

   @Override

@jbgi
Copy link
Author

jbgi commented Sep 29, 2015

@cpovirk thanks for solving this!

@cgdecker
Copy link
Member

@cpovirk We might be able to configure Travis to use openjdk6 for something, but I'm not clear on what we'd do. We can't do the normal build/test we do on other JDKs because Guava just won't build on JDK6. And even if we could, is a build/test enough to catch this problem? Don't we need to build something else with guava + annotation processor on the classpath?

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

Sorry, I guess I still haven't quite accepted that this is a different problem than I initially thought. Ideally we would still have a regression test, but it would have to be more complex than I had expected, so it's probably not worthwhile.

@cpovirk
Copy link
Member

cpovirk commented Sep 29, 2015

I'm still trying to reproduce this without pulling in the whole of Guava.

@cpovirk
Copy link
Member

cpovirk commented Sep 30, 2015

I've managed to reproduce it. I'm not sure whether Oracle will feel the need to do anything, since Java 6 (and even Java 7) are no longer publicly updated, but maybe there's some chance that they'll view it as a bug in the Java 8 compiler. But I'm not feeling too lucky.

@jbgi , for what reason do you build with JDK6? We might be able to find workarounds, but I would be worried that we'll miss cases unless we invest a fair bit of time in hunting them all down.

@cpovirk
Copy link
Member

cpovirk commented Sep 30, 2015

(For example, the problem exists with all other public subclasses of AbstractMultimap, too: ArrayListMultimap, LinkedHashMultimap, LinkedListMultimap, HashMultimap.)

@jbgi
Copy link
Author

jbgi commented Sep 30, 2015

Unfortunately we still use jdk 6 in a number of projects at work (full migration to java 8 will not happen before Q2.2016). If this bug is not fixed then I guess we will just continue to use guava 18 until we migrate to java 8.
But then the guava readme will have to be updated to:

Requires JDK 1.7 or higher (as of 19.0).

@jbgi
Copy link
Author

jbgi commented Sep 30, 2015

I think it is worth openning a bug at openjdk. then, if it fixed, release a 19.1 that restore jdk6 compatibility.

@cpovirk
Copy link
Member

cpovirk commented Sep 30, 2015

Thanks.

I guess I'm focusing too much on the negatives: We do have the workaround of compiling 19.0 with an older javac, so we should be able to maintain compatibility.

@cgdecker
Copy link
Member

Ok, so if we just compile 19.0 on, say, openjdk7, the resulting artifact shouldn't have this problem when used with an annotation processor? Not something we want to have to keep doing long-term probably, but should certainly be able to do that for 19.0.

@cpovirk
Copy link
Member

cpovirk commented Sep 30, 2015

Yep. I previously claimed to have updated our Release Process instructions with the information about which specific JDK version I was having success with. But I realized that I hadn't saved the change to the page because I'd been planning to link to back to this thread. I did eventually make the change, but if you looked relatively shortly after I claimed to have made it, it wasn't there. It is now.

@jbgi
Copy link
Author

jbgi commented Dec 2, 2015

I confirm that I cannot reproduce the problem with 19.0-rc3. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants