FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
Linux dev-dsk-teuliere-1a-i-eb43600c.eu-west-1.amazon.com 3.2.45-0.6.acc.624.45.283.amzn1acc.x86_64 #1 SMP Fri Nov 21 22:39:25 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Javac fails with an AssertionError when compiling some special files and asks me to submit a bug report.
Here is the exact output:
--------------------------
An exception has occurred in the compiler (1.8.0_77). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: typeSig ERROR
at com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:4796)
at com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:299)
at com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:342)
at com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:891)
at com.sun.tools.javac.jvm.ClassWriter.writeJavaAnnotations(ClassWriter.java:759)
at com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:628)
at com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1133)
at com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1603)
at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1693)
at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1621)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:746)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
--------------------------
I wrote a small shell script to generate some simple Java files (as small as I could make them) and to compile them, resulting in the error above. See the "Steps to reproduce" section below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following shell script can be used to reproduce the issue (explanations follow):
---------------------
#!/bin/sh
# Where to reproduce the bug. Do not choose an existing directory!
WORK_DIR=/tmp/javac-bug
# Configure the paths here
JAVA_HOME=/path/to/jdk1.8
FINDBUGS_JAR=/path/to/findbugs-3.0.0.jar
# Secondary variables
OUTPUT_DIR=$WORK_DIR/output
IMPORTED_FILE=$WORK_DIR/tmp/Foo.java
MAIN_FILE=$WORK_DIR/Bar.java
rm -rf $WORK_DIR
echo "Creating files"
# Create imported file
mkdir -p $WORK_DIR/tmp
cat > $IMPORTED_FILE << EOF
package tmp;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("Foo")
public class Foo {}
EOF
# Create main file
cat > $MAIN_FILE << EOF
import tmp.Foo;
public class Bar {
public static class InnerBar {
@edu.umd.cs.findbugs.annotations.SuppressWarnings("Bar")
public void bar() {}
}
}
EOF
# Compile
echo "Compiling $IMPORTED_FILE"
mkdir -p "$OUTPUT_DIR"
$JAVA_HOME/bin/javac -d "$OUTPUT_DIR" -classpath "$FINDBUGS_JAR" "$IMPORTED_FILE"
echo "Compiling $MAIN_FILE"
$JAVA_HOME/bin/javac -d "$OUTPUT_DIR" -classpath "$OUTPUT_DIR" "$MAIN_FILE"
---------------------
The script does the following:
* Set some variables (do not forget to update the first 4 variables to point to the appropriate location)
* Delete the "work directory" (used to create temporary files)
* Generate 2 simple classes (tmp.Foo and Bar)
* Compile them
Note that the first file is compiled with the FindBugs jar in its classpath, whereas the second one is compiled without. This seems to be crucial in order to reproduce the bug.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Instead of an internal error of the compiler, I expect either a successful compilation or a nice error message telling me what is wrong with my program :)
ACTUAL -
Full output:
---------------------
Creating files
Compiling /tmp/javac-bug/tmp/Foo.java
Note: /tmp/javac-bug/tmp/Foo.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Compiling /tmp/javac-bug/Bar.java
An exception has occurred in the compiler (1.8.0_77). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: typeSig ERROR
at com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:4796)
at com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:299)
at com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:342)
at com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:891)
at com.sun.tools.javac.jvm.ClassWriter.writeJavaAnnotations(ClassWriter.java:759)
at com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:628)
at com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1133)
at com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1603)
at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1693)
at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1621)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:746)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
---------------------
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.AssertionError: typeSig ERROR
at com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:4796)
at com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:299)
at com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:342)
at com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:891)
at com.sun.tools.javac.jvm.ClassWriter.writeJavaAnnotations(ClassWriter.java:759)
at com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:628)
at com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1133)
at com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1603)
at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1693)
at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1621)
at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:746)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1572)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1536)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
No log file is created.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
The script above generates 2 classes:
tmp/Foo.java:
---------------------
package tmp;
@edu.umd.cs.findbugs.annotations.SuppressWarnings("Foo")
public class Foo {}
---------------------
Bar.java:
---------------------
import tmp.Foo;
public class Bar {
public static class InnerBar {
@edu.umd.cs.findbugs.annotations.SuppressWarnings("Bar")
public void bar() {}
}
}
---------------------
Please refer to the script for the exact way to compile these files.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
When compiling the second class (Bar.java), adding the FindBugs jar in the classpath works. However, the stack trace does not give any clue as to what is happening (it took me hours to get to a minimal example like this one).
Also, I stumbled into this bug in at least 2 different programs.