W
Wolfgang Jeltsch
Hello,
take the following file Bug.java:
import java.util.*;
public final class Bug<Item> {
public Bug(Collection<Item> items) {
for (Item item : items) {}
}
}
When compiling this with the JSR014 prototype version 2.2, the compiler
crashes with the following exception:
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)
I have created a hack which circumvents this problem by replacing all
occurences of foreach with iterator-based code. In order to use it, your
code must conform to the Java Code Conventions and there must not be any
spaces between the angle brackets (< and >) of generic parameters. No
compiler options are supported. There may be further limitations.
The code is a UNIX shell script so you need Cygwin or whatever under
Windows.
Put the following code in a file named javac and modify the string
<path-to-prototype> properly. Then give the file execution rights and
adjust your PATH variable in a way that this script is found instead of the
normal javac when entering javac on the command line.
#!/bin/sh
mv $1 $1.actual
sed -e 's/for .\([^ ]*\) \([_a-zA-Z]*\) : \(.*\). {/Iterator<\1>
_iterator = (\3).iterator(); while (_iterator.hasNext()) { final \1 \2 =
_iterator.next();/' < $1.actual > $1
/<path-to-prototype>/adding_generics-2_2-ea/scripts/javac $1
mv $1.actual $1
The 4th to 6th line are actually one line that only got splitted by my news
program.
Merry Christmas.
Wolfgang
take the following file Bug.java:
import java.util.*;
public final class Bug<Item> {
public Bug(Collection<Item> items) {
for (Item item : items) {}
}
}
When compiling this with the JSR014 prototype version 2.2, the compiler
crashes with the following exception:
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)
I have created a hack which circumvents this problem by replacing all
occurences of foreach with iterator-based code. In order to use it, your
code must conform to the Java Code Conventions and there must not be any
spaces between the angle brackets (< and >) of generic parameters. No
compiler options are supported. There may be further limitations.
The code is a UNIX shell script so you need Cygwin or whatever under
Windows.
Put the following code in a file named javac and modify the string
<path-to-prototype> properly. Then give the file execution rights and
adjust your PATH variable in a way that this script is found instead of the
normal javac when entering javac on the command line.
#!/bin/sh
mv $1 $1.actual
sed -e 's/for .\([^ ]*\) \([_a-zA-Z]*\) : \(.*\). {/Iterator<\1>
_iterator = (\3).iterator(); while (_iterator.hasNext()) { final \1 \2 =
_iterator.next();/' < $1.actual > $1
/<path-to-prototype>/adding_generics-2_2-ea/scripts/javac $1
mv $1.actual $1
The 4th to 6th line are actually one line that only got splitted by my news
program.
Merry Christmas.
Wolfgang