Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4937353
Votes 0
Synopsis assertion fails: xClassName; generics+foreach
Category java:compiler
Reported Against 1.4.2_01
Release Fixed
State 11-Closed, duplicate of 4898618, bug
Priority: 4-Low
Related Bugs 4898618
Submit Date 14-OCT-2003
Description




FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

FULL OS VERSION :
 customer  Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
I am having a simple generic class wrapping a generic vector, see below.
The compiler crashes with an 'assertion failed' when writing code. If I replace the foreach loop with a semantically equivalent while loop and an iterator, it works fine.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
export J2SE14=c:/Programme/java/j2sdk1.4.2_01
export JSR14DISTR=c:/Programme/java/adding_generics-2_2-ea
$JSR14DISTR/scripts/javac Test.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compiled class file
ACTUAL -
compiler assertion fails

ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.4.2_01). Please file a bug at the Java Developer Connection (http://java.sun.com/cgi-bin/bugreport.cgi)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.

java.lang.AssertionError: xClassName

	at com.sun.tools.javac.jvm.ClassWriter.xClassName(ClassWriter.java:384)

	at com.sun.tools.javac.jvm.ClassWriter.writePool(ClassWriter.java:473)

	at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1002)

	at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:883)

	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)



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.Vector;

public class Test<Base> {
  private Vector<Base> columnsByIndex = new Vector<Base>();

  public void print() {
    // this loop will crash with a compiler error
    for(Base base : columnsByIndex) {
      //...
    }

    /**
    // this loop - which does the same thing - works
    java.util.Iterator<Base> bases = columnsByIndex.iterator();
    while (bases.hasNext()) {
      Base base = bases.next();
      // ...
    }
    */

  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
use the while loop
(Incident Review ID: 215657) 
======================================================================
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang