typetools / typetools/checker-framework

Annotation not found in provided JUnit5 stub file

Open
#6,961 0 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

Working with checker-framework 3.48.4.
When configuring checker framework ti use provided JUnit5 stub (junit-assertions.astub), I have the following warning:
junit-assertions.astub:(line 56,col 2): Unknown annotation @EnsuresNonNull("#1").
Aside this warning, because the @EnsuresNonNull("#1") on assertNonNull is "not known", assertNonNull are not considered as ensuring non-nullness and my tests are not compiling.

I tried to copy the file in my project's resource folder, and specifying this folder in annotation processor -Astubs argument, and added the following missing import: import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
...but I get the same waning.

The warning is triggered by line 56 though my modified stub has the @EnsuresNonNull("#1") on line 57 because of the newly inserted import.

Thus :

  • I failed to override JUnit5 stub location, annotation processor is obviously working with embedded junit-assertions.astub instead of mine
  • an import is missing in JUnit5 stub; we sould insert import org.checkerframework.checker.nullness.qual.EnsuresNonNull; at line 13.

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 by locating the embedded junit-assertions.astub and reviewing how the annotation processor resolves the -Astubs option. Check the missing EnsuresNonNull import and the distinction between the embedded and project-provided stub, then verify that JUnit5 assertNonNull is recognized without the warning and provides the expected nullness information.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.