From 9f6a38402076fc0a85a48627c16312c50887435a Mon Sep 17 00:00:00 2001 From: "David P. Baker" Date: Wed, 5 Jan 2022 09:41:31 -0800 Subject: [PATCH] Remove `@Beta` from most classes in `com.google.common.reflect`. Addresses https://github.com/google/guava/issues/3051 (but doesn't remove `@Beta` from `Invokable`). RELNOTES=`reflect`: Remove `@Beta` from most classes. PiperOrigin-RevId: 419849834 --- .../com/google/common/reflect/AbstractInvocationHandler.java | 2 -- android/guava/src/com/google/common/reflect/ClassPath.java | 4 ---- .../com/google/common/reflect/ImmutableTypeToInstanceMap.java | 3 --- .../com/google/common/reflect/MutableTypeToInstanceMap.java | 2 -- android/guava/src/com/google/common/reflect/Parameter.java | 4 ++++ android/guava/src/com/google/common/reflect/Reflection.java | 2 -- .../guava/src/com/google/common/reflect/TypeParameter.java | 2 -- android/guava/src/com/google/common/reflect/TypeResolver.java | 2 -- .../src/com/google/common/reflect/TypeToInstanceMap.java | 2 -- android/guava/src/com/google/common/reflect/TypeToken.java | 3 ++- .../com/google/common/reflect/AbstractInvocationHandler.java | 2 -- guava/src/com/google/common/reflect/ClassPath.java | 4 ---- .../com/google/common/reflect/ImmutableTypeToInstanceMap.java | 3 --- .../com/google/common/reflect/MutableTypeToInstanceMap.java | 2 -- guava/src/com/google/common/reflect/Parameter.java | 4 ++++ guava/src/com/google/common/reflect/Reflection.java | 2 -- guava/src/com/google/common/reflect/TypeParameter.java | 2 -- guava/src/com/google/common/reflect/TypeResolver.java | 2 -- guava/src/com/google/common/reflect/TypeToInstanceMap.java | 2 -- guava/src/com/google/common/reflect/TypeToken.java | 3 ++- 20 files changed, 12 insertions(+), 40 deletions(-) diff --git a/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java b/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java index 4666f992c3fa..ff921959db39 100644 --- a/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java +++ b/android/guava/src/com/google/common/reflect/AbstractInvocationHandler.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -39,7 +38,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault public abstract class AbstractInvocationHandler implements InvocationHandler { diff --git a/android/guava/src/com/google/common/reflect/ClassPath.java b/android/guava/src/com/google/common/reflect/ClassPath.java index 4b9f7acfc046..d15bb5055d33 100644 --- a/android/guava/src/com/google/common/reflect/ClassPath.java +++ b/android/guava/src/com/google/common/reflect/ClassPath.java @@ -20,7 +20,6 @@ import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR; import static java.util.logging.Level.WARNING; -import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.CharMatcher; import com.google.common.base.Splitter; @@ -91,7 +90,6 @@ * @author Ben Yu * @since 14.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class ClassPath { private static final Logger logger = Logger.getLogger(ClassPath.class.getName()); @@ -204,7 +202,6 @@ public ImmutableSet getTopLevelClassesRecursive(String packageName) { * * @since 14.0 */ - @Beta public static class ResourceInfo { private final File file; private final String resourceName; @@ -300,7 +297,6 @@ public String toString() { * * @since 14.0 */ - @Beta public static final class ClassInfo extends ResourceInfo { private final String className; diff --git a/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java b/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java index 6d8eb7bf75c7..4426d397ea81 100644 --- a/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java +++ b/android/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import com.google.common.collect.ForwardingMap; import com.google.common.collect.ImmutableMap; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -29,7 +28,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class ImmutableTypeToInstanceMap extends ForwardingMap, B> implements TypeToInstanceMap { @@ -60,7 +58,6 @@ public static Builder builder() { * * @since 13.0 */ - @Beta public static final class Builder { private final ImmutableMap.Builder, B> mapBuilder = ImmutableMap.builder(); diff --git a/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java b/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java index 10fc1f3ec1f7..9542e0a7ed51 100644 --- a/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java +++ b/android/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.collect.ForwardingMap; import com.google.common.collect.ForwardingMapEntry; import com.google.common.collect.ForwardingSet; @@ -39,7 +38,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class MutableTypeToInstanceMap extends ForwardingMap, B> implements TypeToInstanceMap { diff --git a/android/guava/src/com/google/common/reflect/Parameter.java b/android/guava/src/com/google/common/reflect/Parameter.java index a55734a2c8c8..a5be09d41d70 100644 --- a/android/guava/src/com/google/common/reflect/Parameter.java +++ b/android/guava/src/com/google/common/reflect/Parameter.java @@ -27,6 +27,10 @@ /** * Represents a method or constructor parameter. * + *

Note: Since Java 8 introduced {@link java.lang.reflect.Parameter} to represent method + * and constructor parameters, this class is no longer necessary. We intend to deprecate it in a + * future version. + * * @author Ben Yu * @since 14.0 */ diff --git a/android/guava/src/com/google/common/reflect/Reflection.java b/android/guava/src/com/google/common/reflect/Reflection.java index fa35f7f2de6a..9544963481d9 100644 --- a/android/guava/src/com/google/common/reflect/Reflection.java +++ b/android/guava/src/com/google/common/reflect/Reflection.java @@ -17,7 +17,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; @@ -26,7 +25,6 @@ * * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class Reflection { diff --git a/android/guava/src/com/google/common/reflect/TypeParameter.java b/android/guava/src/com/google/common/reflect/TypeParameter.java index 9c64abb72794..69cd8291a909 100644 --- a/android/guava/src/com/google/common/reflect/TypeParameter.java +++ b/android/guava/src/com/google/common/reflect/TypeParameter.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.annotations.Beta; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import javax.annotation.CheckForNull; @@ -34,7 +33,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault /* * A nullable bound would let users create a TypeParameter instance for a parameter with a nullable diff --git a/android/guava/src/com/google/common/reflect/TypeResolver.java b/android/guava/src/com/google/common/reflect/TypeResolver.java index f72e19576de8..a3720984af03 100644 --- a/android/guava/src/com/google/common/reflect/TypeResolver.java +++ b/android/guava/src/com/google/common/reflect/TypeResolver.java @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkState; import static java.util.Arrays.asList; -import com.google.common.annotations.Beta; import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; @@ -51,7 +50,6 @@ * @author Ben Yu * @since 15.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class TypeResolver { diff --git a/android/guava/src/com/google/common/reflect/TypeToInstanceMap.java b/android/guava/src/com/google/common/reflect/TypeToInstanceMap.java index 8a329bdb38ed..8a418df2a4d3 100644 --- a/android/guava/src/com/google/common/reflect/TypeToInstanceMap.java +++ b/android/guava/src/com/google/common/reflect/TypeToInstanceMap.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotMock; import java.util.Map; @@ -42,7 +41,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @DoNotMock("Use ImmutableTypeToInstanceMap or MutableTypeToInstanceMap") @ElementTypesAreNonnullByDefault public interface TypeToInstanceMap extends Map, B> { diff --git a/android/guava/src/com/google/common/reflect/TypeToken.java b/android/guava/src/com/google/common/reflect/TypeToken.java index 845221956a51..fea1d53a2fab 100644 --- a/android/guava/src/com/google/common/reflect/TypeToken.java +++ b/android/guava/src/com/google/common/reflect/TypeToken.java @@ -97,7 +97,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @SuppressWarnings("serial") // SimpleTypeToken is the serialized form. @ElementTypesAreNonnullByDefault public abstract class TypeToken extends TypeCapture implements Serializable { @@ -591,6 +590,7 @@ public final TypeToken getComponentType() { * * @since 14.0 */ + @Beta public final Invokable method(Method method) { checkArgument( this.someRawTypeIsSubclassOf(method.getDeclaringClass()), @@ -630,6 +630,7 @@ public String toString() { * * @since 14.0 */ + @Beta public final Invokable constructor(Constructor constructor) { checkArgument( constructor.getDeclaringClass() == getRawType(), diff --git a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java index 4666f992c3fa..ff921959db39 100644 --- a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java +++ b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -39,7 +38,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault public abstract class AbstractInvocationHandler implements InvocationHandler { diff --git a/guava/src/com/google/common/reflect/ClassPath.java b/guava/src/com/google/common/reflect/ClassPath.java index 4b9f7acfc046..d15bb5055d33 100644 --- a/guava/src/com/google/common/reflect/ClassPath.java +++ b/guava/src/com/google/common/reflect/ClassPath.java @@ -20,7 +20,6 @@ import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR; import static java.util.logging.Level.WARNING; -import com.google.common.annotations.Beta; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.CharMatcher; import com.google.common.base.Splitter; @@ -91,7 +90,6 @@ * @author Ben Yu * @since 14.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class ClassPath { private static final Logger logger = Logger.getLogger(ClassPath.class.getName()); @@ -204,7 +202,6 @@ public ImmutableSet getTopLevelClassesRecursive(String packageName) { * * @since 14.0 */ - @Beta public static class ResourceInfo { private final File file; private final String resourceName; @@ -300,7 +297,6 @@ public String toString() { * * @since 14.0 */ - @Beta public static final class ClassInfo extends ResourceInfo { private final String className; diff --git a/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java b/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java index 6d8eb7bf75c7..4426d397ea81 100644 --- a/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java +++ b/guava/src/com/google/common/reflect/ImmutableTypeToInstanceMap.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import com.google.common.collect.ForwardingMap; import com.google.common.collect.ImmutableMap; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -29,7 +28,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class ImmutableTypeToInstanceMap extends ForwardingMap, B> implements TypeToInstanceMap { @@ -60,7 +58,6 @@ public static Builder builder() { * * @since 13.0 */ - @Beta public static final class Builder { private final ImmutableMap.Builder, B> mapBuilder = ImmutableMap.builder(); diff --git a/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java b/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java index 10fc1f3ec1f7..9542e0a7ed51 100644 --- a/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java +++ b/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.collect.ForwardingMap; import com.google.common.collect.ForwardingMapEntry; import com.google.common.collect.ForwardingSet; @@ -39,7 +38,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class MutableTypeToInstanceMap extends ForwardingMap, B> implements TypeToInstanceMap { diff --git a/guava/src/com/google/common/reflect/Parameter.java b/guava/src/com/google/common/reflect/Parameter.java index 61ab85a3fd04..c3c46eca9d08 100644 --- a/guava/src/com/google/common/reflect/Parameter.java +++ b/guava/src/com/google/common/reflect/Parameter.java @@ -28,6 +28,10 @@ /** * Represents a method or constructor parameter. * + *

Note: Since Java 8 introduced {@link java.lang.reflect.Parameter} to represent method + * and constructor parameters, this class is no longer necessary. We intend to deprecate it in a + * future version. + * * @author Ben Yu * @since 14.0 */ diff --git a/guava/src/com/google/common/reflect/Reflection.java b/guava/src/com/google/common/reflect/Reflection.java index fa35f7f2de6a..9544963481d9 100644 --- a/guava/src/com/google/common/reflect/Reflection.java +++ b/guava/src/com/google/common/reflect/Reflection.java @@ -17,7 +17,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; @@ -26,7 +25,6 @@ * * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class Reflection { diff --git a/guava/src/com/google/common/reflect/TypeParameter.java b/guava/src/com/google/common/reflect/TypeParameter.java index 9c64abb72794..69cd8291a909 100644 --- a/guava/src/com/google/common/reflect/TypeParameter.java +++ b/guava/src/com/google/common/reflect/TypeParameter.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.annotations.Beta; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import javax.annotation.CheckForNull; @@ -34,7 +33,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @ElementTypesAreNonnullByDefault /* * A nullable bound would let users create a TypeParameter instance for a parameter with a nullable diff --git a/guava/src/com/google/common/reflect/TypeResolver.java b/guava/src/com/google/common/reflect/TypeResolver.java index f72e19576de8..a3720984af03 100644 --- a/guava/src/com/google/common/reflect/TypeResolver.java +++ b/guava/src/com/google/common/reflect/TypeResolver.java @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkState; import static java.util.Arrays.asList; -import com.google.common.annotations.Beta; import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; @@ -51,7 +50,6 @@ * @author Ben Yu * @since 15.0 */ -@Beta @ElementTypesAreNonnullByDefault public final class TypeResolver { diff --git a/guava/src/com/google/common/reflect/TypeToInstanceMap.java b/guava/src/com/google/common/reflect/TypeToInstanceMap.java index 8a329bdb38ed..8a418df2a4d3 100644 --- a/guava/src/com/google/common/reflect/TypeToInstanceMap.java +++ b/guava/src/com/google/common/reflect/TypeToInstanceMap.java @@ -14,7 +14,6 @@ package com.google.common.reflect; -import com.google.common.annotations.Beta; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.DoNotMock; import java.util.Map; @@ -42,7 +41,6 @@ * @author Ben Yu * @since 13.0 */ -@Beta @DoNotMock("Use ImmutableTypeToInstanceMap or MutableTypeToInstanceMap") @ElementTypesAreNonnullByDefault public interface TypeToInstanceMap extends Map, B> { diff --git a/guava/src/com/google/common/reflect/TypeToken.java b/guava/src/com/google/common/reflect/TypeToken.java index 845221956a51..fea1d53a2fab 100644 --- a/guava/src/com/google/common/reflect/TypeToken.java +++ b/guava/src/com/google/common/reflect/TypeToken.java @@ -97,7 +97,6 @@ * @author Ben Yu * @since 12.0 */ -@Beta @SuppressWarnings("serial") // SimpleTypeToken is the serialized form. @ElementTypesAreNonnullByDefault public abstract class TypeToken extends TypeCapture implements Serializable { @@ -591,6 +590,7 @@ public final TypeToken getComponentType() { * * @since 14.0 */ + @Beta public final Invokable method(Method method) { checkArgument( this.someRawTypeIsSubclassOf(method.getDeclaringClass()), @@ -630,6 +630,7 @@ public String toString() { * * @since 14.0 */ + @Beta public final Invokable constructor(Constructor constructor) { checkArgument( constructor.getDeclaringClass() == getRawType(),