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

Allow NotNull and Nullable on package declarations #60

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
===

Version 22.1.0
---
* Allow `@NotNull` and `@Nullable` on package declarations.

Version 22.0.0
---
* Added new annotations: `@Blocking` and `@NonBlocking`.
Expand Down
8 changes: 5 additions & 3 deletions common/src/main/java/org/jetbrains/annotations/NotNull.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
import java.lang.annotation.*;

/**
* An element annotated with NotNull claims {@code null} value is <em>forbidden</em>
* to return (for methods), pass to (parameters) and hold (local variables and fields).
* An element annotated with {@link NotNull} claims {@code null} value is <em>forbidden</em>
* to return (for methods), pass to (parameters) and hold (local variables and fields). When a
* package is annotated with {@link NotNull} it claims that all fields and the return value for
* methods in every class of this package are non-nullable by default.
* Apart from documentation purposes this annotation is intended to be used by static analysis tools
* to validate against probable runtime errors and element contract violations.
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.PACKAGE})
public @interface NotNull {
/**
* @return Custom exception message
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/java/org/jetbrains/annotations/Nullable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

/**
* An element annotated with {@link Nullable} claims {@code null} value is perfectly <em>valid</em>
* to return (for methods), pass to (parameters) or hold in (local variables and fields).
* to return (for methods), pass to (parameters) or hold in (local variables and fields). When a package
* is annotated with {@link Nullable} it claims that all fields and the return value for methods in every
* class of this package are nullable by default.
* Apart from documentation purposes this annotation is intended to be used by static analysis tools
* to validate against probable runtime errors or element contract violations.
* <p>
Expand All @@ -36,7 +38,7 @@
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.PACKAGE})
public @interface Nullable {
/**
* @return textual reason when the annotated value could be null, for documentation purposes.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# limitations under the License.
#

projectVersion=22.0.0
projectVersion=22.1.0
#JDK_5=<path-to-older-java-version>