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

If a method has a parameter which is a bounded wildcard the return type may not

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      java -version
      java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS 10.9.3
      Linux 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      this appears to be platform independent

      A DESCRIPTION OF THE PROBLEM :
      If a method has a parameter which is a bounded wildcard the return type may not be respected if a raw type is passed in.

      The below code results in this error:

             Reproducer.java:15: error: incompatible types: Object cannot be converted to Kind
              Kind a = LookupUtil.getMap(idAsList).get(id);

      Code:

              // if the list has a type witness, then the issue does not reproduce.
              //List<Number> idAsList = new ArrayList<Number>();
              List idAsList = new ArrayList<Number>();
              Kind a = LookupUtil.getMap(idAsList).get(id);


      REGRESSION. Last worked in version 7u60

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_60"
      Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
      Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      uncompress the attached archive. run the reproducer.sh script and the compiler error will reproduce.

      reproducer.sh, compiles the source in src and creates a jar file. it then tries to compiler Reproducer.java using the classes in the jar file.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the compile to succeed.
      ACTUAL -
      compiler error

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Reproducer.java:15: error: incompatible types: Object cannot be converted to Kind
              Kind a = LookupUtil.getMap(idAsList).get(id);
                                                      ^


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      don't use a raw type for the parameter

              Long id = 1L;
              List<Number> idAsList = new ArrayList<Number>();
              Kind a = LookupUtil.getMap(idAsList).get(id);


        Attachments

          Activity

            People

            • Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: