typetools / typetools/checker-framework

Assertion failure for signature (and interning) checker: "root needs to be set when used on trees"

Open
#555 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

I've been unable to build the annotated BCEL 5.2 for nullness because of a few failures that produce the following message:

error: InvocationTargetException when invoking constructor for class org.checkerframework.checker.signature.SignatureAnnotatedTypeFactory; Underlying cause: java.lang.AssertionError: GenericAnnotatedTypeFactory.annotateImplicit: root needs to be set when used on trees; factory: class org.checkerframework.checker.signature.SignatureAnnotatedTypeFactory; invoke the compiler with -AprintErrorStack to see the stack trace.

Stack traces identify line 894 of GenericAnnotatedTypeFactory.java as the source of the error. To reproduce, using the Checker Framework compiler:

git clone https://github.com/typetools/commons-bcel bcel-5.2
cd bcel-5.2
git fetch origin
git checkout -b BCEL_5_2 origin/BCEL_5_2
ant
cd src/java
javac -source 1.7 -target 1.7 -processor signature -Awarns -AprintStackTrace \
        org/apache/bcel/generic/FieldOrMethod.java

For a smaller example, save the following source as Crash.java (still in bcel-5.2/src/java)

/*>>>
import org.checkerframework.checker.signature.qual.BinaryNameForNonArray;
import org.checkerframework.framework.qual.AnnotatedFor;
*/
/*@AnnotatedFor({"signature"})*/
public abstract class Crash {
    public /*@BinaryNameForNonArray*/ String getString() {
        return "";
    }
}

and compile with

javac -source 1.7 -target 1.7 -processor signature -Awarns -AprintStackTrace Crash.java

However, the same file can be compiled and checked with no crash if the classes produced from the same source are on the classpath, or if it is not on the source path. (Note that Crash.java contains no references to BCEL.) Hence, both of the javac invocations below succeed:

javac -cp ../../target/classes -source 1.7 -target 1.7 -processor signature -Awarns -AprintStackTrace Crash.java
cp Crash.java ..
cd ..
javac -source 1.7 -target 1.7 -processor signature -Awarns -AprintStackTrace Crash.java

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at line 894 of GenericAnnotatedTypeFactory.java and reproduce the failure with the signature processor using the BCEL FieldOrMethod.java command or the smaller Crash.java example. Compare the failing source-path case with the successful classpath cases; done means both reproductions compile without the assertion failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.