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

Compiler incorrectly reports "incompatible types" with valid extended type param

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_18"
      OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
      OpenJDK Server VM (build 14.0-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux btomasini-laptop 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The included code compiled just fine under JDK 6 but now fails under OpenJDK 6






      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected successful compilation
      ACTUAL -
      btomasini@btomasini-laptop:~$ javac Test.java
      Test.java:12: incompatible types
      found : java.lang.Object
      required: java.lang.String
      for (String string : newList(list)) {
      ^
      1 error

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Test
      {

          public void test()
          {
      List<String> list = new ArrayList<String>();

      for (String string : newList(list)) {
      }
          }

          private static <T, V extends T> List<T> newList(Collection<V> list)
          {
      return new ArrayList<T>(list);
          }


      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              abuckley Alex Buckley
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: