From eddf0587c3807cddf2150157a59036094c757b08 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 23 Jul 2025 12:05:09 -0500 Subject: [PATCH 1/2] [Xamarin.Android.Tools.Bytecode] add `org.jspecify.annotations.NonNull` Context: https://mvnrepository.com/artifact/org.jspecify/jspecify Context: https://mvnrepository.com/artifact/org.jspecify/jspecify/1.0.0/usages It appears that some newer AndroidX/GPS libraries are now using: ```diff --androidx.annotation.NonNull ++org.jspecify.annotations.NonNull ``` I can see versions of guava and androidx.core taking a dependency on `org.jspecify:jspecify:1.0.0`, which provides the `org.jspecify.annotations.NonNull` annotation type. I sorted the list of annotation types alphabetically, and added the `org.jspecify.annotations.NonNull` annotation type to the list of recognized annotations in `XmlClassDeclarationBuilder.cs`. --- .../XmlClassDeclarationBuilder.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs index c5f33e938..035b5dbb4 100644 --- a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs +++ b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs @@ -501,15 +501,16 @@ static bool IsNotNullAnnotation (Annotation annotation) // https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use switch (annotation.Type) { case "Landroid/annotation/NonNull;": + case "Landroid/support/annotation/NonNull;": case "Landroidx/annotation/NonNull;": case "Landroidx/annotation/RecentlyNonNull;": - case "Ljavax/validation/constraints/NotNull;": case "Ledu/umd/cs/findbugs/annotations/NonNull;": case "Ljavax/annotation/Nonnull;": - case "Lorg/jetbrains/annotations/NotNull;": + case "Ljavax/validation/constraints/NotNull;": case "Llombok/NonNull;": - case "Landroid/support/annotation/NonNull;": case "Lorg/eclipse/jdt/annotation/NonNull;": + case "Lorg/jetbrains/annotations/NotNull;": + case "Lorg/jspecify/annotations/NonNull;": return true; } From db635557afc3de67384e7d4c6c0c65de2e19583b Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 23 Jul 2025 12:24:51 -0500 Subject: [PATCH 2/2] Add more null annotations from Kotlin repo --- .../XmlClassDeclarationBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs index 035b5dbb4..b6df82728 100644 --- a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs +++ b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs @@ -499,15 +499,20 @@ static bool IsNotNullAnnotation (Annotation annotation) { // Android ones plus the list from here: // https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use + // https://github.com/JetBrains/kotlin/blob/03360c0108797b2a98b6608e2bddfacd5f4e87ce/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt#L64-L91 switch (annotation.Type) { case "Landroid/annotation/NonNull;": case "Landroid/support/annotation/NonNull;": case "Landroidx/annotation/NonNull;": case "Landroidx/annotation/RecentlyNonNull;": + case "Lcom/android/annotations/NonNull;": case "Ledu/umd/cs/findbugs/annotations/NonNull;": + case "Ljakarta/annotation/Nonnull;": case "Ljavax/annotation/Nonnull;": case "Ljavax/validation/constraints/NotNull;": case "Llombok/NonNull;": + case "Lorg/checkerframework/checker/nullness/compatqual/NonNullDecl;": + case "Lorg/checkerframework/checker/nullness/qual/NonNull;": case "Lorg/eclipse/jdt/annotation/NonNull;": case "Lorg/jetbrains/annotations/NotNull;": case "Lorg/jspecify/annotations/NonNull;":