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

parameters containing nested generic types avoid recursive calls

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The following piece of code contains an error, but logically seems to be correct.
      ###
      import java.util.Map;

      class GenericsTest {
          <A> void a(Map<? super A, ? super A> map) {
              a(map);
          }
      }
      ###
      Logically, the method call should be fine. There is a generic type A defining the interdependency between the map's key and value type. But the argument used to call the method cannot be used to call it another time. javac produces the following output:
      ###
      [...]>javac GenericsTest.java
      GenericsTest.java:6: <A>a(java.util.Map<? super A,? super A>) in GenericsTest cannot be applied to (java.util.Map<capture of ? super A,capture of ? super A>)
                      a(map);
                      ^
      1 error
      ###

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Simply try to compile the following piece of code
      ###
      import java.util.Map;

      class GenericsTest {
          <A> void a(Map<? super A, ? super A> map) {
              a(map);
          }
      }
      ###


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Logically, the method call should be fine. There is a generic type A defining the interdependency between the map's key and value type.
      ACTUAL -
      The argument used to call the method cannot be used to call it another time. javac produces the following output:
      ###
      [...]>javac GenericsTest.java
      GenericsTest.java:6: <A>a(java.util.Map<? super A,? super A>) in GenericsTest cannot be applied to (java.util.Map<capture of ? super A,capture of ? super A>)
                      a(map);
                      ^
      1 error
      ###

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      GenericsTest.java:6: <A>a(java.util.Map<? super A,? super A>) in GenericsTest cannot be applied to (java.util.Map<capture of ? super A,capture of ? super A>)
                      a(map);
                      ^
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      class GenericsTest {
          <A> void a(Map<? super A, ? super A> map) {
              a(map);
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: