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

REGRESSION:Casting the result of Collections.singleton doesn't work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 5.0
    • tools
    • x86
    • windows_xp


      ###@###.### 2004-05-12

      J2SE Version (please include all output from java -version flag):
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b50)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b50, mixed mode, sharing)

      Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2? Yes / No (pick one)
        no, works fine with build 48

      Operating System Configuration Information (be specific):
        WinXP

      Hardware Configuration Information (be specific):
        Dell Optiplex

      Bug Description:
        Before build 50, my code compiled, Now it doesn't; get the following
        compiler error (with extra white-space padding):

          [javac] C:\devel\GenericTest.java:11: incompatible types
          [javac] found : java.util.Iterator<GenericTest.Foo<capture of ? extends java.lang.String,capture of ? extends java.awt.Color>>
          [javac] required: java.util.Iterator<GenericTest.Foo< ? extends java.lang.String, ? extends java.awt.Color>>
          [javac] return Collections.singleton(symbol).iterator();


      Steps to Reproduce (be specific):

      Compile this code:

      import java.util.Iterator;
      import java.util.Collections;
      import java.awt.Color;

      public class GenericTest
      {
        Foo<? extends String, ? extends Color> symbol;

        public Iterator<Foo<? extends String, ? extends Color>> iterator()
        {
          return Collections.singleton(symbol).iterator();
        }

        public class Foo<A, B> {
        }
      }

      Casting the result of Collections.singleton doesn't seem to work,
      and nore does casting symbol.

            ahe Peter Ahe
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: