Skip to content

Commit

Permalink
Remove class-level @ElementTypesAreNonnullByDefault annotations.
Browse files Browse the repository at this point in the history
They are redundant with the package-level annotations from cl/708300606. (Again, I recommend against package-level annotations in general, but they're the best option in our specific case because we are likely to have Java 8 users who use Mockito to mock some of our classes.)

For our testlib packages, I've left the usages alone: We haven't inserted a package-level annotation in those packages except for in `c.g.c.testing`. (We could pursue doing adding it, but we'd first need to insert class-level annotations in the unannotated classes.) Really, even some of the "annotated" testlib code likely hasn't been fully annotated, but that's a separate problem. Anyway, the problems we're trying to work around with package-level annotations are mostly related to mocking, and we don't expect users to mock our testlib types (which have few users of any kind to begin with). If we hear of problems, we can reevaluate. For now, we'll live with the redundant class-level annotations in `c.g.c.testing`.

(Oops, I actually had _removed_ the package-level annotation for `common.testing` in cl/708300606 instead of merely converting it from `ParametersAreNonnullByDefault`. I made that error externally only, and this CL fixes it.)

This is the next step toward [using JSpecify in Guava](jspecify/jspecify#239 (comment)).

RELNOTES=n/a
PiperOrigin-RevId: 708490780
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 21, 2024
1 parent 5fe9d20 commit ce43463
Show file tree
Hide file tree
Showing 1,180 changed files with 8 additions and 1,180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
* Testing utilities. This package is a part of the open-source <a
* href="https://github.com/google/guava">Guava</a> library.
*/
@com.google.errorprone.annotations.CheckReturnValue
@CheckReturnValue
@ElementTypesAreNonnullByDefault
package com.google.common.testing;

import com.google.errorprone.annotations.CheckReturnValue;
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Absent.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

/** Implementation of an {@link Optional} not containing a reference. */
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class Absent<T> extends Optional<T> {
static final Absent<Object> INSTANCE = new Absent<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* reasons).
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class AbstractIterator<T extends @Nullable Object> implements Iterator<T> {
private State state = State.NOT_READY;

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Ascii.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @since 7.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Ascii {

private Ascii() {}
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/CaseFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @since 1.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public enum CaseFormat {
/** Hyphenated variable naming convention, e.g., "lower-hyphen". */
LOWER_HYPHEN(CharMatcher.is('-'), "-") {
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/CharMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class CharMatcher implements Predicate<Character> {
/*
* N777777777NO
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Charsets.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Charsets {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class CommonMatcher {
public abstract boolean matches();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* javadoc for details.
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class CommonPattern {
public abstract CommonMatcher matcher(CharSequence t);

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
* @since 16.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
/*
* 1. The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
* doForward and doBackward methods to indicate that the parameter cannot be null. (We also take
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Defaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class Defaults {
private Defaults() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
*/
@GwtIncompatible
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
public final class Enums {

private Enums() {}
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Equivalence.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* source-compatible</a> since 4.0)
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
/*
* The type parameter is <T> rather than <T extends @Nullable> so that we can use T in the
* doEquivalent and doHash methods to indicate that the parameter cannot be null.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@
* version.
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
abstract class ExtraObjectsMethodsForWeb {}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class FinalizablePhantomReference<T> extends PhantomReference<T>
implements FinalizableReference {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
@DoNotMock("Use an instance of one of the Finalizable*Reference classes")
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public interface FinalizableReference {
/**
* Invoked on a background thread after the referent has been garbage collected unless security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public class FinalizableReferenceQueue implements Closeable {
/*
* The Finalizer thread keeps a phantom reference to this object. When the client (for example, a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class FinalizableSoftReference<T> extends SoftReference<T>
implements FinalizableReference {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class FinalizableWeakReference<T> extends WeakReference<T>
implements FinalizableReference {
/**
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public interface Function<F extends @Nullable Object, T extends @Nullable Object> {
/**
* Returns the result of applying this function to {@code input}. This method is <i>generally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @since 10.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class FunctionalEquivalence<F, T> extends Equivalence<F> implements Serializable {

private static final long serialVersionUID = 0;
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Functions {
private Functions() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@
* <p>Each package's copy of this annotation needs to be listed in our {@code pom.xml}.
*/
@Target({METHOD, CONSTRUCTOR, TYPE})
@ElementTypesAreNonnullByDefault
@interface IgnoreJRERequirement {}
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/** This class is for {@code com.google.common.base} use only! */
@J2ktIncompatible
@GwtIncompatible // java.time.Duration
@ElementTypesAreNonnullByDefault
final class Internal {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class Java8Compatibility {
static void clear(Buffer b) {
b.clear();
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/JdkPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.regex.Pattern;

/** A regex pattern implementation which is backed by the {@link Pattern}. */
@ElementTypesAreNonnullByDefault
@GwtIncompatible
final class JdkPattern extends CommonPattern implements Serializable {
private final Pattern pattern;
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Joiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public class Joiner {
/** Returns a joiner which automatically places {@code separator} between consecutive elements. */
public static Joiner on(String separator) {
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/MoreObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @since 18.0 (since 2.0 as {@code Objects})
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MoreObjects {
/**
* Returns the first of two given parameters that is not {@code null}, if either is, or otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

/** A utility method to perform unchecked casts to suppress errors produced by nullness analyses. */
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class NullnessCasts {
/**
* Accepts a {@code @Nullable T} and returns a plain {@code T}, without performing any check that
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Objects extends ExtraObjectsMethodsForWeb {
private Objects() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Optional.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
*/
@DoNotMock("Use Optional.of(value) or Optional.absent()")
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public abstract class Optional<T> implements Serializable {
/**
* Returns an {@code Optional} instance with no contained reference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.checkerframework.checker.nullness.qual.Nullable;

@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
final class PairwiseEquivalence<E, T extends @Nullable E> extends Equivalence<Iterable<T>>
implements Serializable {
final Equivalence<E> elementEquivalence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* java.util.ServiceLoader} mechanism.
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
interface PatternCompiler {
/**
* Compiles the given pattern.
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* @author Jesse Wilson
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
private static final PatternCompiler patternCompiler = loadPatternCompiler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Preconditions {
private Preconditions() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Predicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public interface Predicate<T extends @Nullable Object> {
/**
* Returns the result of applying this predicate to {@code input} (Java 8+ users, see notes in the
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Predicates.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Predicates {
private Predicates() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Present.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

/** Implementation of an {@link Optional} containing a reference. */
@GwtCompatible
@ElementTypesAreNonnullByDefault
final class Present<T> extends Optional<T> {
private final T reference;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* @author Christopher Swenson
*/
@GwtIncompatible // no precomputation is done in GWT
@ElementTypesAreNonnullByDefault
final class SmallCharMatcher extends NamedFastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Splitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
@J2ktIncompatible
@GwtIncompatible // java.lang.System#getProperty
@ElementTypesAreNonnullByDefault
public enum StandardSystemProperty {

/** Java Runtime Environment version. */
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Stopwatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("GoodTime") // lots of violations
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @since 3.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Strings {
private Strings() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Supplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* @since 2.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public interface Supplier<T extends @Nullable Object> {
/**
* Retrieves an instance of the appropriate type. The returned object may or may not be a new
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Suppliers.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @since 2.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Suppliers {
private Suppliers() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Throwables.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Throwables {
private Throwables() {}

Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Ticker.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* source-compatible</a> since 9.0)
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class Ticker {
/** Constructor for use by subclasses. */
protected Ticker() {}
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Utf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @since 16.0
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Utf8 {
/**
* Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string, this
Expand Down
1 change: 0 additions & 1 deletion android/guava/src/com/google/common/base/Verify.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
* @since 17.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Verify {
/**
* Ensures that {@code expression} is {@code true}, throwing a {@code VerifyException} with no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* @since 17.0
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public class VerifyException extends RuntimeException {
/** Constructs a {@code VerifyException} with no message. */
public VerifyException() {}
Expand Down
Loading

0 comments on commit ce43463

Please sign in to comment.