Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8166437

Regression in javac - inferring generic types in Guava

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2
    • 9
    • 9
    • tools

    Description

      # Prerequisites
      having git, maven installed.
      # Steps
      git clone https://github.com/google/guava.git
      mvn clean install

      Guava can be successfully built in jdk8, and jdk9.b12. It start to fail in jdk9.b13, different versions of jdk9 builds have different errors(for detailed information please check comments). It seems not the same issue as JDK-8160244/JDK-8165756.
      Below is the error messages in jdk9.b136 (for full log please check attachment and comments):

      [ERROR] /home/oracle/workspace/jdk/3rd.party.tools/guava/guava.jdk9/guava/src/com/google/common/collect/Collections2.java:[288,20] error: method all in class Iterables cannot be applied to given types;
      [ERROR]
          CAP#1 extends Object from capture of ?
          CAP#2 extends Object from capture of ?
      /home/oracle/workspace/jdk/3rd.party.tools/guava/guava.jdk9/guava/src/com/google/common/collect/Sets.java:[1188,50] error: incompatible types: ImmutableSet<CAP#1> cannot be converted to ImmutableSet<E>
      [ERROR]
          CAP#1 extends E from capture of ? extends E
      /home/oracle/workspace/jdk/3rd.party.tools/guava/guava.jdk9/guava/src/com/google/common/collect/Maps.java:[500,46] error: incompatible types: SortedMap<K,CAP#1> cannot be converted to Map<K,V>
      ..........(hide many error messages)............

      = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
      To reproduce the issue(first error reported in Collections2.java) in a simple scenario, below code(class hierarchy) is extracted from Guava, but the issue can not be reproduced.

      interface Predicate<T> {
      }

      class InPredicate<T> implements Predicate<T> {
          private final Collection<?> target;

          InPredicate(Collection<?> target) {
            this.target = target;
          }
      }

      final class Iterables {
      public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate) {
      return true;
      }
      }

      final class Predicates {
      public static <T> Predicate<T> in(Collection<? extends T> target) {
      return new InPredicate<T>(target);
      }
      }

      final class Collections2 {
      static boolean containsAllImpl(Collection<?> self, Collection<?> c) {
      return Iterables.all((Iterable<?>) c, Predicates.in(self));
      }
      }

      Attachments

        Issue Links

          Activity

            People

              dlsmith Dan Smith
              mli Hamlin Li
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: