Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error message when the Findbugs jar is missing in the classpath #1079

Open
ipkiss42 opened this issue Apr 11, 2016 · 1 comment
Open

Comments

@ipkiss42
Copy link

Lombok fails with a non-intuitive error message when findbugs is missing in the classpath.

Here is a script to reproduce the bug, explanations follow:

#!/bin/sh

# Where to reproduce the bug. Do not choose an existing directory!
WORK_DIR=/tmp/lombok-bug
# Configure the paths here
JAVA_HOME=/path/to/jdk1.8
LOMBOK_JAR=/path/to/lombok.jar
FINDBUGS_JAR=/path/to/findbugs.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;

import lombok.Value;

@Value
public class Foo {}
EOF

# Create main file
cat > $MAIN_FILE << EOF
import tmp.Foo;
import lombok.Value;

@Value
public class Bar {}
EOF

# Create Lombok config file
echo "lombok.extern.findbugs.addSuppressFBWarnings = true" > $WORK_DIR/lombok.config

# Compile
echo "Compiling $IMPORTED_FILE"
mkdir -p "$OUTPUT_DIR"
$JAVA_HOME/bin/javac -d "$OUTPUT_DIR" -classpath "$FINDBUGS_JAR:$LOMBOK_JAR" "$IMPORTED_FILE"
echo "Compiling $MAIN_FILE"
$JAVA_HOME/bin/javac -d "$OUTPUT_DIR" -classpath "$OUTPUT_DIR:$LOMBOK_JAR" "$MAIN_FILE"

Note: to run the script, do not forget to update the 4 first variables appropriately.

The script creates 2 almost empty Java files (tmp.Foo and Bar). The first one is compiled with Findbugs in its classpath, but the second one is compiled without.
In addition, the script creates a lombok config file with lombok.extern.findbugs.addSuppressFBWarnings set to true.

The second file (Bar.java) imports the tmp.Foo class. When compiling it, javac is completely confused and thinks it has a bug. Here is the output of the script:

Creating files
Compiling /tmp/lombok-bug/tmp/Foo.java
Compiling /tmp/lombok-bug/Bar.java
warning: Error during the transformation of 'Bar'; post-compiler 'lombok.bytecode.PreventNullAnalysisRemover' caused an exception: java.lang.ArrayIndexOutOfBoundsException: 8
warning: Error during the transformation of 'Bar'; post-compiler 'lombok.bytecode.SneakyThrowsRemover' caused an exception: java.lang.ArrayIndexOutOfBoundsException: 8
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)

Instead of this cryptic message, the expected behavior is simple: Lombok should tell me that the Findbugs jar is missing in the classpath, ideally by outputting the FQCN of the Findbugs class that it expects to find in the classpath.

@eatdrinksleepcode
Copy link

Just hit this with lombok 1.16.8 while making some changes to my Gradle configuration. This was the only search result; if it hadn't been here, there's no telling how long it would have taken me to find, if I found it at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants