JDK-4898618 : extended 'for' with generic collections causes the compiler to crash
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.2_01,5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_2000
  • CPU: x86
  • Submitted: 2003-07-30
  • Updated: 2003-10-14
  • Resolved: 2003-10-14
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 b24Fixed
Related Reports
Duplicate :  
Duplicate :  
Description

Name: rmT116609			Date: 07/30/2003


FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

with adding_generics-2_2-ea

FULL OS VERSION :
Linux wolf.cl.cam.ac.uk 2.4.19-3cl #1 SMP Mon Nov 4 12:20:37 GMT 2002 i686 athlon i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
the following program causes the compiler to crash (this may be similar to bug  4881292 but the code show there compiles correctly with generics v2.2)



the result is

A

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached code.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the compiler doesn't crash
ACTUAL -
the compiler does crash


ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.4.1_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)
make: *** [Fuzzy.class] Error 4

Compilation exited abnormally with code 2 at Wed Jul 30 17:24:03

REPRODUCIBILITY :
This bug can be reproduced always.

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

class Fuzzy<T> {
    void main(String [] strings) {
	HashSet<T> buffer = new HashSet<T> ();
	for(T item : buffer)
	    ;
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
expand 'for' manually.  The following code works

import java.util.*;

class Fuzzy<T> {
    void main(String [] strings) {
	HashSet<T> buffer = new HashSet<T> ();
	Iterator<T> iter = buffer.iterator();
	while(iter.hasNext()) {
	    T item = iter.next();
	}
    }
}
(Incident Review ID: 193170) 
======================================================================

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

PUBLIC COMMENTS ...
10-06-2004

EVALUATION Since "Lower" is after "TransTypes", it should not generate generic types in its rewritings. ###@###.### 2003-07-30
30-07-2003