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

javac failure: incompatible types: cannot infer type arguments due to Object.hashCode collision

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 24
    • 8, 17, 18, 19, 20
    • tools
    • b22
    • x86
    • linux_ubuntu

      The bug is reproducible with Java 17, 18, 19, and 20-ea.
      Obejct.hashCode does not always collide, so the bug is not reproducible always, however, adding -XX:hashCode=2 makes the bug easier to reproduce.

      Step by step:

      {noformat}
      # install Java 20 from jdk.java.net
      git clone --depth=1 https://github.com/assertj/assertj-core.git
      cd assertj-core
      # This makes Object.hashCode return 1 always
      export _JAVA_OPTIONS="-XX:+UnlockExperimentalVMOptions -XX:hashCode=2"
      ./mvnw -V --no-transfer-progress -e verify
      {noformat}

      See sample failure: https://github.com/vlsi/assertj-core/runs/6919343594?check_suite_focus=true#step:5:61

      {noformat}
      Error: COMPILATION ERROR :
      [INFO] -------------------------------------------------------------
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/util/Lists.java:[64,36] no suitable method found for collect(java.util.stream.Collector<java.lang.Object,capture#1 of ?,java.util.Collection<java.lang.Object>>)
          method java.util.stream.Stream.<R>collect(java.util.function.Supplier<R>,java.util.function.BiConsumer<R,? super capture#2 of ? extends T>,java.util.function.BiConsumer<R,R>) is not applicable
            (cannot infer type-variable(s) R
              (actual and formal argument lists differ in length))
          method java.util.stream.Stream.<R,A>collect(java.util.stream.Collector<? super capture#2 of ? extends T,A,R>) is not applicable
            (inference variable C has incompatible bounds
              equality constraints: java.lang.Object,R,capture#2 of ? extends T
              upper bounds: java.lang.Object,java.util.Collection<T>)
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/util/Lists.java:[78,36] no suitable method found for collect(java.util.stream.Collector<java.lang.Object,capture#3 of ?,java.util.Collection<java.lang.Object>>)
          method java.util.stream.Stream.<R>collect(java.util.function.Supplier<R>,java.util.function.BiConsumer<R,? super capture#4 of ? extends T>,java.util.function.BiConsumer<R,R>) is not applicable
            (cannot infer type-variable(s) R
              (actual and formal argument lists differ in length))
          method java.util.stream.Stream.<R,A>collect(java.util.stream.Collector<? super capture#4 of ? extends T,A,R>) is not applicable
            (inference variable C has incompatible bounds
              equality constraints: java.lang.Object,R,capture#4 of ? extends T
              upper bounds: java.lang.Object,java.util.Collection<T>)
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/groups/FieldsOrPropertiesExtractor.java:[50,22] no suitable method found for extract(java.util.ArrayList<F>,java.util.function.Function<capture#5 of ? super F,T>)
          method org.assertj.core.groups.FieldsOrPropertiesExtractor.<F,T>extract(F[],java.util.function.Function<? super F,T>) is not applicable
            (cannot infer type-variable(s) F,T
              (argument mismatch; no instance(s) of type variable(s) T exist so that java.util.ArrayList<T> conforms to F[]))
          method org.assertj.core.groups.FieldsOrPropertiesExtractor.<F,T>extract(java.lang.Iterable<? extends F>,java.util.function.Function<? super F,T>) is not applicable
            (inference variable T has incompatible equality constraints T,F)
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/util/introspection/PropertySupport.java:[102,34] incompatible types: inference variable R has incompatible bounds
          equality constraints: java.lang.Object,A,T,A,RR
          upper bounds: java.util.List<T>,java.lang.Object
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/util/introspection/FieldSupport.java:[147,34] incompatible types: inference variable R has incompatible bounds
          equality constraints: java.lang.Object,A,T,A,RR
          upper bounds: java.util.List<T>,java.lang.Object
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[244,14] method assertHasOnlyOneElementSatisfying in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends T>,java.util.function.Consumer<? super T>
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Consumer<capture#6 of ? super T>
        reason: inference variable T has incompatible equality constraints T,capture#6 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[2835,49] no suitable method found for extract(java.util.List<T>,java.util.function.Function<capture#7 of ? super T,C>)
          method org.assertj.core.groups.FieldsOrPropertiesExtractor.<F,T>extract(F[],java.util.function.Function<? super F,T>) is not applicable
            (cannot infer type-variable(s) F,T
              (argument mismatch; no instance(s) of type variable(s) T exist so that java.util.List<T> conforms to F[]))
          method org.assertj.core.groups.FieldsOrPropertiesExtractor.<F,T>extract(java.lang.Iterable<? extends F>,java.util.function.Function<? super F,T>) is not applicable
            (inference variable T has incompatible equality constraints C,T)
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3214,42] incompatible types: cannot infer type arguments for org.assertj.core.api.AtomicReferenceArrayAssert<>
          reason: inference variable T has incompatible equality constraints T,T,capture#8 of ? extends T,E
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3253,42] incompatible types: cannot infer type arguments for org.assertj.core.api.AtomicReferenceArrayAssert<>
          reason: inference variable T has incompatible equality constraints T,T,capture#9 of ? extends T,E
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3339,14] method assertAllMatch in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Predicate<? super E>,org.assertj.core.presentation.PredicateDescription
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Predicate<capture#10 of ? super T>,org.assertj.core.presentation.PredicateDescription
        reason: inference variable E has incompatible equality constraints T,capture#10 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3374,14] method assertAllMatch in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Predicate<? super E>,org.assertj.core.presentation.PredicateDescription
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Predicate<capture#11 of ? super T>,org.assertj.core.presentation.PredicateDescription
        reason: inference variable E has incompatible equality constraints T,capture#11 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3440,14] method assertAllSatisfy in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Consumer<? super E>
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Consumer<capture#12 of ? super T>
        reason: inference variable E has incompatible equality constraints T,capture#12 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3468,14] method assertAnyMatch in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Predicate<? super E>,org.assertj.core.presentation.PredicateDescription
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Predicate<capture#13 of ? super T>,org.assertj.core.presentation.PredicateDescription
        reason: inference variable E has incompatible equality constraints T,capture#13 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3542,14] method assertAnySatisfy in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Consumer<? super E>
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Consumer<capture#14 of ? super T>
        reason: inference variable E has incompatible equality constraints T,capture#14 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3593,14] method assertNoneSatisfy in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Consumer<? super E>
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Consumer<capture#15 of ? super T>
        reason: inference variable E has incompatible equality constraints T,capture#15 of ? super T
      Error: /home/runner/work/assertj-core/assertj-core/src/main/java/org/assertj/core/api/AtomicReferenceArrayAssert.java:[3918,14] method assertNoneMatch in class org.assertj.core.internal.Iterables cannot be applied to given types;
        required: org.assertj.core.api.AssertionInfo,java.lang.Iterable<? extends E>,java.util.function.Predicate<? super E>,org.assertj.core.presentation.PredicateDescription
        found: org.assertj.core.api.WritableAssertionInfo,java.util.ArrayList<T>,java.util.function.Predicate<capture#16 of ? super T>,org.assertj.core.presentation.PredicateDescription
        reason: inference variable E has incompatible equality constraints T,capture#16 of ? super T
      ...
      {noformat}


      no error if the option is:
      export _JAVA_OPTIONS="-XX:+UnlockExperimentalVMOptions -XX:hashCode=1"

            vromero Vicente Arturo Romero Zaldivar
            vsitnikov Vladimir Sitnikov
            Votes:
            1 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: