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

Tutorial on generic arrays tells to use an illegal construct

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6u15
    • 6u5
    • docs
    • a
    • x86
    • windows_vista
    • Not verified

      E:\alcatel\borsotti\jtest>java -version
      java version "1.6.0_05"
      Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

      Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
      Not known

      Operating System Configuration Information (be specific):

      Windows Vista
      SP1


      Hardware Configuration Information (be specific):

      AMD Athlon X2-64 2Gb RAM


      Bug Description:
      Tutorial on generic arrays tells to use an illegal construct.


      Steps to Reproduce (be specific):

      Compile this program:

      import java.util.*;

      class TutErr{
          List<String>[] lsa = new List<?>[10]; // Unchecked warning. This is unsafe!
      }

      E:\alcatel\borsotti\jtest>javac -Xlint:unchecked TutErr.java
      TutErr.java:3: incompatible types

      found : java.util.List<?>[]
      required: java.util.List<java.lang.String>[]
          List<String>[] lsa = new List<?>[10]; // Unchecked warning. This is unsafe!
                               ^
      1 error


      Java Tutorial, http://java.sun.com/docs/books/tutorial/extra/generics/fineprint.html,
      section "Arrays", presents this as a solution, and tells that the statement makes

      the compiler issue an "unckecked" warning, which is not tue since it issues an error
      (thereby preventing to run a program using this construct).

            sharonz Sharon Zakhour (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: