-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method pre- and postcondition using @RequiresNonnull/@EnsuresNonn…
…ull (#423) Co-authored-by: Manu Sridharan <[email protected]>
- Loading branch information
1 parent
660a513
commit d7e96e4
Showing
16 changed files
with
1,187 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,3 @@ tmp/ | |
|
||
# TeXlipse plugin | ||
.texlipse | ||
|
||
# kotlin | ||
annotations/ |
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
19 changes: 19 additions & 0 deletions
19
nullaway/src/main/java/com/uber/nullaway/annotations/EnsuresNonNull.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,19 @@ | ||
package com.uber.nullaway.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Can annotate a methods with @EnsuresNonnull(param) annotation where param is one of the classes | ||
* fields. It indicates a post-condition for the method, that at every call site to this method, the | ||
* class field in the argument is @Nonnull at exit point. If a method is annotated | ||
* with @EnsuresNonnull(param), NullAway checks weather the @Nonnull assumption of the field at exit | ||
* point is valid. | ||
*/ | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) | ||
public @interface EnsuresNonNull { | ||
String[] value(); | ||
} |
19 changes: 19 additions & 0 deletions
19
nullaway/src/main/java/com/uber/nullaway/annotations/RequiresNonNull.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,19 @@ | ||
package com.uber.nullaway.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Can annotate a methods with @RequiresNonnull(param) annotation where param is one of the classes | ||
* fields. It indicates a pre-condition for the method, that at every call site to this method, the | ||
* class field in the argument must be @Nonnull. If a method is annotated | ||
* with @RequiresNonnull(param), NullAway dataflow analysis is going to assume that the filed with | ||
* name param, is @Nonnull at the start point. | ||
*/ | ||
@Retention(RetentionPolicy.CLASS) | ||
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) | ||
public @interface RequiresNonNull { | ||
String[] value(); | ||
} |
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
Oops, something went wrong.