forked from uber/NullAway
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Update to JSpecify 0.3.0-alpha-1 (uber#673)"
This reverts commit 3da177a.
- Loading branch information
Showing
6 changed files
with
170 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test-java-lib/src/main/java/com/example/jspecify/future/annotations/NullMarked.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2018-2022 The JSpecify Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.jspecify.future.annotations; | ||
|
||
// Note: Copied from | ||
// https://github.com/jspecify/jspecify/blob/main/src/main/java/org/jspecify/nullness/NullMarked.java | ||
// used for testing JSpecify features (such as @NullMarked on methods), which aren't part of | ||
// JSpecify v0.2.0. | ||
// This annotation should be deleted and its references replaced with | ||
// org.jspecify.nullness.NullMarked once JSpecify v0.3.0 is out. | ||
// This test resource is not redistributed with NullAway. | ||
|
||
import static java.lang.annotation.ElementType.CONSTRUCTOR; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PACKAGE; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Indicates that the annotated element and the code transitively <a | ||
* href="https://docs.oracle.com/en/java/javase/18/docs/api/java.compiler/javax/lang/model/element/Element.html#getEnclosedElements()">enclosed</a> | ||
* within it is <b>null-marked code</b>: type usages are generally considered to exclude {@code | ||
* null} as a value unless specified otherwise (special cases to be covered below). Using this | ||
* annotation avoids the need to write {@link NonNull @NonNull} many times throughout your code. | ||
* | ||
* <p><b>WARNING:</b> This annotation is under development, and <i>any</i> aspect of its naming, | ||
* location, or design may change before 1.0. <b>Do not release libraries using this annotation at | ||
* this time.</b> | ||
*/ | ||
@Documented | ||
@Target({TYPE, METHOD, CONSTRUCTOR, PACKAGE}) | ||
@Retention(RUNTIME) | ||
public @interface NullMarked {} |
82 changes: 82 additions & 0 deletions
82
test-java-lib/src/main/java/com/example/jspecify/future/annotations/NullUnmarked.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2022 The JSpecify Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.jspecify.future.annotations; | ||
|
||
// Note: Copied from | ||
// https://github.com/jspecify/jspecify/blob/main/src/main/java/org/jspecify/nullness/NullUnmarked.java | ||
// as it isn't part of JSpecify v0.2.0. | ||
// This annotation should be deleted and its references replaced with | ||
// org.jspecify.nullness.NullUnmarked once JSpecify v0.3.0 is out. | ||
// This test resource is not redistributed with NullAway. | ||
|
||
import static java.lang.annotation.ElementType.CONSTRUCTOR; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PACKAGE; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Indicates that the annotated element and the code transitively {@linkplain | ||
* javax.lang.model.element.Element#getEnclosedElements() enclosed} within it is <b>null-unmarked | ||
* code</b>: there, type usages generally have <b>unspecified nullness</b> unless explicitly | ||
* annotated otherwise. | ||
* | ||
* <p>This annotation's purpose is to ease migration of a large existing codebase to null-marked | ||
* status. It makes it possible to "flip the default" for new code added to a class or package even | ||
* before that class or package has been fully migrated. Since new code is the most important code | ||
* to analyze, this is strongly recommended as a temporary measure whenever necessary. However, once | ||
* a codebase has been fully migrated it would be appropriate to ban use of this annotation. | ||
* | ||
* <p>For a guided introduction to JSpecify nullness annotations, please see the <a | ||
* href="http://jspecify.org/docs/user-guide">User Guide</a>. | ||
* | ||
* <p><b>Warning:</b> These annotations are under development, and <b>any</b> aspect of their | ||
* naming, locations, or design is subject to change until the JSpecify 1.0 release. Moreover, | ||
* supporting analysis tools will track with these changes on varying schedules. Releasing a library | ||
* using these annotations in its API is <b>strongly discouraged</b> at this time. | ||
* | ||
* <h2>Null-marked and null-unmarked code</h2> | ||
* | ||
* <p>{@link NullMarked} and this annotation work as a pair to include and exclude sections of code | ||
* from null-marked status. | ||
* | ||
* <p>Code is considered null-marked if the most narrowly enclosing element annotated with either of | ||
* these two annotations is annotated with {@code @NullMarked}. | ||
* | ||
* <p>Otherwise it is considered null-unmarked. This can happen in two ways: either it is more | ||
* narrowly enclosed by a {@code @NullUnmarked}-annotated element than by any | ||
* {@code @NullMarked}-annotated element, or neither annotation is present on any enclosing element. | ||
* No distinction is made between these cases. | ||
* | ||
* <h2>Unspecified nullness</h2> | ||
* | ||
* <p>An unannotated type usage in null-unmarked code has <b>unspecified nullness</b>. There is | ||
* <i>some</i> correct way to annotate it, but that information is missing; the usage conveys <b>no | ||
* information</b> about whether it includes or excludes {@code null} as a value. Only type usages | ||
* within null-unmarked code may have unspecified nullness. (<a | ||
* href="https://bit.ly/3ppb8ZC">Why?</a>) | ||
* | ||
* <p>Unspecified nullness is (will be) explained comprehensively in the <a | ||
* href="http://jspecify.org/docs/user-guide">User Guide</a>. | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({TYPE, METHOD, CONSTRUCTOR, PACKAGE}) | ||
public @interface NullUnmarked {} |
6 changes: 4 additions & 2 deletions
6
test-java-lib/src/main/java/com/example/jspecify/unannotatedpackage/Methods.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters