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

Cast not allowed when both qualifying type and inner class are parameterized

    Details

    • Subcomponent:
    • Resolved In Build:
      b44
    • CPU:
      generic, x86
    • OS:
      generic, linux
    • Verification:
      Verified

      Description

      Description:
      Compiler throws error for what seems to be a valid cast to a type in which both the qualifying type and inner class are parameterized.

      <code>
      bash-3.00$
      <code>
      bash-3.00$ cat GenericOuter.java
      public class GenericOuter<S> {

          class GenericInner<T> extends LinkedList<T>{

          }
          public static void main(String...args){
             GenericOuter.GenericInner g1 = ( GenericOuter.GenericInner)new LinkedList<String>();
             GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
          }

      }


      </code>
      Compilation result is :
      <output>
      GenericOuter.java:8: ')' expected
             GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
                                                                                  ^
      GenericOuter.java:8: ';' expected
             GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
                                                                                   ^
      GenericOuter.java:8: illegal start of expression
             GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error

      </output>
      <version>
      /net/sqindia/export/disk09/jdk/7/latest/binaries/solsparc/bin/java -version
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b24)
      Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode)

      bash-3.00$ uname -a
      SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: