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

generic class method with vararg gets "java.lang.AssertionError: arraycode T"

XMLWordPrintable

    • b26
    • generic
    • generic

      /*
       * @test %W% %E% %I%
       * @summary no arrays of generic types
       * @compile/fail -source 1.5 badSyntax2.java
       */

      class Tclass<T>
      {
        T data;
        public Tclass(T... t){}
      }

      public class badSyntax2
      {
        String s = null;
        Tclass<String> tc = new Tclass<String>(s); //this gets Assertion
        public badSyntax2(){}

      }

      /*
      >javac -source 1.5 badSyntax2.java
      An exception has occurred in the compiler (1.5.0-auto-tiger). Please file a bug at the Java Develope
      r Connection (http://java.sun.com/cgi-bin/bugreport.cgi) after checking the Bug Parade for duplicat
      es. Include your program and the following diagnostic in your report. Thank you.
      java.lang.AssertionError: arraycode T
              at com.sun.tools.javac.jvm.Code.arraycode(Code.java:236)
              at com.sun.tools.javac.jvm.Gen.makeNewArray(Gen.java:1719)
              at com.sun.tools.javac.jvm.Gen.visitNewArray(Gen.java:1692)
              at com.sun.tools.javac.tree.Tree$NewArray.accept(Tree.java:817)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:792)
              at com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:810)
              at com.sun.tools.javac.jvm.Gen.visitNewClass(Gen.java:1682)
              at com.sun.tools.javac.tree.Tree$NewClass.accept(Tree.java:801)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:792)
              at com.sun.tools.javac.jvm.Gen.visitAssign(Gen.java:1736)
              at com.sun.tools.javac.tree.Tree$Assign.accept(Tree.java:843)
              at com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:792)
              at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1589)
              at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:694)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:639)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:674)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:660)
              at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:711)
              at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:952)
              at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:500)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:639)
              at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:674)
              at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:890)
              at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:832)
              at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:446)
              at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:639)
              at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2156)
              at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:316)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:455)
              at com.sun.tools.javac.main.Main.compile(Main.java:520)
              at com.sun.tools.javac.Main.compile(Main.java:41)
              at com.sun.tools.javac.Main.main(Main.java:32)
      */

            gafter Neal Gafter (Inactive)
            ssides Steve Sides
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: