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

Migrate to JSpecify #4415

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
2 changes: 2 additions & 0 deletions rewrite-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies {
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("net.java.dev.jna:jna-platform:latest.release")

implementation("org.jspecify:jspecify:latest.release")

// Pinning okhttp while waiting on 5.0.0
// https://github.com/openrewrite/rewrite/issues/1479
compileOnly("com.squareup.okhttp3:okhttp:4.9.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
* @see NonNullApi
* @see NonNullFields
* @see Nullable
* @deprecated Use {@link org.jspecify.annotations.NonNull} instead.
*/
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Nonnull
@TypeQualifierNickname
@Deprecated
public @interface NonNull {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@
*/
package org.openrewrite.internal.lang;

import javax.annotation.Nonnull;
import org.jspecify.annotations.NullMarked;

import javax.annotation.meta.TypeQualifierDefault;
import java.lang.annotation.*;

/**
* A common annotation to declare that parameters and return values
* are to be considered as non-nullable by default for a given package.
* <p>Leverages JSR-305 meta-annotations to indicate nullability in Java to common
* tools with JSR-305 support and used by Kotlin to infer nullability of the API.
* <p>Leverages JSpecify meta-annotations to indicate nullability in Java to common
* tools with JSpecify support and used by Kotlin to infer nullability of the API.
* <p>Should be used at package level in association with {@link Nullable}
* annotations at parameter and return value level.
*
* @see NonNullFields
* @see Nullable
* @see NonNull
* @deprecated Use {@link org.jspecify.annotations.NullMarked} instead.
*/
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Nonnull
@NullMarked
@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER})
@Deprecated
public @interface NonNullApi {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,25 @@
*/
package org.openrewrite.internal.lang;

import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
import java.lang.annotation.*;

/**
* A common annotation to declare that fields are to be considered as
* non-nullable by default for a given package.
* <p>Leverages JSR-305 meta-annotations to indicate nullability in Java to common
* tools with JSR-305 support and used by Kotlin to infer nullability of the API.
* <p>Should be used at package level in association with {@link Nullable}
* <p>Leverages JSpecify meta-annotations to indicate nullability in Java to common
* tools with JSpecify support and used by Kotlin to infer nullability of the API.
* <p>Should be used at package level in association with {@link org.jspecify.annotations.Nullable}
* annotations at field level.
*
* @see NonNullFields
* @see Nullable
* @see NonNull
* @see org.jspecify.annotations.NonNull
* @see org.jspecify.annotations.Nullable
*/
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Nonnull
@org.jspecify.annotations.NonNull
@TypeQualifierDefault(ElementType.FIELD)
public @interface NonNullFields {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
/**
* A common annotation to declare that fields are to be considered as
* non-nullable by default for a given package.
* <p>Leverages JSR-305 meta-annotations to indicate nullability in Java to common
* tools with JSR-305 support and used by Kotlin to infer nullability of the API.
* <p>Leverages JSpecify meta-annotations to indicate nullability in Java to common
* tools with JSpecify support and used by Kotlin to infer nullability of the API.
* <p>Should be used at package level in association with {@link Nullable}
* annotations at field level.
*
* @see NullFields
* @see Nullable
* @see NonNull
* @see org.jspecify.annotations.Nullable
* @see org.jspecify.annotations.NonNull
*/
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@javax.annotation.Nullable
@org.jspecify.annotations.Nullable
@TypeQualifierDefault(ElementType.FIELD)
public @interface NullFields {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/
package org.openrewrite.internal.lang;

import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierNickname;
import javax.annotation.meta.When;
import java.lang.annotation.*;

/**
Expand All @@ -32,11 +30,13 @@
* @see NonNullApi
* @see NonNullFields
* @see NonNull
* @deprecated Use {@link org.jspecify.annotations.Nullable} instead.
*/
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Nonnull(when = When.MAYBE)
@org.jspecify.annotations.Nullable
@TypeQualifierNickname
@Deprecated
public @interface Nullable {
}
Loading