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

false positive contradictory null annotations since 2024-03 #2226

Merged
merged 1 commit into from Mar 27, 2024

Conversation

stephan-herrmann
Copy link
Contributor

@stephan-herrmann stephan-herrmann commented Mar 26, 2024

fixes #2178

includes updates to enable using jclMin21.jar + src.zip

Also AbstractJavaModelTests was not ready for use the library stub, but that was needed for the test to trigger this bad path:

  • we add a synthetic "import static java.lang.StringTemplate.STR" with null annotations temporarily disabled
  • while resolving the field we need to resolve type java.lang.String
  • due to java/lang/String.eea we decorate a string method with @NonNull
  • this triggers the initial load of the NonNull annotation type
  • since null annotations are temporarily disabled, we skip the following assignment inside PackageBinding.checkIfAnalysisAnnotationType():
    type.typeBits |= TypeIds.BitNonNullAnnotation;
  • ergo: org.eclipse.jdt.annotation.NonNull is not known as a null annotation from which various "interesting" effects could follow.

I relation to #1513 (comment) I chose the second option:

... to encapsulate all fields of ImportBinding, so that we can use lazy initialization, but that would affect all locations accessing this class, so not a tiny change.

With that change, disabling null annotations (the "kludge" from #1513) is no longer necessary, the field STR is resolved only when needed, which restores proper null analysis.

fixes eclipse-jdt#2178

includes updates to enable using jclMin21.jar + src.zip
@stephan-herrmann stephan-herrmann merged commit 7b4acd1 into eclipse-jdt:master Mar 27, 2024
9 checks passed
@stephan-herrmann stephan-herrmann deleted the issue2178 branch March 27, 2024 23:31
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

Successfully merging this pull request may close these issues.

false positive contradictory null annotations since 2024-03
1 participant