United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4901611 : generic class method with vararg gets "java.lang.AssertionError: arraycode T"

Details
Type:
Bug
Submit Date:
2003-08-05
Status:
Resolved
Updated Date:
2003-10-24
Project Name:
JDK
Resolved Date:
2003-10-24
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b26)

Related Reports

Sub Tasks

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



Hardware and Software, Engineered to Work Together