From cc137d01c50bf1debe5951cfa245fe76a818f5ef Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 1 Oct 2024 18:00:37 +0200 Subject: [PATCH 1/2] Add section on nullability annotations --- CONTRIBUTING.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe998c4ea542..46056cec70b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -249,6 +249,17 @@ instead of adding a new import to the top of the file. If you are using a type a can add an import with a comment. However, if its only used a couple of times, the FQN is preferred to prevent future patch conflicts in the import section of the file. +### Nullability annotations + +We are in the process of switching nullability annotation libraries, so you might need to use one or the other: + +**For classes we add**: Fields, method parameters and return types that are nullable should be marked via the +`@Nullable` annotation from `org.jspecify.annotations`. Whenever you create a new class, add `NullMarked`, meaning types +are assumed to be non-null by default. + +**For classes added by upstream**: Keep using both `@Nullable` and `@NotNull` from `org.jetbrains.annotations`. These +will be replaced later. + ```java import org.bukkit.event.Event; // don't add import here, use FQN like below From 6a50e4bd06176305a725ff6affd3e1fc5b0b0121 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 1 Oct 2024 20:21:46 +0200 Subject: [PATCH 2/2] Link to jspecify user guide --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46056cec70b1..be94ba56a930 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -254,8 +254,8 @@ patch conflicts in the import section of the file. We are in the process of switching nullability annotation libraries, so you might need to use one or the other: **For classes we add**: Fields, method parameters and return types that are nullable should be marked via the -`@Nullable` annotation from `org.jspecify.annotations`. Whenever you create a new class, add `NullMarked`, meaning types -are assumed to be non-null by default. +`@Nullable` annotation from `org.jspecify.annotations`. Whenever you create a new class, add `@NullMarked`, meaning types +are assumed to be non-null by default. For less obvious placing such as on generics or arrays, see the [JSpecify docs](https://jspecify.dev/docs/user-guide/). **For classes added by upstream**: Keep using both `@Nullable` and `@NotNull` from `org.jetbrains.annotations`. These will be replaced later.