Skip to content

Commit 4d015ca

Browse files
[Xamarin.Android.Tools.Bytecode] add org.jspecify.annotations.NonNull (#1351)
Context: https://mvnrepository.com/artifact/org.jspecify/jspecify Context: https://mvnrepository.com/artifact/org.jspecify/jspecify/1.0.0/usages Context: https://github.com/JetBrains/kotlin/blob/03360c0108797b2a98b6608e2bddfacd5f4e87ce/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt#L64-L91 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`. So, then we found a list of "non-null" annotations in the Kotlin compiler. Updated to include some of the ones they list as well.
1 parent 03cb8e2 commit 4d015ca

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,23 @@ static bool IsNotNullAnnotation (Annotation annotation)
499499
{
500500
// Android ones plus the list from here:
501501
// https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use
502+
// https://github.com/JetBrains/kotlin/blob/03360c0108797b2a98b6608e2bddfacd5f4e87ce/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt#L64-L91
502503
switch (annotation.Type) {
503504
case "Landroid/annotation/NonNull;":
505+
case "Landroid/support/annotation/NonNull;":
504506
case "Landroidx/annotation/NonNull;":
505507
case "Landroidx/annotation/RecentlyNonNull;":
506-
case "Ljavax/validation/constraints/NotNull;":
508+
case "Lcom/android/annotations/NonNull;":
507509
case "Ledu/umd/cs/findbugs/annotations/NonNull;":
510+
case "Ljakarta/annotation/Nonnull;":
508511
case "Ljavax/annotation/Nonnull;":
509-
case "Lorg/jetbrains/annotations/NotNull;":
512+
case "Ljavax/validation/constraints/NotNull;":
510513
case "Llombok/NonNull;":
511-
case "Landroid/support/annotation/NonNull;":
514+
case "Lorg/checkerframework/checker/nullness/compatqual/NonNullDecl;":
515+
case "Lorg/checkerframework/checker/nullness/qual/NonNull;":
512516
case "Lorg/eclipse/jdt/annotation/NonNull;":
517+
case "Lorg/jetbrains/annotations/NotNull;":
518+
case "Lorg/jspecify/annotations/NonNull;":
513519
return true;
514520
}
515521

0 commit comments

Comments
 (0)