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

Wildcard capture reported incompatible with wildcard use

    Details

    • Subcomponent:
    • Introduced In Build:
      5.0
    • Introduced In Version:
      5.0
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b12)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b12, mixed mode, sharing)

      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux [machine name] 2.6.8.1-12mdk #1 Fri Oct 1 12:53:41 CEST 2004 i686 AMD Athlon(tm) XP 2400+ unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The error seems to say that wildcard use is incompatible with an identically-declared method result.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No error

      ACTUAL -
      Final1.java:5: incompatible types
      found : Agg<J,K,capture of ? extends Pair<J,K>>
      required: Agg<J,K,? extends Pair<J,K>>
                      Agg<J,K, ? extends Pair<J,K>> aggs = haver.getAgg();
                                                                       ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Collection;

      abstract class Test<J, K> {
      void have(Haver<J,K> haver) {
      Agg<J,K, ? extends Pair<J,K>> aggs = haver.getAgg();
      Collection<? extends Pair<J,K>> pairs = aggs.getPairs();
      for(final Pair<J,K> pair : pairs)
      System.out.println(pair);
      }
      }

      interface Pair<A,B> {
      A getA(); B getB();
      }

      interface Agg<C,D, E extends Pair<C,D>> {
      Collection<E> getPairs();
      }

      interface Haver<F,G> {
      Agg<F,G, ? extends Pair<F,G>> getAgg();
      }

      ---------- END SOURCE ----------

      Note that code is processed without error on a colleague's Eclipse, Nov. 10 integrated build Windows 2000
      ###@###.### 2004-12-13 23:18:01 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ahe Peter Ahe
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: