Problem
When running EISOP's NullnessChecker (or any checker using InitializationChecker) in a project where the compilation classpath resolves org.checkerframework:checker-qual from upstream typetools rather than EISOP's fork (for instance, when brought in transitively by a dependency), compilation aborts immediately during type factory initialization:
error: AnnotationBuilder: fromClass can't load class org.checkerframework.checker.initialization.qual.PolyInitialized
Is the class in checker-qual.jar?
Cause
In InitializationParentAnnotatedTypeFactory:
NOT_ONLY_INITIALIZED = AnnotationBuilder.fromClass(elements, NotOnlyInitialized.class);
POLY_INITIALIZED = AnnotationBuilder.fromClass(elements, PolyInitialized.class);
Upstream typetools checker-qual contains @Initialized, @UnderInitialization, @UnknownInitialization, and @FBCBottom, but lacks the EISOP-specific annotations @PolyInitialized (added in #494) and @NotOnlyInitialized. Because AnnotationBuilder.fromClass throws a compiler error when elements.getTypeElement(...) returns null, the checker cannot initialize.
Proposed Solution
Follow a graceful degradation pattern similar to #1906:
- Safely check if
PolyInitialized.class and NotOnlyInitialized.class exist on the compilation classpath before building their AnnotationMirrors.
- If missing, emit an informative diagnostic
NOTE once per run (e.g. informing the user that @PolyInitialized and @NotOnlyInitialized are unavailable without EISOP's checker-qual) and operate without those qualifier features.
- This will allow
NullnessChecker to seamlessly type-check projects using upstream typetools checker-qual on their compilation classpath.
Problem
When running EISOP's
NullnessChecker(or any checker usingInitializationChecker) in a project where the compilation classpath resolvesorg.checkerframework:checker-qualfrom upstream typetools rather than EISOP's fork (for instance, when brought in transitively by a dependency), compilation aborts immediately during type factory initialization:Cause
In
InitializationParentAnnotatedTypeFactory:Upstream typetools
checker-qualcontains@Initialized,@UnderInitialization,@UnknownInitialization, and@FBCBottom, but lacks the EISOP-specific annotations@PolyInitialized(added in #494) and@NotOnlyInitialized. BecauseAnnotationBuilder.fromClassthrows a compiler error whenelements.getTypeElement(...)returns null, the checker cannot initialize.Proposed Solution
Follow a graceful degradation pattern similar to #1906:
PolyInitialized.classandNotOnlyInitialized.classexist on the compilation classpath before building theirAnnotationMirrors.NOTEonce per run (e.g. informing the user that@PolyInitializedand@NotOnlyInitializedare unavailable without EISOP'schecker-qual) and operate without those qualifier features.NullnessCheckerto seamlessly type-check projects using upstream typetoolschecker-qualon their compilation classpath.