opprop / checker-framework-inference

Inference of pluggable types for Java
6 stars 13 forks source link

Fix crash when an interface contains an array literal #366

Closed d367wang closed 2 years ago

d367wang commented 2 years ago

Found a case that causes crash,

public interface Constants {
    String[] ACCESS_NAMES = {
        "public", "private", "protected", "static", "final", "synchronized",
        "volatile", "transient", "native", "interface", "abstract", "strictfp",
        "synthetic", "annotation", "enum"

    };
}

The reason is that in VariableAnnotator.annotateArrayLiteral, it firstly check if the array is an annotation element, by calling enclosedByAnnotation, which triggers NullPointerException when the array is declared in an interface.