JDK-4901611 : generic class method with vararg gets "java.lang.AssertionError: arraycode T"
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-08-05
  • Updated: 2003-10-24
  • Resolved: 2003-10-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b26Fixed
Description
/*
 * @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)
*/

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b26 tiger-beta
2004-06-14

EVALUATION We need to give a better error message than crashing. However, in order for the type system to remain sound a varargs parameter cannot be a generic type or a type parameter. So this will be an error. ###@###.### 2003-08-05
2003-08-05