Have you ever crashed Javac?

I did -- tonight...

 

I didn't know (until Eclipse's QuickFix feature suggested it to me about a week ago) that this is valid:

for (@SuppressWarnings("unused") String fieldname : fieldnames) {
// some block where I didn't use 'fieldname' --
// I was more interested in doing it the right number of times, but without a counter variable
}

This works on Java 1.6.0_10-b33 as provided by Debian/Ubuntu.

But on Solaris Java 1.5.0_06-b05 (where my product has to be built every night) this was (apparently) an invalid place to put a @SuppressWarnings annotation. Makes the compiler barf:

[javac] An exception has occurred in the compiler (1.5.0_06).
Please file a bug at the Java Developer Connection
(http://java.sun.com/webapps/bugreport) after checking the Bug
Parade for duplicates. Include your program and the following
diagnostic in your report. Thank you.
[javac] java.lang.AssertionError: {unused}
[javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitArray(TreeMaker.java:634)
[javac] at com.sun.tools.javac.code.Attribute$Array.accept(Attribute.java:124)
[javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:637)
[javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.visitCompoundInternal(TreeMaker.java:628)
[javac] at com.sun.tools.javac.tree.TreeMaker$AnnotationBuilder.translate(TreeMaker.java:641)
[javac] at com.sun.tools.javac.tree.TreeMaker.Annotation(TreeMaker.java:649)
[javac] at com.sun.tools.javac.tree.TreeMaker.Annotations(TreeMaker.java:570)
[javac] at com.sun.tools.javac.tree.TreeMaker.VarDef(TreeMaker.java:554)
[javac] at com.sun.tools.javac.comp.Lower.visitIterableForeachLoop(Lower.java:2892)
[javac] at com.sun.tools.javac.comp.Lower.visitForeachLoop(Lower.java:2755)
...etc ...

The bug is described here and it's been fixed in a later version.

 

This is the fix (since there's no way we're going to push out the fixed compiler on dev/test AND production by March 31, which is when I would need it.

for ( String fieldname : fieldnames) {
// same old block
}

All that over trying to suppress a warning...