Repository navigation
[class-parse] Fix member-type and CheckForNull nullability - #13305
Merged
Merged
Conversation
Honor INNER_TYPE-only annotation paths without applying nested type annotations to their containers. Recognize javax and FindBugs CheckForNull contracts in null-marked scopes. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the nullability metadata changes.
No open issues 🎉
What changed in this PR
Fixes class-parse nullability metadata for member-type references and explicit @CheckForNull contracts inside @NullMarked scopes.
Changes:
- Accepts empty and
INNER_TYPE-only annotation paths without applying generic-argument or array-element nullability to their containers. - Recognizes both
javax.annotation.CheckForNulland FindBugsCheckForNull. - Adds nine regression cases covering fields, returns, and parameters.
| File | Description |
|---|---|
external/Java.Interop/tests/Xamarin.Android.Tools.Bytecode-Tests/JSpecifyAnnotationTests.cs |
Adds parameterized nullability assertions for nine cases. |
external/Java.Interop/tests/Xamarin.Android.Tools.Bytecode-Tests/java/javax/annotation/CheckForNull.java |
Adds the javax annotation test fixture. |
external/Java.Interop/tests/Xamarin.Android.Tools.Bytecode-Tests/java/edu/umd/cs/findbugs/annotations/CheckForNull.java |
Adds the FindBugs annotation test fixture. |
external/Java.Interop/tests/Xamarin.Android.Tools.Bytecode-Tests/java/com/jspecifytest/JSpecifyPackageMarked.java |
Adds member-type, generic, array, and annotation fixtures. |
external/Java.Interop/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs |
Recognizes both CheckForNull annotations as nullable. |
external/Java.Interop/src/Xamarin.Android.Tools.Bytecode/TypeAnnotation.cs |
Treats INNER_TYPE-only paths as applying to the reference itself. |
Review effort: Balanced
simonrozsival
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inside
@NullMarkedscopes, class-parse incorrectly marksOuter.@Nullable Innerreferences and explicit@CheckForNullcontracts as non-null. This affects fields, returns, and parameters.Accept empty or
INNER_TYPE-only annotation paths, while keeping annotations on generic arguments and array elements separate from container nullability. Recognize bothjavax.annotation.CheckForNullandedu.umd.cs.findbugs.annotations.CheckForNull.Fixes the member-type finding and CheckForNull finding from dotnet/java-interop#1509. That servicing PR is unchanged.
Added nine regression cases covering fields, returns, and parameters, including mixed member-type, generic, and array paths.
Tested after rebasing onto current main:
dotnet test external\Java.Interop\tests\Xamarin.Android.Tools.Bytecode-Tests\Xamarin.Android.Tools.Bytecode-Tests.csproj -v minimal -p:JavaCPath="$($env:JAVA_HOME)bin\javac.exe" -p:JarPath="$($env:JAVA_HOME)bin\jar.exe"— 107 passed, 2 skipped. The existing documentation tests requireANDROID_SDK_PATH, which is unset.git diff --check origin/main...HEAD— passed.