Skip to content

Commit ee680cb

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committedJun 26, 2024·
Use JSpecify annotations in the public release.
We've been using these internally for over a year. With JSpecify 1.0 not far off and wider adoption to gradually follow, now seems like the time to expand our public usage of the annotations. We've already been using them in a few projects, but Truth may become the mostly widely used project that users actually link against to use them. At the same time, it's a library that's used only in testing code, so the stakes remain relatively low. Most users will see no effect from this change, since most users don't use nullness checking and since we already used some nullness annotations in our public release. The main effect users are likely to see is if they pass nullable values for parameters that are now recognized as non-nullable. Under Kotlin, the effect should normally be a warning, not an error, at least until [Kotlin 2.1 or so](https://youtrack.jetbrains.com/issue/KT-55586/Handle-nullability-from-jspecify-annotations-properly#focus=Comments-27-8368666.0-0). Please still [report any problems](https://github.com/google/truth/issues/new). (progress toward JSpecify adoption in our projects in general, including google/guava#2960) RELNOTES=Added more nullness information to our APIs (in the form of [JSpecify](https://jspecify.dev/) annotations). This could lead to additional warnings (or even errors) for users of Kotlin and other nullness checkers. Please [report any problems](https://github.com/google/truth/issues/new). PiperOrigin-RevId: 647012817
1 parent d39e722 commit ee680cb

File tree

92 files changed

+198
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+198
-88
lines changed
 

‎core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<artifactId>guava</artifactId>
1616
</dependency>
1717
<dependency>
18-
<groupId>org.checkerframework</groupId>
19-
<artifactId>checker-qual</artifactId>
18+
<groupId>org.jspecify</groupId>
19+
<artifactId>jspecify</artifactId>
2020
</dependency>
2121
<dependency>
2222
<groupId>junit</groupId>

‎core/src/main/java/com/google/common/truth/AbstractArraySubject.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
import static com.google.common.truth.Fact.simpleFact;
2121

2222
import java.lang.reflect.Array;
23-
import org.checkerframework.checker.nullness.qual.Nullable;
23+
import org.jspecify.annotations.NullMarked;
24+
import org.jspecify.annotations.Nullable;
2425

2526
/**
2627
* A common supertype for Array subjects, abstracting some common display and error infrastructure.
2728
*
2829
* @author Christian Gruber (cgruber@israfil.net)
2930
*/
31+
@NullMarked
3032
abstract class AbstractArraySubject extends Subject {
3133
private final @Nullable Object actual;
3234

0 commit comments

Comments
 (0)
Please sign in to comment.