From 0a2258e6691a22aa7ff2604871b520d44bbac01f Mon Sep 17 00:00:00 2001 From: cushon Date: Tue, 8 May 2018 10:48:52 -0700 Subject: [PATCH] Use the type annotation version of @Nullable in the Java 8 branch RELNOTES=Use the type annotation version of @Nullable in the Java 8 branch ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=195842620 --- .../common/testing/ClassSanityTester.java | 2 +- .../common/testing/NullPointerTester.java | 5 +- .../common/testing/ClassSanityTesterTest.java | 2 +- .../common/testing/NullPointerTesterTest.java | 5 +- .../common/collect/LinkedListMultimap.java | 2 +- .../base/ExtraObjectsMethodsForWeb.java | 4 +- .../com/google/common/base/Platform.java | 8 +- .../com/google/common/cache/LocalCache.java | 8 +- .../collect/AbstractSortedMultiset.java | 6 +- .../ForwardingImmutableCollection.java | 4 +- .../collect/ForwardingImmutableList.java | 8 +- .../collect/ForwardingImmutableMap.java | 10 +- .../collect/ForwardingImmutableSet.java | 4 +- .../common/collect/ImmutableCollection.java | 4 +- .../google/common/collect/ImmutableList.java | 8 +- .../google/common/collect/ImmutableMap.java | 12 +- .../common/collect/ImmutableSortedSet.java | 4 +- .../util/concurrent/AbstractFuture.java | 6 +- .../base/GwtSerializationDependencies.java | 6 +- guava-testlib/pom.xml | 4 + .../collect/testing/SpliteratorTester.java | 4 +- .../common/testing/ArbitraryInstances.java | 8 +- .../common/testing/CollectorTester.java | 9 +- .../common/testing/FreshValueGenerator.java | 8 +- .../common/testing/NullPointerTester.java | 15 +- .../google/common/testing/TestLogHandler.java | 4 +- .../common/testing/ClassSanityTesterTest.java | 38 +-- .../common/testing/NullPointerTesterTest.java | 76 +++--- .../ConcurrentHashMultisetBenchmark.java | 12 +- .../concurrent/ExecutionListBenchmark.java | 8 +- .../MonitorBasedArrayBlockingQueue.java | 6 +- .../MonitorBasedPriorityBlockingQueue.java | 8 +- guava-tests/pom.xml | 4 + .../common/cache/CacheBuilderFactory.java | 4 +- .../com/google/common/cache/CacheTesting.java | 4 +- .../common/cache/TestingCacheLoaders.java | 4 +- .../common/collect/FluentIterableTest.java | 4 +- .../collect/ForwardingSortedMultisetTest.java | 10 +- .../common/collect/ImmutableBiMapTest.java | 4 +- .../common/collect/ImmutableMapTest.java | 4 +- .../common/collect/ImmutableMultisetTest.java | 4 +- .../common/collect/ImmutableSetTest.java | 4 +- .../common/collect/MapsCollectionTest.java | 6 +- .../collect/MapsTransformValuesTest.java | 6 +- ...ansformValuesUnmodifiableIteratorTest.java | 6 +- .../google/common/collect/MultimapsTest.java | 10 +- .../google/common/collect/OrderingTest.java | 4 +- .../com/google/common/collect/SetsTest.java | 4 +- .../collect/SimpleAbstractMultisetTest.java | 6 +- .../collect/SynchronizedMultimapTest.java | 20 +- .../common/collect/SynchronizedSetTest.java | 10 +- .../common/collect/SynchronizedTableTest.java | 6 +- .../google/common/hash/BloomFilterTest.java | 4 +- .../google/common/io/BaseEncodingTest.java | 4 +- .../test/com/google/common/io/CloserTest.java | 4 +- .../google/common/io/SourceSinkFactories.java | 10 +- .../com/google/common/math/QuantilesTest.java | 4 +- .../google/common/reflect/InvokableTest.java | 6 +- .../concurrent/AbstractFutureBenchmarks.java | 10 +- .../util/concurrent/FutureCallbackTest.java | 6 +- .../common/util/concurrent/FuturesTest.java | 4 +- .../concurrent/ListenableFutureTester.java | 6 +- .../common/util/concurrent/TestThread.java | 6 +- guava/pom.xml | 4 + guava/src/com/google/common/base/Absent.java | 6 +- .../google/common/base/AbstractIterator.java | 6 +- .../com/google/common/base/CaseFormat.java | 4 +- .../src/com/google/common/base/Converter.java | 42 ++-- .../src/com/google/common/base/Defaults.java | 4 +- guava/src/com/google/common/base/Enums.java | 4 +- .../com/google/common/base/Equivalence.java | 28 +-- .../base/FinalizableReferenceQueue.java | 8 +- .../src/com/google/common/base/Function.java | 8 +- .../common/base/FunctionalEquivalence.java | 4 +- .../src/com/google/common/base/Functions.java | 43 ++-- guava/src/com/google/common/base/Joiner.java | 14 +- .../com/google/common/base/MoreObjects.java | 18 +- guava/src/com/google/common/base/Objects.java | 6 +- .../src/com/google/common/base/Optional.java | 16 +- .../common/base/PairwiseEquivalence.java | 4 +- .../src/com/google/common/base/Platform.java | 8 +- .../com/google/common/base/Preconditions.java | 227 ++++++++---------- .../src/com/google/common/base/Predicate.java | 8 +- .../com/google/common/base/Predicates.java | 42 ++-- guava/src/com/google/common/base/Present.java | 4 +- .../common/base/StandardSystemProperty.java | 4 +- guava/src/com/google/common/base/Strings.java | 10 +- .../src/com/google/common/base/Suppliers.java | 18 +- .../com/google/common/base/Throwables.java | 24 +- guava/src/com/google/common/base/Verify.java | 96 +++----- .../google/common/base/VerifyException.java | 8 +- .../common/base/internal/Finalizer.java | 12 +- guava/src/com/google/common/cache/Cache.java | 4 +- .../google/common/cache/CacheBuilderSpec.java | 16 +- .../com/google/common/cache/CacheStats.java | 4 +- .../google/common/cache/ForwardingCache.java | 4 +- .../com/google/common/cache/LocalCache.java | 134 +++++------ .../google/common/cache/ReferenceEntry.java | 6 +- .../common/cache/RemovalNotification.java | 6 +- .../com/google/common/cache/Striped64.java | 4 +- .../google/common/collect/AbstractBiMap.java | 18 +- .../common/collect/AbstractIterator.java | 4 +- .../common/collect/AbstractListMultimap.java | 12 +- .../collect/AbstractMapBasedMultimap.java | 52 ++-- .../collect/AbstractMapBasedMultiset.java | 16 +- .../common/collect/AbstractMapEntry.java | 4 +- .../common/collect/AbstractMultimap.java | 20 +- .../common/collect/AbstractMultiset.java | 18 +- .../common/collect/AbstractNavigableMap.java | 22 +- .../common/collect/AbstractRangeSet.java | 4 +- .../collect/AbstractSequentialIterator.java | 6 +- .../common/collect/AbstractSetMultimap.java | 12 +- .../collect/AbstractSortedMultiset.java | 6 +- .../collect/AbstractSortedSetMultimap.java | 8 +- .../google/common/collect/AbstractTable.java | 18 +- .../common/collect/AllEqualOrdering.java | 4 +- .../com/google/common/collect/ArrayTable.java | 26 +- .../src/com/google/common/collect/BiMap.java | 10 +- .../common/collect/ByFunctionOrdering.java | 4 +- .../google/common/collect/CartesianList.java | 4 +- .../common/collect/ClassToInstanceMap.java | 4 +- .../common/collect/CollectSpliterators.java | 6 +- .../google/common/collect/Collections2.java | 14 +- .../google/common/collect/CompactHashMap.java | 36 +-- .../google/common/collect/CompactHashSet.java | 8 +- .../common/collect/ComparatorOrdering.java | 4 +- .../common/collect/ComparisonChain.java | 10 +- .../common/collect/ComputationException.java | 4 +- .../collect/ConcurrentHashMultiset.java | 16 +- .../src/com/google/common/collect/Count.java | 4 +- guava/src/com/google/common/collect/Cut.java | 14 +- .../common/collect/DenseImmutableTable.java | 8 +- .../DescendingImmutableSortedMultiset.java | 4 +- .../collect/DescendingImmutableSortedSet.java | 6 +- .../common/collect/EmptyContiguousSet.java | 4 +- .../google/common/collect/EnumHashBiMap.java | 6 +- .../google/common/collect/EnumMultiset.java | 10 +- .../common/collect/ExplicitOrdering.java | 4 +- .../common/collect/FilteredEntryMultimap.java | 20 +- .../collect/FilteredKeyListMultimap.java | 4 +- .../common/collect/FilteredKeyMultimap.java | 6 +- .../collect/FilteredKeySetMultimap.java | 4 +- .../collect/FilteredMultimapValues.java | 6 +- .../google/common/collect/FluentIterable.java | 8 +- .../common/collect/ForwardingCollection.java | 6 +- .../google/common/collect/ForwardingList.java | 10 +- .../collect/ForwardingListMultimap.java | 6 +- .../google/common/collect/ForwardingMap.java | 18 +- .../common/collect/ForwardingMapEntry.java | 6 +- .../common/collect/ForwardingMultimap.java | 16 +- .../common/collect/ForwardingMultiset.java | 10 +- .../google/common/collect/ForwardingSet.java | 6 +- .../common/collect/ForwardingSetMultimap.java | 6 +- .../common/collect/ForwardingSortedMap.java | 4 +- .../common/collect/ForwardingSortedSet.java | 8 +- .../collect/ForwardingSortedSetMultimap.java | 6 +- .../google/common/collect/GeneralRange.java | 34 +-- .../google/common/collect/HashBasedTable.java | 16 +- .../com/google/common/collect/HashBiMap.java | 54 ++--- .../com/google/common/collect/Hashing.java | 4 +- .../collect/ImmutableClassToInstanceMap.java | 4 +- .../common/collect/ImmutableCollection.java | 4 +- .../google/common/collect/ImmutableEntry.java | 12 +- .../common/collect/ImmutableEnumMap.java | 4 +- .../google/common/collect/ImmutableList.java | 16 +- .../common/collect/ImmutableListMultimap.java | 6 +- .../google/common/collect/ImmutableMap.java | 16 +- .../common/collect/ImmutableMapEntry.java | 10 +- .../common/collect/ImmutableMapEntrySet.java | 4 +- .../common/collect/ImmutableMapKeySet.java | 4 +- .../common/collect/ImmutableMapValues.java | 4 +- .../common/collect/ImmutableMultimap.java | 12 +- .../common/collect/ImmutableMultiset.java | 8 +- .../common/collect/ImmutableRangeMap.java | 8 +- .../common/collect/ImmutableRangeSet.java | 4 +- .../google/common/collect/ImmutableSet.java | 6 +- .../common/collect/ImmutableSetMultimap.java | 18 +- .../common/collect/ImmutableSortedAsList.java | 6 +- .../common/collect/ImmutableSortedMap.java | 4 +- .../common/collect/ImmutableSortedSet.java | 4 +- .../google/common/collect/ImmutableTable.java | 6 +- .../com/google/common/collect/Iterables.java | 31 ++- .../com/google/common/collect/Iterators.java | 41 ++-- .../collect/JdkBackedImmutableBiMap.java | 4 +- .../common/collect/JdkBackedImmutableMap.java | 4 +- .../collect/JdkBackedImmutableMultiset.java | 4 +- .../common/collect/JdkBackedImmutableSet.java | 4 +- .../collect/LexicographicalOrdering.java | 4 +- .../common/collect/LinkedHashMultimap.java | 32 +-- .../common/collect/LinkedListMultimap.java | 65 +++-- .../google/common/collect/ListMultimap.java | 8 +- .../src/com/google/common/collect/Lists.java | 34 +-- .../google/common/collect/MapDifference.java | 6 +- .../common/collect/MapMakerInternalMap.java | 93 ++++--- guava/src/com/google/common/collect/Maps.java | 93 ++++--- .../common/collect/MinMaxPriorityQueue.java | 4 +- .../google/common/collect/MoreCollectors.java | 6 +- .../com/google/common/collect/Multimap.java | 24 +- .../com/google/common/collect/Multimaps.java | 14 +- .../com/google/common/collect/Multiset.java | 14 +- .../com/google/common/collect/Multisets.java | 28 +-- .../common/collect/NullsFirstOrdering.java | 6 +- .../common/collect/NullsLastOrdering.java | 6 +- .../google/common/collect/ObjectArrays.java | 6 +- .../com/google/common/collect/Ordering.java | 16 +- .../src/com/google/common/collect/Range.java | 4 +- .../com/google/common/collect/RangeMap.java | 8 +- .../com/google/common/collect/RangeSet.java | 4 +- .../common/collect/RegularContiguousSet.java | 8 +- .../common/collect/RegularImmutableBiMap.java | 10 +- .../common/collect/RegularImmutableMap.java | 13 +- .../collect/RegularImmutableMultiset.java | 6 +- .../common/collect/RegularImmutableSet.java | 4 +- .../RegularImmutableSortedMultiset.java | 4 +- .../collect/RegularImmutableSortedSet.java | 8 +- .../common/collect/RegularImmutableTable.java | 12 +- .../common/collect/ReverseOrdering.java | 4 +- .../google/common/collect/SetMultimap.java | 8 +- guava/src/com/google/common/collect/Sets.java | 22 +- .../collect/SingletonImmutableBiMap.java | 8 +- .../google/common/collect/SortedLists.java | 8 +- .../common/collect/SortedMultisets.java | 4 +- .../common/collect/SortedSetMultimap.java | 6 +- .../google/common/collect/StandardTable.java | 18 +- .../com/google/common/collect/Streams.java | 8 +- .../google/common/collect/Synchronized.java | 107 ++++----- .../src/com/google/common/collect/Table.java | 34 +-- .../src/com/google/common/collect/Tables.java | 34 +-- .../google/common/collect/TopKSelector.java | 6 +- .../google/common/collect/TreeBasedTable.java | 14 +- .../google/common/collect/TreeMultimap.java | 6 +- .../google/common/collect/TreeMultiset.java | 72 +++--- .../google/common/collect/TreeRangeMap.java | 26 +- .../google/common/collect/TreeRangeSet.java | 22 +- .../common/graph/AbstractBaseGraph.java | 8 +- .../AbstractDirectedNetworkConnections.java | 4 +- .../google/common/graph/AbstractGraph.java | 4 +- .../google/common/graph/AbstractNetwork.java | 8 +- .../common/graph/AbstractValueGraph.java | 4 +- .../common/graph/ConfigurableNetwork.java | 6 +- .../common/graph/ConfigurableValueGraph.java | 8 +- .../graph/DirectedGraphConnections.java | 10 +- .../DirectedMultiNetworkConnections.java | 6 +- .../google/common/graph/EdgesConnecting.java | 6 +- .../com/google/common/graph/ElementOrder.java | 8 +- .../com/google/common/graph/EndpointPair.java | 8 +- .../common/graph/ForwardingValueGraph.java | 6 +- guava/src/com/google/common/graph/Graph.java | 4 +- .../google/common/graph/GraphConnections.java | 4 +- guava/src/com/google/common/graph/Graphs.java | 13 +- .../google/common/graph/MapIteratorCache.java | 18 +- .../common/graph/MapRetrievalCache.java | 10 +- .../common/graph/MultiEdgesConnecting.java | 4 +- .../src/com/google/common/graph/Network.java | 6 +- .../com/google/common/graph/Traverser.java | 10 +- .../UndirectedMultiNetworkConnections.java | 6 +- .../com/google/common/graph/ValueGraph.java | 8 +- .../com/google/common/hash/BloomFilter.java | 4 +- .../common/hash/BloomFilterStrategies.java | 4 +- guava/src/com/google/common/hash/Funnels.java | 6 +- .../src/com/google/common/hash/HashCode.java | 4 +- guava/src/com/google/common/hash/Hashing.java | 4 +- .../common/hash/Murmur3_128HashFunction.java | 4 +- .../common/hash/Murmur3_32HashFunction.java | 4 +- .../google/common/hash/SipHashFunction.java | 4 +- .../src/com/google/common/hash/Striped64.java | 6 +- .../google/common/io/AppendableWriter.java | 10 +- .../com/google/common/io/BaseEncoding.java | 27 +-- .../src/com/google/common/io/CharSource.java | 4 +- .../src/com/google/common/io/Closeables.java | 8 +- guava/src/com/google/common/io/Closer.java | 4 +- .../common/io/FileBackedOutputStream.java | 4 +- .../io/InsecureRecursiveDeleteException.java | 4 +- .../src/com/google/common/io/LineReader.java | 4 +- guava/src/com/google/common/io/MoreFiles.java | 19 +- .../google/common/io/MultiInputStream.java | 6 +- .../src/com/google/common/io/MultiReader.java | 6 +- .../common/io/PatternFilenameFilter.java | 4 +- .../google/common/math/MathPreconditions.java | 16 +- .../com/google/common/math/PairedStats.java | 4 +- guava/src/com/google/common/math/Stats.java | 4 +- .../google/common/primitives/Booleans.java | 4 +- .../com/google/common/primitives/Bytes.java | 4 +- .../com/google/common/primitives/Chars.java | 4 +- .../com/google/common/primitives/Doubles.java | 6 +- .../com/google/common/primitives/Floats.java | 6 +- .../primitives/ImmutableDoubleArray.java | 6 +- .../common/primitives/ImmutableIntArray.java | 6 +- .../common/primitives/ImmutableLongArray.java | 6 +- .../com/google/common/primitives/Ints.java | 8 +- .../com/google/common/primitives/Longs.java | 8 +- .../com/google/common/primitives/Shorts.java | 10 +- .../common/primitives/UnsignedInteger.java | 4 +- .../common/primitives/UnsignedLong.java | 4 +- .../reflect/AbstractInvocationHandler.java | 4 +- .../com/google/common/reflect/ClassPath.java | 5 +- .../com/google/common/reflect/Element.java | 4 +- .../com/google/common/reflect/Invokable.java | 10 +- .../reflect/MutableTypeToInstanceMap.java | 20 +- .../com/google/common/reflect/Parameter.java | 8 +- .../google/common/reflect/TypeParameter.java | 4 +- .../google/common/reflect/TypeResolver.java | 4 +- .../common/reflect/TypeToInstanceMap.java | 14 +- .../com/google/common/reflect/TypeToken.java | 18 +- .../src/com/google/common/reflect/Types.java | 18 +- .../concurrent/AbstractCatchingFuture.java | 16 +- .../util/concurrent/AbstractFuture.java | 26 +- .../AbstractListeningExecutorService.java | 4 +- .../concurrent/AbstractScheduledService.java | 4 +- .../util/concurrent/AbstractService.java | 6 +- .../concurrent/AbstractTransformFuture.java | 20 +- .../util/concurrent/AggregateFuture.java | 7 +- .../common/util/concurrent/AsyncFunction.java | 4 +- .../common/util/concurrent/Atomics.java | 4 +- .../common/util/concurrent/Callables.java | 4 +- .../util/concurrent/CollectionFuture.java | 4 +- .../util/concurrent/CombinedFuture.java | 4 +- .../concurrent/CycleDetectingLockFactory.java | 4 +- .../util/concurrent/ExecutionError.java | 8 +- .../common/util/concurrent/ExecutionList.java | 7 +- .../util/concurrent/FutureCallback.java | 4 +- .../common/util/concurrent/Futures.java | 6 +- .../util/concurrent/FuturesGetChecked.java | 6 +- .../util/concurrent/ImmediateFuture.java | 10 +- .../util/concurrent/InterruptibleTask.java | 4 +- .../util/concurrent/ListenableFutureTask.java | 6 +- .../common/util/concurrent/Monitor.java | 5 +- .../common/util/concurrent/Platform.java | 4 +- .../util/concurrent/SettableFuture.java | 4 +- .../common/util/concurrent/TimeoutFuture.java | 8 +- .../TrustedListenableFutureTask.java | 4 +- .../UncheckedExecutionException.java | 8 +- .../concurrent/UncheckedTimeoutException.java | 8 +- pom.xml | 5 + 334 files changed, 1947 insertions(+), 2012 deletions(-) diff --git a/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java b/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java index 457e22bd4ef8..55f167eddd86 100644 --- a/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java +++ b/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java @@ -767,7 +767,7 @@ private static T invoke(Invokable factory, List args) T returnValue = factory.invoke(null, args.toArray()); if (returnValue == null) { Assert.assertTrue( - factory + " returns null but it's not annotated with @NullableDecl", isNullable(factory)); + factory + " returns null but it's not annotated with @Nullable", isNullable(factory)); } return returnValue; } diff --git a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java index c59b0c764119..a32a53b7b050 100644 --- a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java +++ b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java @@ -52,9 +52,8 @@ /** * A test utility that verifies that your methods and constructors throw {@link * NullPointerException} or {@link UnsupportedOperationException} whenever null is passed to a - * parameter that isn't annotated with {@link javax.annotation.Nullable}, {@link - * javax.annotation.CheckForNull}, or {@link - * org.checkerframework.checker.nullness.compatqual.NullableDecl}. + * parameter that isn't annotated with an annotation with the simple name {@code Nullable}, {@lcode + * CheckForNull}, {@link NullableType}, or {@link NullableDecl}. * *

The tested methods and constructors are invoked -- each time with one parameter being null and * the rest not null -- and the test fails if no expected exception is thrown. {@code diff --git a/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java b/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java index 17d9c9d13380..73d2cbc14239 100644 --- a/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java +++ b/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java @@ -477,7 +477,7 @@ public void testInstantiate_factoryMethodReturnsNullButNotAnnotated() throws Exc try { tester.instantiate(FactoryMethodReturnsNullButNotAnnotated.class); } catch (AssertionFailedError expected) { - assertThat(expected.getMessage()).contains("@NullableDecl"); + assertThat(expected.getMessage()).contains("@Nullable"); return; } fail("should have failed"); diff --git a/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java index a7767ed938de..c8d363444d15 100644 --- a/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java +++ b/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java @@ -85,8 +85,7 @@ public static void staticOneArgCheckForNullCorrectlyDoesNotThrowNPE( // null? no problem } - public static void staticOneArgJsr305NullableCorrectlyDoesNotThrowNPE( - @javax.annotation.Nullable String s) { + public static void staticOneArgJsr305NullableCorrectlyDoesNotThrowNPE(@NullableDecl String s) { // null? no problem } @@ -498,7 +497,7 @@ public void twoMixedArgsThrows(@NullableDecl Integer i, String s) { doThrow(i); } - public void twoNullableArgs(@NullableDecl String s, @javax.annotation.Nullable Integer i) {} + public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) {} public void twoNullableArgsThrowsFirstArg(@NullableDecl String s, @NullableDecl Integer i) { doThrow(s); diff --git a/android/guava/src/com/google/common/collect/LinkedListMultimap.java b/android/guava/src/com/google/common/collect/LinkedListMultimap.java index 63682cde7fd3..0434f67aa734 100644 --- a/android/guava/src/com/google/common/collect/LinkedListMultimap.java +++ b/android/guava/src/com/google/common/collect/LinkedListMultimap.java @@ -675,7 +675,7 @@ public void clear() { *

The returned list is not serializable and does not have random access. */ @Override - public List get(final @NullableDecl K key) { + public List get(@NullableDecl final K key) { return new AbstractSequentialList() { @Override public int size() { diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java index 3234a5103334..9e3c89e2b079 100644 --- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java +++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java @@ -14,11 +14,11 @@ package com.google.common.base; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Holder for extra methods of {@code Objects} only in web. */ abstract class ExtraObjectsMethodsForWeb { - public static boolean equal(@NullableDecl String a, @NullableDecl String b) { + public static boolean equal(@Nullable String a, @Nullable String b) { return a == b; } } diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Platform.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Platform.java index 5b63f57d6b02..d52b01a9ce1a 100644 --- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Platform.java +++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Platform.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsType; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** @author Jesse Wilson */ final class Platform { @@ -52,17 +52,17 @@ static String formatCompact4Digits(double value) { } @JsMethod - static native boolean stringIsNullOrEmpty(@NullableDecl String string) /*-{ + static native boolean stringIsNullOrEmpty(@Nullable String string) /*-{ return !string; }-*/; @JsMethod - static native String nullToEmpty(@NullableDecl String string) /*-{ + static native String nullToEmpty(@Nullable String string) /*-{ return string || ""; }-*/; @JsMethod - static native String emptyToNull(@NullableDecl String string) /*-{ + static native String emptyToNull(@Nullable String string) /*-{ return string || null; }-*/; diff --git a/guava-gwt/src-super/com/google/common/cache/super/com/google/common/cache/LocalCache.java b/guava-gwt/src-super/com/google/common/cache/super/com/google/common/cache/LocalCache.java index d6d2cbc34b7f..171a8c709537 100644 --- a/guava-gwt/src-super/com/google/common/cache/super/com/google/common/cache/LocalCache.java +++ b/guava-gwt/src-super/com/google/common/cache/super/com/google/common/cache/LocalCache.java @@ -39,7 +39,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * LocalCache emulation for GWT. @@ -375,7 +375,7 @@ public V get(K key, Callable valueLoader) throws ExecutionException } @Override - @NullableDecl + @Nullable public V getIfPresent(Object key) { return localCache.getIfPresent(key); } @@ -476,7 +476,7 @@ public CapacityEnforcingLinkedHashMap( boolean accessOrder, long maximumSize, StatsCounter statsCounter, - @NullableDecl RemovalListener removalListener) { + @Nullable RemovalListener removalListener) { super(initialCapacity, loadFactor, accessOrder); this.maximumSize = maximumSize; this.statsCounter = statsCounter; @@ -682,7 +682,7 @@ public V getValue() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { // Cannot use key and value equivalence if (object instanceof Entry) { Entry that = (Entry) object; diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/AbstractSortedMultiset.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/AbstractSortedMultiset.java index fbdac97b6c02..88cc5363182e 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/AbstractSortedMultiset.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/AbstractSortedMultiset.java @@ -20,7 +20,7 @@ import java.util.Comparator; import java.util.Iterator; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of the {@link SortedMultiset} interface. @@ -98,9 +98,9 @@ public Entry pollLastEntry() { @Override public SortedMultiset subMultiset( - @NullableDecl E fromElement, + @Nullable E fromElement, BoundType fromBoundType, - @NullableDecl E toElement, + @Nullable E toElement, BoundType toBoundType) { // These are checked elsewhere, but NullPointerTester wants them checked eagerly. checkNotNull(fromBoundType); diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableCollection.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableCollection.java index 5d95310f427b..a541c77fa135 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableCollection.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableCollection.java @@ -17,7 +17,7 @@ package com.google.common.collect; import java.util.Collection; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A GWT-only class only used by GWT emulations. It is used to consolidate the definitions of method @@ -40,7 +40,7 @@ public UnmodifiableIterator iterator() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && delegate.contains(object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableList.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableList.java index 9730d330ba25..a54c383f9d29 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableList.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableList.java @@ -18,7 +18,7 @@ import java.util.Collection; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT emulated version of {@link ImmutableList}. TODO(cpovirk): more doc @@ -31,11 +31,11 @@ abstract class ForwardingImmutableList extends ImmutableList { abstract List delegateList(); - public int indexOf(@NullableDecl Object object) { + public int indexOf(@Nullable Object object) { return delegateList().indexOf(object); } - public int lastIndexOf(@NullableDecl Object object) { + public int lastIndexOf(@Nullable Object object) { return delegateList().lastIndexOf(object); } @@ -70,7 +70,7 @@ public UnmodifiableIterator iterator() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && delegateList().contains(object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableMap.java index 7bac7c8d926b..68cce933d4d8 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableMap.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableMap.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT implementation of {@link ImmutableMap} that forwards to another map. @@ -57,15 +57,15 @@ public final boolean isEmpty() { return delegate.isEmpty(); } - public final boolean containsKey(@NullableDecl Object key) { + public final boolean containsKey(@Nullable Object key) { return Maps.safeContainsKey(delegate, key); } - public final boolean containsValue(@NullableDecl Object value) { + public final boolean containsValue(@Nullable Object value) { return delegate.containsValue(value); } - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return (key == null) ? null : Maps.safeGet(delegate, key); } @@ -119,7 +119,7 @@ public int size() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return delegate.equals(object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableSet.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableSet.java index 07d6f3f9a982..09fcd9e2cd67 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableSet.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ForwardingImmutableSet.java @@ -19,7 +19,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT implementation of {@link ImmutableSet} that forwards to another {@code Set} implementation. @@ -41,7 +41,7 @@ public UnmodifiableIterator iterator() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && delegate.contains(object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java index 4a151de64a32..83cb18f4f0b3 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.Spliterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT emulated version of {@link ImmutableCollection}. @@ -43,7 +43,7 @@ public abstract class ImmutableCollection extends AbstractCollection imple public abstract UnmodifiableIterator iterator(); - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && super.contains(object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java index 5ee490b82aa6..c2e69b4d7984 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.RandomAccess; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT emulated version of {@link com.google.common.collect.ImmutableList}. TODO(cpovirk): more doc @@ -216,12 +216,12 @@ private static List nullCheckedList(Object... array) { } @Override - public int indexOf(@NullableDecl Object object) { + public int indexOf(@Nullable Object object) { return (object == null) ? -1 : Lists.indexOfImpl(this, object); } @Override - public int lastIndexOf(@NullableDecl Object object) { + public int lastIndexOf(@Nullable Object object) { return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object); } @@ -272,7 +272,7 @@ public ImmutableList asList() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return Lists.equalsImpl(this, obj); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java index a7fed46b445e..1f9fe942f5ac 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java @@ -37,7 +37,7 @@ import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT emulation of {@link com.google.common.collect.ImmutableMap}. For non sorted maps, it is a @@ -283,12 +283,12 @@ public boolean isEmpty() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return values().contains(value); } @@ -368,12 +368,12 @@ public ImmutableSet keySet() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return ImmutableMap.this.containsKey(key); } @Override - public ImmutableSet get(@NullableDecl Object key) { + public ImmutableSet get(@Nullable Object key) { V outerValue = ImmutableMap.this.get(key); return (outerValue == null) ? null : ImmutableSet.of(outerValue); } @@ -422,7 +422,7 @@ ImmutableCollection createValues() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return Maps.equalsImpl(this, object); } diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedSet.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedSet.java index 3f15b36cf446..8eeaf4f25234 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedSet.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedSet.java @@ -29,7 +29,7 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * GWT emulation of {@link com.google.common.collect.ImmutableSortedSet}. @@ -270,7 +270,7 @@ public T[] toArray(T[] other) { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { try { // This set never contains null. We need to explicitly check here // because some comparator might throw NPE (e.g. the natural ordering). diff --git a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/AbstractFuture.java b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/AbstractFuture.java index 725aa1d5b8ee..cccd131d0c3f 100644 --- a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/AbstractFuture.java +++ b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/AbstractFuture.java @@ -32,7 +32,7 @@ import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Emulation for AbstractFuture in GWT. */ public abstract class AbstractFuture extends FluentFuture { @@ -192,7 +192,7 @@ final Throwable trustedGetException() { return throwable; } - final void maybePropagateCancellationTo(@NullableDecl Future related) { + final void maybePropagateCancellationTo(@Nullable Future related) { if (related != null & isCancelled()) { related.cancel(wasInterrupted()); } @@ -232,7 +232,7 @@ public String toString() { * * @return null if an explanation cannot be provided because the future is done. */ - @NullableDecl + @Nullable String pendingToString() { if (state == State.DELEGATED) { return "setFuture=[" + delegate + "]"; diff --git a/guava-gwt/src/com/google/common/base/GwtSerializationDependencies.java b/guava-gwt/src/com/google/common/base/GwtSerializationDependencies.java index dbe3fba050c8..69cf0d214e4e 100644 --- a/guava-gwt/src/com/google/common/base/GwtSerializationDependencies.java +++ b/guava-gwt/src/com/google/common/base/GwtSerializationDependencies.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Contains dummy collection implementations to convince GWT that part of serializing a collection @@ -34,7 +34,7 @@ final class GwtSerializationDependencies { private GwtSerializationDependencies() {} static final class OptionalDependencies extends Optional { - @NullableDecl T value; + @Nullable T value; OptionalDependencies() { super(); @@ -81,7 +81,7 @@ public Optional transform(Function function) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { throw new AssertionError(); } diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index 929f21aa7004..9e4cf9b1e397 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -22,6 +22,10 @@ org.checkerframework checker-compat-qual + + org.checkerframework + checker-qual + com.google.errorprone error_prone_annotations diff --git a/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java b/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java index bb801392dd48..6822a2716da9 100644 --- a/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java +++ b/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java @@ -36,7 +36,7 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.Supplier; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Tester for {@code Spliterator} implementations. */ @GwtCompatible @@ -104,7 +104,7 @@ void forEach(Spliterator spliterator, Consumer consumer) { abstract void forEach(Spliterator spliterator, Consumer consumer); } - @NullableDecl + @Nullable private static Spliterator trySplitTestingSize(Spliterator spliterator) { boolean subsized = spliterator.hasCharacteristics(Spliterator.SUBSIZED); long originalSize = spliterator.estimateSize(); diff --git a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java index ca5dd034358f..8e4b1fcb833e 100644 --- a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java +++ b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java @@ -146,7 +146,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Supplies an arbitrary "default" instance for a wide range of types, often useful in testing @@ -334,7 +334,7 @@ private static void setImplementation(Class type, Class impl } @SuppressWarnings("unchecked") // it's a subtype map - @NullableDecl + @Nullable private static Class getImplementation(Class type) { return (Class) implementations.get(type); } @@ -345,7 +345,7 @@ private static Class getImplementation(Class type) { * Returns an arbitrary instance for {@code type}, or {@code null} if no arbitrary instance can be * determined. */ - @NullableDecl + @Nullable public static T get(Class type) { T defaultValue = DEFAULTS.getInstance(type); if (defaultValue != null) { @@ -389,7 +389,7 @@ public static T get(Class type) { } } - @NullableDecl + @Nullable private static T arbitraryConstantInstanceOrNull(Class type) { Field[] fields = type.getDeclaredFields(); Arrays.sort(fields, BY_FIELD_NAME); diff --git a/guava-testlib/src/com/google/common/testing/CollectorTester.java b/guava-testlib/src/com/google/common/testing/CollectorTester.java index c25012ed5d0d..9478a1fd20cf 100644 --- a/guava-testlib/src/com/google/common/testing/CollectorTester.java +++ b/guava-testlib/src/com/google/common/testing/CollectorTester.java @@ -29,7 +29,7 @@ import java.util.Objects; import java.util.function.BiPredicate; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tester for {@code Collector} implementations. @@ -140,8 +140,7 @@ E pop(List stack) { * inputs, regardless of how the elements are divided. */ @SafeVarargs - public final CollectorTester expectCollects( - @NullableDecl R expectedResult, T... inputs) { + public final CollectorTester expectCollects(@Nullable R expectedResult, T... inputs) { List list = Arrays.asList(inputs); doExpectCollects(expectedResult, list); if (collector.characteristics().contains(Collector.Characteristics.UNORDERED)) { @@ -151,7 +150,7 @@ public final CollectorTester expectCollects( return this; } - private void doExpectCollects(@NullableDecl R expectedResult, List inputs) { + private void doExpectCollects(@Nullable R expectedResult, List inputs) { for (CollectStrategy scheme : EnumSet.allOf(CollectStrategy.class)) { A finalAccum = scheme.result(collector, inputs); if (collector.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { @@ -161,7 +160,7 @@ private void doExpectCollects(@NullableDecl R expectedResult, List inputs) { } } - private void assertEquivalent(@NullableDecl R expected, @NullableDecl R actual) { + private void assertEquivalent(@Nullable R expected, @Nullable R actual) { assertTrue( "Expected " + expected + " got " + actual + " modulo equivalence " + equivalence, equivalence.test(expected, actual)); diff --git a/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java b/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java index 88f3159229e8..af0131d38b34 100644 --- a/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java +++ b/guava-testlib/src/com/google/common/testing/FreshValueGenerator.java @@ -122,7 +122,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Generates fresh instances of types that are different from each other (if possible). @@ -179,7 +179,7 @@ final void addSampleInstances(Class type, Iterable instances *

  • null if no value can be generated. * */ - @NullableDecl + @Nullable final Object generateFresh(TypeToken type) { Object generated = generate(type); if (generated != null) { @@ -188,7 +188,7 @@ final Object generateFresh(TypeToken type) { return generated; } - @NullableDecl + @Nullable final T generateFresh(Class type) { return Primitives.wrap(type).cast(generateFresh(TypeToken.of(type))); } @@ -303,7 +303,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof FreshInvocationHandler) { FreshInvocationHandler that = (FreshInvocationHandler) obj; return identity == that.identity; diff --git a/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/guava-testlib/src/com/google/common/testing/NullPointerTester.java index bf525c269f88..cd0dd15a6137 100644 --- a/guava-testlib/src/com/google/common/testing/NullPointerTester.java +++ b/guava-testlib/src/com/google/common/testing/NullPointerTester.java @@ -46,14 +46,13 @@ import java.util.concurrent.ConcurrentMap; import junit.framework.Assert; import junit.framework.AssertionFailedError; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A test utility that verifies that your methods and constructors throw {@link * NullPointerException} or {@link UnsupportedOperationException} whenever null is passed to a - * parameter that isn't annotated with {@link javax.annotation.Nullable}, {@link - * javax.annotation.CheckForNull}, or {@link - * org.checkerframework.checker.nullness.compatqual.NullableDecl}. + * parameter whose declaration or type isn't annotated with an annotation with the simple name + * {@code Nullable}, {@lcode CheckForNull}, {@link NullableType}, or {@link NullableDecl}. * *

    The tested methods and constructors are invoked -- each time with one parameter being null and * the rest not null -- and the test fails if no expected exception is thrown. {@code @@ -176,7 +175,7 @@ public void testAllPublicInstanceMethods(Object instance) { * * @param instance the instance to invoke {@code method} on, or null if {@code method} is static */ - public void testMethod(@NullableDecl Object instance, Method method) { + public void testMethod(@Nullable Object instance, Method method) { Class[] types = method.getParameterTypes(); for (int nullIndex = 0; nullIndex < types.length; nullIndex++) { testMethodParameter(instance, method, nullIndex); @@ -208,7 +207,7 @@ public void testConstructor(Constructor ctor) { * @param instance the instance to invoke {@code method} on, or null if {@code method} is static */ public void testMethodParameter( - @NullableDecl final Object instance, final Method method, int paramIndex) { + @Nullable final Object instance, final Method method, int paramIndex) { method.setAccessible(true); testParameter(instance, invokable(instance, method), paramIndex, method.getDeclaringClass()); } @@ -461,7 +460,7 @@ R dummyReturnValue(TypeToken returnType) { }.newProxy(type); } - private static Invokable invokable(@NullableDecl Object instance, Method method) { + private static Invokable invokable(@Nullable Object instance, Method method) { if (instance == null) { return Invokable.from(method); } else { @@ -503,7 +502,7 @@ private boolean isIgnored(Member member) { * Returns true if the the given member is a method that overrides {@link Object#equals(Object)}. * *

    The documentation for {@link Object#equals} says it should accept null, so don't require an - * explicit {@code @NullableDecl} annotation (see #1819). * *

    It is not necessary to consider visibility, return type, or type parameter declarations. The diff --git a/guava-testlib/src/com/google/common/testing/TestLogHandler.java b/guava-testlib/src/com/google/common/testing/TestLogHandler.java index c03093be52f3..e63d11fa5067 100644 --- a/guava-testlib/src/com/google/common/testing/TestLogHandler.java +++ b/guava-testlib/src/com/google/common/testing/TestLogHandler.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.logging.Handler; import java.util.logging.LogRecord; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests may use this to intercept messages that are logged by the code under test. Example: @@ -60,7 +60,7 @@ public class TestLogHandler extends Handler { /** Adds the most recently logged record to our list. */ @Override - public synchronized void publish(@NullableDecl LogRecord record) { + public synchronized void publish(@Nullable LogRecord record) { list.add(record); } diff --git a/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java b/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java index be9b7289a695..4c7a2f593833 100644 --- a/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java +++ b/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java @@ -38,7 +38,7 @@ import java.util.stream.Stream; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit tests for {@link ClassSanityTester}. @@ -60,7 +60,7 @@ public static Object good( // oneConstantOnly doesn't matter since it's not nullable and can be only 1 value. @SuppressWarnings("unused") OneConstantEnum oneConstantOnly, // noConstant doesn't matter since it can only be null - @SuppressWarnings("unused") @NullableDecl NoConstantEnum noConstant) { + @SuppressWarnings("unused") @Nullable NoConstantEnum noConstant) { return new GoodEquals(a, b); } // instance method ignored @@ -107,7 +107,7 @@ public void testEqualsOnReturnValues_bad() throws Exception { private static class BadEqualsFactory { /** oneConstantOnly matters now since it can be either null or the constant. */ @SuppressWarnings("unused") // Called by reflection - public static Object bad(String a, int b, @NullableDecl OneConstantEnum oneConstantOnly) { + public static Object bad(String a, int b, @Nullable OneConstantEnum oneConstantOnly) { return new GoodEquals(a, b); } } @@ -287,7 +287,7 @@ public void testEqualsAndSerializableForReturnValues_factoryReturnsNullAndAnnota } public static class FactoryThatReturnsNullAndAnnotated { - @NullableDecl + @Nullable public static Object bad() { return null; } @@ -483,7 +483,7 @@ public void testInstantiate_factoryMethodReturnsNullButNotAnnotated() throws Exc try { tester.instantiate(FactoryMethodReturnsNullButNotAnnotated.class); } catch (AssertionFailedError expected) { - assertThat(expected.getMessage()).contains("@NullableDecl"); + assertThat(expected.getMessage()).contains("@Nullable"); return; } fail("should have failed"); @@ -620,7 +620,7 @@ public HasAnInterface(AnInterface i) { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof HasAnInterface) { HasAnInterface that = (HasAnInterface) obj; return i.equals(that.i); @@ -677,7 +677,7 @@ private abstract static class Wrapper { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { // In general getClass().isInstance() is bad for equals. // But here we fully control the subclasses to ensure symmetry. if (getClass().isInstance(obj)) { @@ -757,13 +757,13 @@ static GoodEquals create(String a, int b) { // keep trying @SuppressWarnings("unused") - @NullableDecl + @Nullable public static GoodEquals createMayReturnNull(int a, int b) { return null; } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof GoodEquals) { GoodEquals that = (GoodEquals) obj; return a.equals(that.a) && b == that.b; @@ -782,12 +782,12 @@ static class BadEquals { public BadEquals() {} // ignored by testEquals() since it has less parameters. - public static BadEquals create(@SuppressWarnings("unused") @NullableDecl String s) { + public static BadEquals create(@SuppressWarnings("unused") @Nullable String s) { return new BadEquals(); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof BadEquals; } @@ -1136,7 +1136,7 @@ public static BadEqualsWithParameterizedType create( } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof BadEqualsWithParameterizedType; } @@ -1170,12 +1170,12 @@ public NoNullCheckNeededDespitNotInstantiable(NotInstantiable x) { void primitiveOnly(int i) {} @SuppressWarnings("unused") // reflected - void nullableOnly(@NullableDecl String s) {} + void nullableOnly(@Nullable String s) {} public void noParameter() {} @SuppressWarnings("unused") // reflected - void primitiveAndNullable(@NullableDecl String s, int i) {} + void primitiveAndNullable(@Nullable String s, int i) {} } static class FactoryMethodReturnsNullButNotAnnotated { @@ -1189,7 +1189,7 @@ static FactoryMethodReturnsNullButNotAnnotated returnsNull() { static class FactoryMethodReturnsNullAndAnnotated { private FactoryMethodReturnsNullAndAnnotated() {} - @NullableDecl + @Nullable public static FactoryMethodReturnsNullAndAnnotated returnsNull() { return null; } @@ -1203,7 +1203,7 @@ private FactoryMethodAcceptsNull(String name) { this.name = name; } - static FactoryMethodAcceptsNull create(@NullableDecl String name) { + static FactoryMethodAcceptsNull create(@Nullable String name) { return new FactoryMethodAcceptsNull(name); } } @@ -1225,7 +1225,7 @@ static class ConstructorAcceptsNull { final String name; - public ConstructorAcceptsNull(@NullableDecl String name) { + public ConstructorAcceptsNull(@Nullable String name) { this.name = name; } } @@ -1251,7 +1251,7 @@ public ConstructorParameterMapOfNotInstantiable(Map } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { throw new UnsupportedOperationException(); } diff --git a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java index 81261e516caa..8c18c1ebab9e 100644 --- a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java +++ b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java @@ -46,7 +46,7 @@ import java.util.SortedSet; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@link NullPointerTester}. @@ -90,7 +90,7 @@ public static void staticOneArgJsr305NullableCorrectlyDoesNotThrowNPE( // null? no problem } - public static void staticOneArgNullableCorrectlyDoesNotThrowNPE(@NullableDecl String s) { + public static void staticOneArgNullableCorrectlyDoesNotThrowNPE(@Nullable String s) { // null? no problem } @@ -99,7 +99,7 @@ public static void staticOneArgCheckForNullCorrectlyThrowsOtherThanNPE( throw new FooException(); // ok, as long as it's not NullPointerException } - public static void staticOneArgNullableCorrectlyThrowsOtherThanNPE(@NullableDecl String s) { + public static void staticOneArgNullableCorrectlyThrowsOtherThanNPE(@Nullable String s) { throw new FooException(); // ok, as long as it's not NullPointerException } @@ -107,7 +107,7 @@ public static void staticOneArgCheckForNullThrowsNPE(@javax.annotation.CheckForN checkNotNull(s); // doesn't check if you said you'd accept null, but you don't } - public static void staticOneArgNullableThrowsNPE(@NullableDecl String s) { + public static void staticOneArgNullableThrowsNPE(@Nullable String s) { checkNotNull(s); // doesn't check if you said you'd accept null, but you don't } @@ -128,7 +128,7 @@ public void oneArgCheckForNullCorrectlyDoesNotThrowNPE( // null? no problem } - public void oneArgNullableCorrectlyDoesNotThrowNPE(@NullableDecl String s) { + public void oneArgNullableCorrectlyDoesNotThrowNPE(@Nullable String s) { // null? no problem } @@ -137,7 +137,7 @@ public void oneArgCheckForNullCorrectlyThrowsOtherThanNPE( throw new FooException(); // ok, as long as it's not NullPointerException } - public void oneArgNullableCorrectlyThrowsOtherThanNPE(@NullableDecl String s) { + public void oneArgNullableCorrectlyThrowsOtherThanNPE(@Nullable String s) { throw new FooException(); // ok, as long as it's not NullPointerException } @@ -145,7 +145,7 @@ public void oneArgCheckForNullThrowsNPE(@javax.annotation.CheckForNull String s) checkNotNull(s); // doesn't check if you said you'd accept null, but you don't } - public void oneArgNullableThrowsNPE(@NullableDecl String s) { + public void oneArgNullableThrowsNPE(@Nullable String s) { checkNotNull(s); // doesn't check if you said you'd accept null, but you don't } } @@ -397,17 +397,17 @@ public void normalNormal(String first, Integer second) { } /** Two-arg method with the second param Nullable. */ - public void normalNullable(String first, @NullableDecl Integer second) { + public void normalNullable(String first, @Nullable Integer second) { reactToNullParameters(first, second); } /** Two-arg method with the first param Nullable. */ - public void nullableNormal(@NullableDecl String first, Integer second) { + public void nullableNormal(@Nullable String first, Integer second) { reactToNullParameters(first, second); } /** Two-arg method with the both params Nullable. */ - public void nullableNullable(@NullableDecl String first, @NullableDecl Integer second) { + public void nullableNullable(@Nullable String first, @Nullable Integer second) { reactToNullParameters(first, second); } @@ -521,9 +521,9 @@ protected void protectedOneArg(String s) { checkNotNull(s); } - public void oneNullableArg(@NullableDecl String s) {} + public void oneNullableArg(@Nullable String s) {} - public void oneNullableArgThrows(@NullableDecl String s) { + public void oneNullableArgThrows(@Nullable String s) { doThrow(s); } @@ -532,31 +532,31 @@ public void twoArg(String s, Integer i) { i.intValue(); } - public void twoMixedArgs(String s, @NullableDecl Integer i) { + public void twoMixedArgs(String s, @Nullable Integer i) { checkNotNull(s); } - public void twoMixedArgs(@NullableDecl Integer i, String s) { + public void twoMixedArgs(@Nullable Integer i, String s) { checkNotNull(s); } - public void twoMixedArgsThrows(String s, @NullableDecl Integer i) { + public void twoMixedArgsThrows(String s, @Nullable Integer i) { checkNotNull(s); doThrow(i); } - public void twoMixedArgsThrows(@NullableDecl Integer i, String s) { + public void twoMixedArgsThrows(@Nullable Integer i, String s) { checkNotNull(s); doThrow(i); } - public void twoNullableArgs(@NullableDecl String s, @javax.annotation.Nullable Integer i) {} + public void twoNullableArgs(@Nullable String s, @javax.annotation.Nullable Integer i) {} - public void twoNullableArgsThrowsFirstArg(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgsThrowsFirstArg(@Nullable String s, @Nullable Integer i) { doThrow(s); } - public void twoNullableArgsThrowsSecondArg(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgsThrowsSecondArg(@Nullable String s, @Nullable Integer i) { doThrow(i); } @@ -564,9 +564,9 @@ public static void staticOneArg(String s) { checkNotNull(s); } - public static void staticOneNullableArg(@NullableDecl String s) {} + public static void staticOneNullableArg(@Nullable String s) {} - public static void staticOneNullableArgThrows(@NullableDecl String s) { + public static void staticOneNullableArgThrows(@Nullable String s) { doThrow(s); } } @@ -599,7 +599,7 @@ public void testFailOneArgThrowsWrongType() { private static class PassOneNullableArgThrowsNPE extends PassObject { @Override - public void oneNullableArg(@NullableDecl String s) { + public void oneNullableArg(@Nullable String s) { checkNotNull(s); // ok to throw NPE } } @@ -658,7 +658,7 @@ public void testFailTwoArgsSecondArgThrowsWrongType() { private static class FailTwoMixedArgsFirstArgDoesntThrowNPE extends PassObject { @Override - public void twoMixedArgs(String s, @NullableDecl Integer i) { + public void twoMixedArgs(String s, @Nullable Integer i) { // Fail: missing NPE for s } } @@ -669,7 +669,7 @@ public void testFailTwoMixedArgsFirstArgDoesntThrowNPE() { private static class FailTwoMixedArgsFirstArgThrowsWrongType extends PassObject { @Override - public void twoMixedArgs(String s, @NullableDecl Integer i) { + public void twoMixedArgs(String s, @Nullable Integer i) { doThrow(s); // Fail: throwing non-NPE exception for null s } } @@ -680,7 +680,7 @@ public void testFailTwoMixedArgsFirstArgThrowsWrongType() { private static class PassTwoMixedArgsNullableArgThrowsNPE extends PassObject { @Override - public void twoMixedArgs(String s, @NullableDecl Integer i) { + public void twoMixedArgs(String s, @Nullable Integer i) { checkNotNull(s); i.intValue(); // ok to throw NPE? } @@ -692,7 +692,7 @@ public void testPassTwoMixedArgsNullableArgThrowsNPE() { private static class PassTwoMixedArgSecondNullableArgThrowsOther extends PassObject { @Override - public void twoMixedArgs(String s, @NullableDecl Integer i) { + public void twoMixedArgs(String s, @Nullable Integer i) { checkNotNull(s); doThrow(i); // ok to throw non-NPE exception for null i } @@ -704,7 +704,7 @@ public void testPassTwoMixedArgSecondNullableArgThrowsOther() { private static class FailTwoMixedArgsSecondArgDoesntThrowNPE extends PassObject { @Override - public void twoMixedArgs(@NullableDecl Integer i, String s) { + public void twoMixedArgs(@Nullable Integer i, String s) { // Fail: missing NPE for null s } } @@ -715,7 +715,7 @@ public void testFailTwoMixedArgsSecondArgDoesntThrowNPE() { private static class FailTwoMixedArgsSecondArgThrowsWrongType extends PassObject { @Override - public void twoMixedArgs(@NullableDecl Integer i, String s) { + public void twoMixedArgs(@Nullable Integer i, String s) { doThrow(s); // Fail: throwing non-NPE exception for null s } } @@ -726,7 +726,7 @@ public void testFailTwoMixedArgsSecondArgThrowsWrongType() { private static class PassTwoNullableArgsFirstThrowsNPE extends PassObject { @Override - public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgs(@Nullable String s, @Nullable Integer i) { checkNotNull(s); // ok to throw NPE? } } @@ -737,7 +737,7 @@ public void testPassTwoNullableArgsFirstThrowsNPE() { private static class PassTwoNullableArgsFirstThrowsOther extends PassObject { @Override - public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgs(@Nullable String s, @Nullable Integer i) { doThrow(s); // ok to throw non-NPE exception for null s } } @@ -748,7 +748,7 @@ public void testPassTwoNullableArgsFirstThrowsOther() { private static class PassTwoNullableArgsSecondThrowsNPE extends PassObject { @Override - public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgs(@Nullable String s, @Nullable Integer i) { i.intValue(); // ok to throw NPE? } } @@ -759,7 +759,7 @@ public void testPassTwoNullableArgsSecondThrowsNPE() { private static class PassTwoNullableArgsSecondThrowsOther extends PassObject { @Override - public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgs(@Nullable String s, @Nullable Integer i) { doThrow(i); // ok to throw non-NPE exception for null i } } @@ -770,7 +770,7 @@ public void testPassTwoNullableArgsSecondThrowsOther() { private static class PassTwoNullableArgsNeitherThrowsAnything extends PassObject { @Override - public void twoNullableArgs(@NullableDecl String s, @NullableDecl Integer i) { + public void twoNullableArgs(@Nullable String s, @Nullable Integer i) { // ok to do nothing } } @@ -816,7 +816,7 @@ public void testSubclassWithBadSuperclassForPackageProtectedMethod() { private static class SubclassThatOverridesBadSuperclassMethod extends BaseClassThatFailsToThrow { @Override - public void oneArg(@NullableDecl String s) {} + public void oneArg(@Nullable String s) {} } public void testSubclassThatOverridesBadSuperclassMethod() { @@ -825,7 +825,7 @@ public void testSubclassThatOverridesBadSuperclassMethod() { @SuppressWarnings("unused") // for NullPointerTester private static class SubclassOverridesTheWrongMethod extends BaseClassThatFailsToThrow { - public void oneArg(@NullableDecl CharSequence s) {} + public void oneArg(@Nullable CharSequence s) {} } public void testSubclassOverridesTheWrongMethod() { @@ -849,7 +849,7 @@ public void testSubclassThatFailsToThrowForStatic() { private static class SubclassThatTriesToOverrideBadStaticMethod extends ClassThatFailsToThrowForStatic { - static void staticOneArg(@NullableDecl String s) {} + static void staticOneArg(@Nullable String s) {} } public void testSubclassThatTriesToOverrideBadStaticMethod() { @@ -862,7 +862,7 @@ private HardToCreate(HardToCreate x) {} @SuppressWarnings("unused") // used by reflection private static class CanCreateDefault { - public void foo(@NullableDecl HardToCreate ignored, String required) { + public void foo(@Nullable HardToCreate ignored, String required) { checkNotNull(required); } } @@ -925,7 +925,7 @@ private static void shouldFail(Class cls) { @SuppressWarnings("unused") // used by reflection private static class PrivateClassWithPrivateConstructor { - private PrivateClassWithPrivateConstructor(@NullableDecl Integer argument) {} + private PrivateClassWithPrivateConstructor(@Nullable Integer argument) {} } public void testPrivateClass() { diff --git a/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java b/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java index 5b713f26b64f..322dd547f6d1 100644 --- a/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java +++ b/guava-tests/benchmark/com/google/common/collect/ConcurrentHashMultisetBenchmark.java @@ -37,7 +37,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Benchmarks for {@link ConcurrentHashMultiset}. @@ -192,7 +192,7 @@ public static OldConcurrentHashMultiset create() { * @return the nonnegative number of occurrences of the element */ @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { try { return unbox(countMap.get(element)); } catch (NullPointerException | ClassCastException e) { @@ -295,7 +295,7 @@ public int add(E element, int occurrences) { * @throws IllegalArgumentException if {@code occurrences} is negative */ @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { if (occurrences == 0) { return count(element); } @@ -330,7 +330,7 @@ public int remove(@NullableDecl Object element, int occurrences) { * @param element the element whose occurrences should all be removed * @return the number of occurrences successfully removed, possibly zero */ - private int removeAllOccurrences(@NullableDecl Object element) { + private int removeAllOccurrences(@Nullable Object element) { try { return unbox(countMap.remove(element)); } catch (NullPointerException | ClassCastException e) { @@ -349,7 +349,7 @@ private int removeAllOccurrences(@NullableDecl Object element) { * @param occurrences the number of occurrences of {@code element} to remove * @return {@code true} if the removal was possible (including if {@code occurrences} is zero) */ - public boolean removeExactly(@NullableDecl Object element, int occurrences) { + public boolean removeExactly(@Nullable Object element, int occurrences) { if (occurrences == 0) { return true; } @@ -543,7 +543,7 @@ public int hashCode() { } /** We use a special form of unboxing that treats null as zero. */ - private static int unbox(@NullableDecl Integer i) { + private static int unbox(@Nullable Integer i) { return (i == null) ? 0 : i; } } diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java b/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java index e1b94a3a1fef..02db8fdb9df7 100644 --- a/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java +++ b/guava-tests/benchmark/com/google/common/util/concurrent/ExecutionListBenchmark.java @@ -38,7 +38,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Benchmarks for {@link ExecutionList}. */ @VmOptions({"-Xms8g", "-Xmx8g"}) @@ -488,7 +488,7 @@ private static void executeListener(Runnable runnable, Executor executor) { private static final class RunnableExecutorPair { final Runnable runnable; final Executor executor; - @NullableDecl RunnableExecutorPair next; + @Nullable RunnableExecutorPair next; RunnableExecutorPair(Runnable runnable, Executor executor, RunnableExecutorPair next) { this.runnable = runnable; @@ -563,7 +563,7 @@ private static void executeListener(Runnable runnable, Executor executor) { private static final class RunnableExecutorPair { Runnable runnable; Executor executor; - @NullableDecl RunnableExecutorPair next; + @Nullable RunnableExecutorPair next; RunnableExecutorPair(Runnable runnable, Executor executor) { this.runnable = runnable; @@ -669,7 +669,7 @@ private static class RunnableExecutorPair { final Runnable runnable; final Executor executor; // Volatile because this is written on one thread and read on another with no synchronization. - @NullableDecl volatile RunnableExecutorPair next; + @Nullable volatile RunnableExecutorPair next; RunnableExecutorPair(Runnable runnable, Executor executor) { this.runnable = runnable; diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java index 7998a729f3b9..c1e5201d788c 100644 --- a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java +++ b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedArrayBlockingQueue.java @@ -25,7 +25,7 @@ import java.util.NoSuchElementException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A bounded {@linkplain BlockingQueue blocking queue} backed by an array. This queue orders @@ -388,7 +388,7 @@ public int remainingCapacity() { * @return true if this queue changed as a result of the call */ @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o == null) return false; final E[] items = this.items; final Monitor monitor = this.monitor; @@ -418,7 +418,7 @@ public boolean remove(@NullableDecl Object o) { * @return true if this queue contains the specified element */ @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o == null) return false; final E[] items = this.items; final Monitor monitor = this.monitor; diff --git a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java index 715a9c815097..6e063466be0a 100644 --- a/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java +++ b/guava-tests/benchmark/com/google/common/util/concurrent/MonitorBasedPriorityBlockingQueue.java @@ -30,7 +30,7 @@ import java.util.SortedSet; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An unbounded {@linkplain BlockingQueue blocking queue} that uses the same ordering rules as class @@ -124,7 +124,7 @@ public MonitorBasedPriorityBlockingQueue(int initialCapacity) { * @throws IllegalArgumentException if initialCapacity is less than 1 */ public MonitorBasedPriorityBlockingQueue( - int initialCapacity, @NullableDecl Comparator comparator) { + int initialCapacity, @Nullable Comparator comparator) { q = new PriorityQueue(initialCapacity, comparator); } @@ -303,7 +303,7 @@ public int remainingCapacity() { * @return true if this queue changed as a result of the call */ @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { final Monitor monitor = this.monitor; monitor.enter(); try { @@ -322,7 +322,7 @@ public boolean remove(@NullableDecl Object o) { * @return true if this queue contains the specified element */ @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { final Monitor monitor = this.monitor; monitor.enter(); try { diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index f0fc113fbf2a..ac08292fba56 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -29,6 +29,10 @@ org.checkerframework checker-compat-qual + + org.checkerframework + checker-qual + com.google.errorprone error_prone_annotations diff --git a/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java b/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java index 04b6f1ef5d6a..5426ced0eab3 100644 --- a/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java +++ b/guava-tests/test/com/google/common/cache/CacheBuilderFactory.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Helper class for creating {@link CacheBuilder} instances with all combinations of several sets of @@ -120,7 +120,7 @@ public CacheBuilder apply(List combination) { private static final Function> NULLABLE_TO_OPTIONAL = new Function>() { @Override - public Optional apply(@NullableDecl Object obj) { + public Optional apply(@Nullable Object obj) { return Optional.fromNullable(obj); } }; diff --git a/guava-tests/test/com/google/common/cache/CacheTesting.java b/guava-tests/test/com/google/common/cache/CacheTesting.java index d7a3b4abeb57..3616e5115516 100644 --- a/guava-tests/test/com/google/common/cache/CacheTesting.java +++ b/guava-tests/test/com/google/common/cache/CacheTesting.java @@ -44,7 +44,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReferenceArray; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection of utilities for {@link Cache} testing. @@ -367,7 +367,7 @@ static void processPendingNotifications(Cache cache) { } interface Receiver { - void accept(@NullableDecl T object); + void accept(@Nullable T object); } /** diff --git a/guava-tests/test/com/google/common/cache/TestingCacheLoaders.java b/guava-tests/test/com/google/common/cache/TestingCacheLoaders.java index 8507e68f2eb9..e4a06c9cb252 100644 --- a/guava-tests/test/com/google/common/cache/TestingCacheLoaders.java +++ b/guava-tests/test/com/google/common/cache/TestingCacheLoaders.java @@ -23,7 +23,7 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Utility {@link CacheLoader} implementations intended for use in testing. @@ -57,7 +57,7 @@ public Map loadAll(Iterable keys) throws Exception { } /** Returns a {@link CacheLoader} that returns the given {@code constant} for every request. */ - static ConstantLoader constantLoader(@NullableDecl V constant) { + static ConstantLoader constantLoader(@Nullable V constant) { return new ConstantLoader<>(constant); } diff --git a/guava-tests/test/com/google/common/collect/FluentIterableTest.java b/guava-tests/test/com/google/common/collect/FluentIterableTest.java index 4314bed452b4..6a9c2d73f6ec 100644 --- a/guava-tests/test/com/google/common/collect/FluentIterableTest.java +++ b/guava-tests/test/com/google/common/collect/FluentIterableTest.java @@ -44,7 +44,7 @@ import java.util.stream.Stream; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@link FluentIterable}. @@ -854,7 +854,7 @@ public void testUniqueIndex_nullValue() { .uniqueIndex( new Function() { @Override - public Object apply(@NullableDecl Integer input) { + public Object apply(@Nullable Integer input) { return String.valueOf(input); } }); diff --git a/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java b/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java index d0673f1d0d7c..4f69dea94dca 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java @@ -30,7 +30,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link ForwardingSortedMultiset}. @@ -93,12 +93,12 @@ public SortedMultiset subMultiset( } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { return standardCount(element); } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return standardEquals(object); } @@ -123,7 +123,7 @@ public void clear() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return standardContains(object); } @@ -143,7 +143,7 @@ public Iterator iterator() { } @Override - public boolean remove(@NullableDecl Object object) { + public boolean remove(@Nullable Object object) { return standardRemove(object); } diff --git a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java index 279b80ca85af..319512ad277a 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java @@ -50,7 +50,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link ImmutableBiMap}. @@ -656,7 +656,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object other) { + public boolean equals(@Nullable Object other) { onEquals.run(); return other instanceof CountsHashCodeAndEquals && delegateString.equals(((CountsHashCodeAndEquals) other).delegateString); diff --git a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java index 3836eafacbc6..c6395b40b555 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java @@ -67,7 +67,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link ImmutableMap}. @@ -871,7 +871,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object other) { + public boolean equals(@Nullable Object other) { onEquals.run(); return other instanceof CountsHashCodeAndEquals && delegateString.equals(((CountsHashCodeAndEquals) other).delegateString); diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java index 7888c82a5ac0..07223b8479bf 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java @@ -50,7 +50,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link ImmutableMultiset}. @@ -694,7 +694,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object other) { + public boolean equals(@Nullable Object other) { onEquals.run(); return other instanceof CountsHashCodeAndEquals && delegateString.equals(((CountsHashCodeAndEquals) other).delegateString); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java index d0cbb66f5709..6a38fcdb5896 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java @@ -48,7 +48,7 @@ import java.util.stream.Collector; import junit.framework.Test; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@link ImmutableSet}. @@ -404,7 +404,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object other) { + public boolean equals(@Nullable Object other) { onEquals.run(); return other instanceof CountsHashCodeAndEquals && delegateString.equals(((CountsHashCodeAndEquals) other).delegateString); diff --git a/guava-tests/test/com/google/common/collect/MapsCollectionTest.java b/guava-tests/test/com/google/common/collect/MapsCollectionTest.java index 54aa1aa2e65e..1e600647b6fc 100644 --- a/guava-tests/test/com/google/common/collect/MapsCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/MapsCollectionTest.java @@ -52,7 +52,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Test suites for wrappers in {@code Maps}. @@ -561,7 +561,7 @@ static void putEntries(Map map, Entry[] entries) static final Predicate FILTER_KEYS = new Predicate() { @Override - public boolean apply(@NullableDecl String string) { + public boolean apply(@Nullable String string) { return !"banana".equals(string) && !"eggplant".equals(string); } }; @@ -569,7 +569,7 @@ public boolean apply(@NullableDecl String string) { static final Predicate FILTER_VALUES = new Predicate() { @Override - public boolean apply(@NullableDecl String string) { + public boolean apply(@Nullable String string) { return !"toast".equals(string) && !"spam".equals(string); } }; diff --git a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java index d81f546c55cb..eec27251e5ec 100644 --- a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java +++ b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link Maps#transformValues}. @@ -156,7 +156,7 @@ public void testTransformEqualityOfMapsWithNullValues() { underlying, new Function() { @Override - public Boolean apply(@NullableDecl String from) { + public Boolean apply(@Nullable String from) { return from == null; } }); @@ -274,7 +274,7 @@ public void testTransformEntrySetContains() { underlying, new Function() { @Override - public Boolean apply(@NullableDecl Boolean from) { + public Boolean apply(@Nullable Boolean from) { return (from == null) ? true : null; } }); diff --git a/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java b/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java index 81a2d935bdbf..271b3b31d8ee 100644 --- a/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java +++ b/guava-tests/test/com/google/common/collect/MapsTransformValuesUnmodifiableIteratorTest.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link Maps#transformValues} when the backing map's views have iterators that don't @@ -232,7 +232,7 @@ public void testTransformEqualityOfMapsWithNullValues() { underlying, new Function() { @Override - public Boolean apply(@NullableDecl String from) { + public Boolean apply(@Nullable String from) { return from == null; } }); @@ -350,7 +350,7 @@ public void testTransformEntrySetContains() { underlying, new Function() { @Override - public Boolean apply(@NullableDecl Boolean from) { + public Boolean apply(@Nullable Boolean from) { return (from == null) ? true : null; } }); diff --git a/guava-tests/test/com/google/common/collect/MultimapsTest.java b/guava-tests/test/com/google/common/collect/MultimapsTest.java index 2ebd31664377..6fa9c3c8b9f8 100644 --- a/guava-tests/test/com/google/common/collect/MultimapsTest.java +++ b/guava-tests/test/com/google/common/collect/MultimapsTest.java @@ -62,7 +62,7 @@ import java.util.stream.Collector; import java.util.stream.Stream; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@code Multimaps}. @@ -324,8 +324,8 @@ private static void checkUnmodifiableMultimap( private static void checkUnmodifiableMultimap( Multimap multimap, boolean permitsDuplicates, - @NullableDecl String nullKey, - @NullableDecl Integer nullValue) { + @Nullable String nullKey, + @Nullable Integer nullValue) { Multimap unmodifiable = prepareUnmodifiableTests(multimap, permitsDuplicates, nullKey, nullValue); @@ -354,8 +354,8 @@ private static void checkUnmodifiableMultimap( private static Multimap prepareUnmodifiableTests( Multimap multimap, boolean permitsDuplicates, - @NullableDecl String nullKey, - @NullableDecl Integer nullValue) { + @Nullable String nullKey, + @Nullable Integer nullValue) { multimap.clear(); multimap.put("foo", 1); multimap.put("foo", 2); diff --git a/guava-tests/test/com/google/common/collect/OrderingTest.java b/guava-tests/test/com/google/common/collect/OrderingTest.java index b449a29ee34c..36b63d8d9c8b 100644 --- a/guava-tests/test/com/google/common/collect/OrderingTest.java +++ b/guava-tests/test/com/google/common/collect/OrderingTest.java @@ -41,7 +41,7 @@ import java.util.Random; import java.util.RandomAccess; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit tests for {@code Ordering}. @@ -1030,7 +1030,7 @@ Scenario mutate(final Scenario scenario) { scenario.ordering.onResultOf( new Function() { @Override - public T apply(@NullableDecl Integer from) { + public T apply(@Nullable Integer from) { return scenario.strictlyOrderedList.get(from); } }); diff --git a/guava-tests/test/com/google/common/collect/SetsTest.java b/guava-tests/test/com/google/common/collect/SetsTest.java index 809996bb9a9c..82b190f6d855 100644 --- a/guava-tests/test/com/google/common/collect/SetsTest.java +++ b/guava-tests/test/com/google/common/collect/SetsTest.java @@ -76,7 +76,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@code Sets}. @@ -1074,7 +1074,7 @@ private static void verifyLinkedHashSetContents( * same as the given comparator. */ private static void verifySortedSetContents( - SortedSet set, Iterable iterable, @NullableDecl Comparator comparator) { + SortedSet set, Iterable iterable, @Nullable Comparator comparator) { assertSame(comparator, set.comparator()); verifySetContents(set, iterable); } diff --git a/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java b/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java index 830536dfc5db..04f4fe67c735 100644 --- a/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java @@ -31,7 +31,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit test for {@link AbstractMultiset}. @@ -106,7 +106,7 @@ public void clear() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { for (Entry entry : entrySet()) { if (Objects.equal(entry.getElement(), element)) { return entry.getCount(); @@ -116,7 +116,7 @@ public int count(@NullableDecl Object element) { } @Override - public int add(@NullableDecl E element, int occurrences) { + public int add(@Nullable E element, int occurrences) { checkArgument(occurrences >= 0); Integer frequency = backingMap.get(element); if (frequency == null) { diff --git a/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java index 14111da785f4..6475dad8f983 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java @@ -33,7 +33,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@code Synchronized#multimap}. @@ -89,7 +89,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { assertTrue(Thread.holdsLock(mutex)); return super.equals(o); } @@ -113,25 +113,25 @@ public boolean isEmpty() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { assertTrue(Thread.holdsLock(mutex)); return super.containsKey(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { assertTrue(Thread.holdsLock(mutex)); return super.containsValue(value); } @Override - public boolean containsEntry(@NullableDecl Object key, @NullableDecl Object value) { + public boolean containsEntry(@Nullable Object key, @Nullable Object value) { assertTrue(Thread.holdsLock(mutex)); return super.containsEntry(key, value); } @Override - public Set get(@NullableDecl K key) { + public Set get(@Nullable K key) { assertTrue(Thread.holdsLock(mutex)); /* TODO: verify that the Collection is also synchronized? */ return super.get(key); @@ -144,7 +144,7 @@ public boolean put(K key, V value) { } @Override - public boolean putAll(@NullableDecl K key, Iterable values) { + public boolean putAll(@Nullable K key, Iterable values) { assertTrue(Thread.holdsLock(mutex)); return super.putAll(key, values); } @@ -156,19 +156,19 @@ public boolean putAll(Multimap map) { } @Override - public Set replaceValues(@NullableDecl K key, Iterable values) { + public Set replaceValues(@Nullable K key, Iterable values) { assertTrue(Thread.holdsLock(mutex)); return super.replaceValues(key, values); } @Override - public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { + public boolean remove(@Nullable Object key, @Nullable Object value) { assertTrue(Thread.holdsLock(mutex)); return super.remove(key, value); } @Override - public Set removeAll(@NullableDecl Object key) { + public Set removeAll(@Nullable Object key) { assertTrue(Thread.holdsLock(mutex)); return super.removeAll(key); } diff --git a/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java b/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java index fe7582dbf64d..313a94f6679f 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java @@ -27,7 +27,7 @@ import java.util.Set; import junit.framework.Test; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@code Synchronized#set}. @@ -80,7 +80,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { assertTrue(Thread.holdsLock(mutex)); return super.equals(o); } @@ -92,7 +92,7 @@ public int hashCode() { } @Override - public boolean add(@NullableDecl E o) { + public boolean add(@Nullable E o) { assertTrue(Thread.holdsLock(mutex)); return super.add(o); } @@ -110,7 +110,7 @@ public void clear() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { assertTrue(Thread.holdsLock(mutex)); return super.contains(o); } @@ -130,7 +130,7 @@ public boolean isEmpty() { /* Don't test iterator(); it may or may not hold the mutex. */ @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { assertTrue(Thread.holdsLock(mutex)); return super.remove(o); } diff --git a/guava-tests/test/com/google/common/collect/SynchronizedTableTest.java b/guava-tests/test/com/google/common/collect/SynchronizedTableTest.java index f418367eae76..934ad7a9e9c5 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedTableTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedTableTest.java @@ -20,7 +20,7 @@ import java.util.Collection; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; public class SynchronizedTableTest extends AbstractTableTest { private static final class TestTable implements Table, Serializable { @@ -34,7 +34,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { assertTrue(Thread.holdsLock(mutex)); return delegate.equals(o); } @@ -58,7 +58,7 @@ public boolean isEmpty() { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { assertTrue(Thread.holdsLock(mutex)); return delegate.containsValue(value); } diff --git a/guava-tests/test/com/google/common/hash/BloomFilterTest.java b/guava-tests/test/com/google/common/hash/BloomFilterTest.java index c979bf54b88b..460289498869 100644 --- a/guava-tests/test/com/google/common/hash/BloomFilterTest.java +++ b/guava-tests/test/com/google/common/hash/BloomFilterTest.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Stream; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for SimpleGenericBloomFilter and derived BloomFilter views. @@ -422,7 +422,7 @@ public void funnel(Long value, PrimitiveSink into) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return (object instanceof CustomFunnel); } diff --git a/guava-tests/test/com/google/common/io/BaseEncodingTest.java b/guava-tests/test/com/google/common/io/BaseEncodingTest.java index 39a471f6d9ce..ab9ed1ef169f 100644 --- a/guava-tests/test/com/google/common/io/BaseEncodingTest.java +++ b/guava-tests/test/com/google/common/io/BaseEncodingTest.java @@ -34,7 +34,7 @@ import java.io.StringReader; import java.io.StringWriter; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@code BaseEncoding}. @@ -388,7 +388,7 @@ private static void assertFailsToDecode(BaseEncoding encoding, String cannotDeco } private static void assertFailsToDecode( - BaseEncoding encoding, String cannotDecode, @NullableDecl String expectedMessage) { + BaseEncoding encoding, String cannotDecode, @Nullable String expectedMessage) { assertFalse(encoding.canDecode(cannotDecode)); try { encoding.decode(cannotDecode); diff --git a/guava-tests/test/com/google/common/io/CloserTest.java b/guava-tests/test/com/google/common/io/CloserTest.java index b97a3057698a..3d16a09906b1 100644 --- a/guava-tests/test/com/google/common/io/CloserTest.java +++ b/guava-tests/test/com/google/common/io/CloserTest.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.logging.LogRecord; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link Closer}. @@ -435,7 +435,7 @@ static TestCloseable throwsOnCreate() throws IOException { throw new IOException(); } - private TestCloseable(@NullableDecl Throwable throwOnClose) { + private TestCloseable(@Nullable Throwable throwOnClose) { this.throwOnClose = throwOnClose; } diff --git a/guava-tests/test/com/google/common/io/SourceSinkFactories.java b/guava-tests/test/com/google/common/io/SourceSinkFactories.java index 3c2558d9d96f..9b761d37450e 100644 --- a/guava-tests/test/com/google/common/io/SourceSinkFactories.java +++ b/guava-tests/test/com/google/common/io/SourceSinkFactories.java @@ -40,7 +40,7 @@ import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@link SourceSinkFactory} implementations. @@ -340,7 +340,7 @@ private static class FileByteSinkFactory extends FileFactory implements ByteSink private final byte[] initialBytes; - private FileByteSinkFactory(@NullableDecl byte[] initialBytes) { + private FileByteSinkFactory(byte @Nullable [] initialBytes) { this.initialBytes = initialBytes; } @@ -410,7 +410,7 @@ private static class FileCharSinkFactory extends FileFactory implements CharSink private final String initialString; - private FileCharSinkFactory(@NullableDecl String initialString) { + private FileCharSinkFactory(@Nullable String initialString) { this.initialString = initialString; } @@ -520,7 +520,7 @@ private static class PathByteSinkFactory extends Jdk7FileFactory implements Byte private final byte[] initialBytes; - private PathByteSinkFactory(@NullableDecl byte[] initialBytes) { + private PathByteSinkFactory(byte @Nullable [] initialBytes) { this.initialBytes = initialBytes; } @@ -577,7 +577,7 @@ private static class PathCharSinkFactory extends Jdk7FileFactory implements Char private final String initialString; - private PathCharSinkFactory(@NullableDecl String initialString) { + private PathCharSinkFactory(@Nullable String initialString) { this.initialString = initialString; } diff --git a/guava-tests/test/com/google/common/math/QuantilesTest.java b/guava-tests/test/com/google/common/math/QuantilesTest.java index bdd35216259f..eb5d111dd462 100644 --- a/guava-tests/test/com/google/common/math/QuantilesTest.java +++ b/guava-tests/test/com/google/common/math/QuantilesTest.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.Random; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Tests for {@link Quantiles}. @@ -90,7 +90,7 @@ public class QuantilesTest extends TestCase { new Correspondence() { @Override - public boolean compare(@NullableDecl Double actual, @NullableDecl Double expected) { + public boolean compare(@Nullable Double actual, @Nullable Double expected) { // Test for equality to allow non-finite values to match; otherwise, use the finite test. return actual.equals(expected) || FINITE_QUANTILE_CORRESPONDENCE.compare(actual, expected); diff --git a/guava-tests/test/com/google/common/reflect/InvokableTest.java b/guava-tests/test/com/google/common/reflect/InvokableTest.java index 816aed3326ee..1b48ba673035 100644 --- a/guava-tests/test/com/google/common/reflect/InvokableTest.java +++ b/guava-tests/test/com/google/common/reflect/InvokableTest.java @@ -30,7 +30,7 @@ import java.lang.reflect.TypeVariable; import java.util.Collections; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit tests for {@link Invokable}. @@ -343,7 +343,7 @@ public void testInnerClassWithOneParameterConstructor() { private class InnerWithAnnotatedConstructorParameter { @SuppressWarnings("unused") // called by reflection - InnerWithAnnotatedConstructorParameter(@NullableDecl String s) {} + InnerWithAnnotatedConstructorParameter(@Nullable String s) {} } public void testInnerClassWithAnnotatedConstructorParameter() { @@ -506,7 +506,7 @@ public LocalWithOneParameterConstructor(String x) { public void testLocalClassWithAnnotatedConstructorParameter() throws Exception { class LocalWithAnnotatedConstructorParameter { @SuppressWarnings("unused") // called by reflection - LocalWithAnnotatedConstructorParameter(@NullableDecl String s) {} + LocalWithAnnotatedConstructorParameter(@Nullable String s) {} } Constructor constructor = LocalWithAnnotatedConstructorParameter.class.getDeclaredConstructors()[0]; diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java index bf70aac25e72..d90c5bbe807d 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.AbstractQueuedSynchronizer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Utilities for the AbstractFutureBenchmarks */ final class AbstractFutureBenchmarks { @@ -218,7 +218,7 @@ public void addListener(Runnable listener, Executor exec) { * @return true if the state was successfully changed. */ @CanIgnoreReturnValue - protected boolean set(@NullableDecl V value) { + protected boolean set(@Nullable V value) { boolean result = sync.set(value); if (result) { executionList.execute(); @@ -360,7 +360,7 @@ boolean wasInterrupted() { } /** Transition to the COMPLETED state and set the value. */ - boolean set(@NullableDecl V v) { + boolean set(@Nullable V v) { return complete(v, null, COMPLETED); } @@ -384,7 +384,7 @@ boolean cancel(boolean interrupt) { * @param t the exception to set as the result of the computation. * @param finalState the state to transition to. */ - private boolean complete(@NullableDecl V v, @NullableDecl Throwable t, int finalState) { + private boolean complete(@Nullable V v, @Nullable Throwable t, int finalState) { boolean doCompletion = compareAndSetState(RUNNING, COMPLETING); if (doCompletion) { // If this thread successfully transitioned to COMPLETING, set the value @@ -406,7 +406,7 @@ private boolean complete(@NullableDecl V v, @NullableDecl Throwable t, int final } static final CancellationException cancellationExceptionWithCause( - @NullableDecl String message, @NullableDecl Throwable cause) { + @Nullable String message, @Nullable Throwable cause) { CancellationException exception = new CancellationException(message); exception.initCause(cause); return exception; diff --git a/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java b/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java index 4febc5a8dcc5..22eba9bde49a 100644 --- a/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.Executor; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; import org.mockito.Mockito; /** @@ -157,8 +157,8 @@ public void execute(Runnable command) { } private final class MockCallback implements FutureCallback { - @NullableDecl private String value = null; - @NullableDecl private Throwable failure = null; + @Nullable private String value = null; + @Nullable private Throwable failure = null; private boolean wasCalled = false; MockCallback(String expectedValue) { diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java b/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java index 38678ffa8911..db7d072e3d63 100644 --- a/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/FuturesTest.java @@ -90,7 +90,7 @@ import java.util.logging.Logger; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unit tests for {@link Futures}. @@ -3508,7 +3508,7 @@ public void testNonCancellationPropagating_doesNotPropagate() throws Exception { @GwtIncompatible // used only in GwtIncompatible tests private static class TestException extends Exception { - TestException(@NullableDecl Throwable cause) { + TestException(@Nullable Throwable cause) { super(cause); } } diff --git a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java index 338b8b2a14a3..2ee8581d7f74 100644 --- a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java +++ b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java @@ -29,7 +29,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Used to test listenable future implementations. @@ -67,7 +67,7 @@ public void tearDown() { exec.shutdown(); } - public void testCompletedFuture(@NullableDecl Object expectedValue) + public void testCompletedFuture(@Nullable Object expectedValue) throws InterruptedException, ExecutionException { assertTrue(future.isDone()); assertFalse(future.isCancelled()); @@ -94,7 +94,7 @@ public void testCancelledFuture() throws InterruptedException, ExecutionExceptio } } - public void testFailedFuture(@NullableDecl String message) throws InterruptedException { + public void testFailedFuture(@Nullable String message) throws InterruptedException { assertTrue(future.isDone()); assertFalse(future.isCancelled()); diff --git a/guava-tests/test/com/google/common/util/concurrent/TestThread.java b/guava-tests/test/com/google/common/util/concurrent/TestThread.java index 1c3c88818e4b..6d5609399b0d 100644 --- a/guava-tests/test/com/google/common/util/concurrent/TestThread.java +++ b/guava-tests/test/com/google/common/util/concurrent/TestThread.java @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import junit.framework.AssertionFailedError; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A helper for concurrency testing. One or more {@code TestThread} instances are instantiated in a @@ -168,7 +168,7 @@ public void callAndAssertWaits(String methodName, Object conditionLikeObject) th * Asserts that a prior call that had caused this thread to block or wait has since returned * normally. */ - public void assertPriorCallReturns(@NullableDecl String methodName) throws Exception { + public void assertPriorCallReturns(@Nullable String methodName) throws Exception { assertEquals(null, getResponse(methodName).getResult()); } @@ -176,7 +176,7 @@ public void assertPriorCallReturns(@NullableDecl String methodName) throws Excep * Asserts that a prior call that had caused this thread to block or wait has since returned the * expected boolean value. */ - public void assertPriorCallReturns(boolean expected, @NullableDecl String methodName) + public void assertPriorCallReturns(boolean expected, @Nullable String methodName) throws Exception { assertEquals(expected, getResponse(methodName).getResult()); } diff --git a/guava/pom.xml b/guava/pom.xml index 6e3fa7d75f72..d2e0745f2c13 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -24,6 +24,10 @@ org.checkerframework checker-compat-qual + + org.checkerframework + checker-qual + com.google.errorprone error_prone_annotations diff --git a/guava/src/com/google/common/base/Absent.java b/guava/src/com/google/common/base/Absent.java index 86aec0516d26..af35c2eeb960 100644 --- a/guava/src/com/google/common/base/Absent.java +++ b/guava/src/com/google/common/base/Absent.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Collections; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Implementation of an {@link Optional} not containing a reference. */ @GwtCompatible @@ -61,7 +61,7 @@ public T or(Supplier supplier) { } @Override - @NullableDecl + @Nullable public T orNull() { return null; } @@ -78,7 +78,7 @@ public Optional transform(Function function) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this; } diff --git a/guava/src/com/google/common/base/AbstractIterator.java b/guava/src/com/google/common/base/AbstractIterator.java index 853dfcdc8201..d49dc17fe9ba 100644 --- a/guava/src/com/google/common/base/AbstractIterator.java +++ b/guava/src/com/google/common/base/AbstractIterator.java @@ -20,7 +20,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Iterator; import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Note this class is a copy of {@link com.google.common.collect.AbstractIterator} (for dependency @@ -39,11 +39,11 @@ private enum State { FAILED, } - @NullableDecl private T next; + @Nullable private T next; protected abstract T computeNext(); - @NullableDecl + @Nullable @CanIgnoreReturnValue protected final T endOfData() { state = State.DONE; diff --git a/guava/src/com/google/common/base/CaseFormat.java b/guava/src/com/google/common/base/CaseFormat.java index a9c110e5d50b..324473986fc4 100644 --- a/guava/src/com/google/common/base/CaseFormat.java +++ b/guava/src/com/google/common/base/CaseFormat.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Utility class for converting between various ASCII case formats. Behavior is undefined for @@ -174,7 +174,7 @@ protected String doBackward(String s) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof StringConverter) { StringConverter that = (StringConverter) object; return sourceFormat.equals(that.sourceFormat) && targetFormat.equals(that.targetFormat); diff --git a/guava/src/com/google/common/base/Converter.java b/guava/src/com/google/common/base/Converter.java index ad145cbafd74..57cdcccc8cab 100644 --- a/guava/src/com/google/common/base/Converter.java +++ b/guava/src/com/google/common/base/Converter.java @@ -23,7 +23,7 @@ import java.io.Serializable; import java.util.Iterator; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A function from {@code A} to {@code B} with an associated reverse function from {@code B} @@ -164,14 +164,14 @@ protected Converter() { * * @return the converted value; is null if and only if {@code a} is null */ - @NullableDecl + @Nullable @CanIgnoreReturnValue - public final B convert(@NullableDecl A a) { + public final B convert(@Nullable A a) { return correctedDoForward(a); } - @NullableDecl - B correctedDoForward(@NullableDecl A a) { + @Nullable + B correctedDoForward(@Nullable A a) { if (handleNullAutomatically) { // TODO(kevinb): we shouldn't be checking for a null result at runtime. Assert? return a == null ? null : checkNotNull(doForward(a)); @@ -180,8 +180,8 @@ B correctedDoForward(@NullableDecl A a) { } } - @NullableDecl - A correctedDoBackward(@NullableDecl B b) { + @Nullable + A correctedDoBackward(@Nullable B b) { if (handleNullAutomatically) { // TODO(kevinb): we shouldn't be checking for a null result at runtime. Assert? return b == null ? null : checkNotNull(doBackward(b)); @@ -266,14 +266,14 @@ protected B doBackward(A a) { } @Override - @NullableDecl - A correctedDoForward(@NullableDecl B b) { + @Nullable + A correctedDoForward(@Nullable B b) { return original.correctedDoBackward(b); } @Override - @NullableDecl - B correctedDoBackward(@NullableDecl A a) { + @Nullable + B correctedDoBackward(@Nullable A a) { return original.correctedDoForward(a); } @@ -283,7 +283,7 @@ public Converter reverse() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof ReverseConverter) { ReverseConverter that = (ReverseConverter) object; return this.original.equals(that.original); @@ -348,19 +348,19 @@ protected A doBackward(C c) { } @Override - @NullableDecl - C correctedDoForward(@NullableDecl A a) { + @Nullable + C correctedDoForward(@Nullable A a) { return second.correctedDoForward(first.correctedDoForward(a)); } @Override - @NullableDecl - A correctedDoBackward(@NullableDecl C c) { + @Nullable + A correctedDoBackward(@Nullable C c) { return first.correctedDoBackward(second.correctedDoBackward(c)); } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof ConverterComposition) { ConverterComposition that = (ConverterComposition) object; return this.first.equals(that.first) && this.second.equals(that.second); @@ -386,9 +386,9 @@ public String toString() { */ @Deprecated @Override - @NullableDecl + @Nullable @CanIgnoreReturnValue - public final B apply(@NullableDecl A a) { + public final B apply(@Nullable A a) { return convert(a); } @@ -404,7 +404,7 @@ public final B apply(@NullableDecl A a) { * interchangeable. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return super.equals(object); } @@ -453,7 +453,7 @@ protected A doBackward(B b) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof FunctionBasedConverter) { FunctionBasedConverter that = (FunctionBasedConverter) object; return this.forwardFunction.equals(that.forwardFunction) diff --git a/guava/src/com/google/common/base/Defaults.java b/guava/src/com/google/common/base/Defaults.java index 787810c26632..9f787feb29ae 100644 --- a/guava/src/com/google/common/base/Defaults.java +++ b/guava/src/com/google/common/base/Defaults.java @@ -17,7 +17,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides default values for all Java types, as defined by the JLS. @@ -37,7 +37,7 @@ private Defaults() {} * false} for {@code boolean} and {@code '\0'} for {@code char}. For non-primitive types and * {@code void}, {@code null} is returned. */ - @NullableDecl + @Nullable @SuppressWarnings("unchecked") public static T defaultValue(Class type) { checkNotNull(type); diff --git a/guava/src/com/google/common/base/Enums.java b/guava/src/com/google/common/base/Enums.java index 247fa6ed2ecf..2a1b429ad06f 100644 --- a/guava/src/com/google/common/base/Enums.java +++ b/guava/src/com/google/common/base/Enums.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Utility methods for working with {@link Enum} instances. @@ -128,7 +128,7 @@ protected String doBackward(T enumValue) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof StringConverter) { StringConverter that = (StringConverter) object; return this.enumClass.equals(that.enumClass); diff --git a/guava/src/com/google/common/base/Equivalence.java b/guava/src/com/google/common/base/Equivalence.java index a83184e918dd..c5c315a8c966 100644 --- a/guava/src/com/google/common/base/Equivalence.java +++ b/guava/src/com/google/common/base/Equivalence.java @@ -20,7 +20,7 @@ import com.google.errorprone.annotations.ForOverride; import java.io.Serializable; import java.util.function.BiPredicate; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A strategy for determining whether two instances are considered equivalent, and for computing @@ -55,7 +55,7 @@ protected Equivalence() {} *

    Note that all calls to {@code equivalent(x, y)} are expected to return the same result as * long as neither {@code x} nor {@code y} is modified. */ - public final boolean equivalent(@NullableDecl T a, @NullableDecl T b) { + public final boolean equivalent(@Nullable T a, @Nullable T b) { if (a == b) { return true; } @@ -72,7 +72,7 @@ public final boolean equivalent(@NullableDecl T a, @NullableDecl T b) { */ @Deprecated @Override - public final boolean test(@NullableDecl T t, @NullableDecl T u) { + public final boolean test(@Nullable T t, @Nullable T u) { return equivalent(t, u); } @@ -105,7 +105,7 @@ public final boolean test(@NullableDecl T t, @NullableDecl T u) { *

  • {@code hash(null)} is {@code 0}. * */ - public final int hash(@NullableDecl T t) { + public final int hash(@Nullable T t) { if (t == null) { return 0; } @@ -158,7 +158,7 @@ public final Equivalence onResultOf(Function function) { * * @since 10.0 */ - public final Wrapper wrap(@NullableDecl S reference) { + public final Wrapper wrap(@Nullable S reference) { return new Wrapper(this, reference); } @@ -184,15 +184,15 @@ public final Wrapper wrap(@NullableDecl S reference) { */ public static final class Wrapper implements Serializable { private final Equivalence equivalence; - @NullableDecl private final T reference; + @Nullable private final T reference; - private Wrapper(Equivalence equivalence, @NullableDecl T reference) { + private Wrapper(Equivalence equivalence, @Nullable T reference) { this.equivalence = checkNotNull(equivalence); this.reference = reference; } /** Returns the (possibly null) reference wrapped by this instance. */ - @NullableDecl + @Nullable public T get() { return reference; } @@ -203,7 +203,7 @@ public T get() { * equivalence. */ @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } @@ -265,27 +265,27 @@ public final Equivalence> pairwise() { * * @since 10.0 */ - public final Predicate equivalentTo(@NullableDecl T target) { + public final Predicate equivalentTo(@Nullable T target) { return new EquivalentToPredicate(this, target); } private static final class EquivalentToPredicate implements Predicate, Serializable { private final Equivalence equivalence; - @NullableDecl private final T target; + @Nullable private final T target; - EquivalentToPredicate(Equivalence equivalence, @NullableDecl T target) { + EquivalentToPredicate(Equivalence equivalence, @Nullable T target) { this.equivalence = checkNotNull(equivalence); this.target = target; } @Override - public boolean apply(@NullableDecl T input) { + public boolean apply(@Nullable T input) { return equivalence.equivalent(input, target); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/guava/src/com/google/common/base/FinalizableReferenceQueue.java b/guava/src/com/google/common/base/FinalizableReferenceQueue.java index a90458a50211..29cfea0e6f8d 100644 --- a/guava/src/com/google/common/base/FinalizableReferenceQueue.java +++ b/guava/src/com/google/common/base/FinalizableReferenceQueue.java @@ -27,7 +27,7 @@ import java.net.URLClassLoader; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A reference queue with an associated background thread that dequeues references and invokes @@ -228,7 +228,7 @@ interface FinalizerLoader { * * @throws SecurityException if we don't have the appropriate privileges */ - @NullableDecl + @Nullable Class loadFinalizer(); } @@ -241,7 +241,7 @@ static class SystemLoader implements FinalizerLoader { // finding Finalizer on the system class path even if it is there. @VisibleForTesting static boolean disabled; - @NullableDecl + @Nullable @Override public Class loadFinalizer() { if (disabled) { @@ -279,7 +279,7 @@ static class DecoupledLoader implements FinalizerLoader { + "loader. To support reclaiming this class loader, either resolve the underlying " + "issue, or move Guava to your system class path."; - @NullableDecl + @Nullable @Override public Class loadFinalizer() { try { diff --git a/guava/src/com/google/common/base/Function.java b/guava/src/com/google/common/base/Function.java index fddb0ac3d30f..e60b25ef283d 100644 --- a/guava/src/com/google/common/base/Function.java +++ b/guava/src/com/google/common/base/Function.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Legacy version of {@link java.util.function.Function java.util.function.Function}. @@ -43,9 +43,9 @@ @FunctionalInterface public interface Function extends java.util.function.Function { @Override - @NullableDecl + @Nullable @CanIgnoreReturnValue // TODO(kevinb): remove this - T apply(@NullableDecl F input); + T apply(@Nullable F input); /** * May return {@code true} if {@code object} is a {@code Function} that behaves identically @@ -59,5 +59,5 @@ public interface Function extends java.util.function.Function { * disappear. It is best not to depend on it. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); } diff --git a/guava/src/com/google/common/base/FunctionalEquivalence.java b/guava/src/com/google/common/base/FunctionalEquivalence.java index 17dd40078124..05b6271b16c0 100644 --- a/guava/src/com/google/common/base/FunctionalEquivalence.java +++ b/guava/src/com/google/common/base/FunctionalEquivalence.java @@ -19,7 +19,7 @@ import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Equivalence applied on functional result. @@ -52,7 +52,7 @@ protected int doHash(F a) { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/base/Functions.java b/guava/src/com/google/common/base/Functions.java index e998c7af6726..496fcff86bcc 100644 --- a/guava/src/com/google/common/base/Functions.java +++ b/guava/src/com/google/common/base/Functions.java @@ -20,7 +20,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code com.google.common.base.Function} instances; see that @@ -88,8 +88,8 @@ private enum IdentityFunction implements Function { INSTANCE; @Override - @NullableDecl - public Object apply(@NullableDecl Object o) { + @Nullable + public Object apply(@Nullable Object o) { return o; } @@ -129,8 +129,7 @@ public static Function forMap(Map map) { * @return function that returns {@code map.get(a)} when {@code a} is a key, or {@code * defaultValue} otherwise */ - public static Function forMap( - Map map, @NullableDecl V defaultValue) { + public static Function forMap(Map map, @Nullable V defaultValue) { return new ForMapWithDefault<>(map, defaultValue); } @@ -142,14 +141,14 @@ private static class FunctionForMapNoDefault implements Function, Se } @Override - public V apply(@NullableDecl K key) { + public V apply(@Nullable K key) { V result = map.get(key); checkArgument(result != null || map.containsKey(key), "Key '%s' not present in map", key); return result; } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof FunctionForMapNoDefault) { FunctionForMapNoDefault that = (FunctionForMapNoDefault) o; return map.equals(that.map); @@ -172,21 +171,21 @@ public String toString() { private static class ForMapWithDefault implements Function, Serializable { final Map map; - @NullableDecl final V defaultValue; + @Nullable final V defaultValue; - ForMapWithDefault(Map map, @NullableDecl V defaultValue) { + ForMapWithDefault(Map map, @Nullable V defaultValue) { this.map = checkNotNull(map); this.defaultValue = defaultValue; } @Override - public V apply(@NullableDecl K key) { + public V apply(@Nullable K key) { V result = map.get(key); return (result != null || map.containsKey(key)) ? result : defaultValue; } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof ForMapWithDefault) { ForMapWithDefault that = (ForMapWithDefault) o; return map.equals(that.map) && Objects.equal(defaultValue, that.defaultValue); @@ -234,12 +233,12 @@ public FunctionComposition(Function g, Function f) { } @Override - public C apply(@NullableDecl A a) { + public C apply(@Nullable A a) { return g.apply(f.apply(a)); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof FunctionComposition) { FunctionComposition that = (FunctionComposition) obj; return f.equals(that.f) && g.equals(that.g); @@ -282,12 +281,12 @@ private PredicateFunction(Predicate predicate) { } @Override - public Boolean apply(@NullableDecl T t) { + public Boolean apply(@Nullable T t) { return predicate.apply(t); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof PredicateFunction) { PredicateFunction that = (PredicateFunction) obj; return predicate.equals(that.predicate); @@ -316,24 +315,24 @@ public String toString() { * @param value the constant value for the function to return * @return a function that always returns {@code value} */ - public static Function constant(@NullableDecl E value) { + public static Function constant(@Nullable E value) { return new ConstantFunction(value); } private static class ConstantFunction implements Function, Serializable { - @NullableDecl private final E value; + @Nullable private final E value; - public ConstantFunction(@NullableDecl E value) { + public ConstantFunction(@Nullable E value) { this.value = value; } @Override - public E apply(@NullableDecl Object from) { + public E apply(@Nullable Object from) { return value; } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof ConstantFunction) { ConstantFunction that = (ConstantFunction) obj; return Objects.equal(value, that.value); @@ -375,12 +374,12 @@ private SupplierFunction(Supplier supplier) { } @Override - public T apply(@NullableDecl Object input) { + public T apply(@Nullable Object input) { return supplier.get(); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof SupplierFunction) { SupplierFunction that = (SupplierFunction) obj; return this.supplier.equals(that.supplier); diff --git a/guava/src/com/google/common/base/Joiner.java b/guava/src/com/google/common/base/Joiner.java index f74f02feba0a..922c1ebde172 100644 --- a/guava/src/com/google/common/base/Joiner.java +++ b/guava/src/com/google/common/base/Joiner.java @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An object which joins pieces of text (specified as an array, {@link Iterable}, varargs or even a @@ -124,7 +124,7 @@ public final A appendTo(A appendable, Object[] parts) thr /** Appends to {@code appendable} the string representation of each of the remaining arguments. */ @CanIgnoreReturnValue public final A appendTo( - A appendable, @NullableDecl Object first, @NullableDecl Object second, Object... rest) + A appendable, @Nullable Object first, @Nullable Object second, Object... rest) throws IOException { return appendTo(appendable, iterable(first, second, rest)); } @@ -173,10 +173,7 @@ public final StringBuilder appendTo(StringBuilder builder, Object[] parts) { */ @CanIgnoreReturnValue public final StringBuilder appendTo( - StringBuilder builder, - @NullableDecl Object first, - @NullableDecl Object second, - Object... rest) { + StringBuilder builder, @Nullable Object first, @Nullable Object second, Object... rest) { return appendTo(builder, iterable(first, second, rest)); } @@ -210,8 +207,7 @@ public final String join(Object[] parts) { * Returns a string containing the string representation of each argument, using the previously * configured separator between each. */ - public final String join( - @NullableDecl Object first, @NullableDecl Object second, Object... rest) { + public final String join(@Nullable Object first, @Nullable Object second, Object... rest) { return join(iterable(first, second, rest)); } @@ -223,7 +219,7 @@ public Joiner useForNull(final String nullText) { checkNotNull(nullText); return new Joiner(this) { @Override - CharSequence toString(@NullableDecl Object part) { + CharSequence toString(@Nullable Object part) { return (part == null) ? nullText : Joiner.this.toString(part); } diff --git a/guava/src/com/google/common/base/MoreObjects.java b/guava/src/com/google/common/base/MoreObjects.java index 606fcbce272d..4245f209e637 100644 --- a/guava/src/com/google/common/base/MoreObjects.java +++ b/guava/src/com/google/common/base/MoreObjects.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Arrays; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Helper functions that operate on any {@code Object}, and are not already provided in {@link @@ -51,7 +51,7 @@ public final class MoreObjects { * @throws NullPointerException if both {@code first} and {@code second} are null * @since 18.0 (since 3.0 as {@code Objects.firstNonNull()}). */ - public static T firstNonNull(@NullableDecl T first, @NullableDecl T second) { + public static T firstNonNull(@Nullable T first, @Nullable T second) { if (first != null) { return first; } @@ -167,7 +167,7 @@ public ToStringHelper omitNullValues() { * called, in which case this name/value pair will not be added. */ @CanIgnoreReturnValue - public ToStringHelper add(String name, @NullableDecl Object value) { + public ToStringHelper add(String name, @Nullable Object value) { return addHolder(name, value); } @@ -238,7 +238,7 @@ public ToStringHelper add(String name, long value) { * readable name. */ @CanIgnoreReturnValue - public ToStringHelper addValue(@NullableDecl Object value) { + public ToStringHelper addValue(@Nullable Object value) { return addHolder(value); } @@ -363,13 +363,13 @@ private ValueHolder addHolder() { return valueHolder; } - private ToStringHelper addHolder(@NullableDecl Object value) { + private ToStringHelper addHolder(@Nullable Object value) { ValueHolder valueHolder = addHolder(); valueHolder.value = value; return this; } - private ToStringHelper addHolder(String name, @NullableDecl Object value) { + private ToStringHelper addHolder(String name, @Nullable Object value) { ValueHolder valueHolder = addHolder(); valueHolder.value = value; valueHolder.name = checkNotNull(name); @@ -377,9 +377,9 @@ private ToStringHelper addHolder(String name, @NullableDecl Object value) { } private static final class ValueHolder { - @NullableDecl String name; - @NullableDecl Object value; - @NullableDecl ValueHolder next; + @Nullable String name; + @Nullable Object value; + @Nullable ValueHolder next; } } diff --git a/guava/src/com/google/common/base/Objects.java b/guava/src/com/google/common/base/Objects.java index 1a409a68df02..924885843948 100644 --- a/guava/src/com/google/common/base/Objects.java +++ b/guava/src/com/google/common/base/Objects.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Arrays; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Helper functions that can operate on any {@code Object}. @@ -48,7 +48,7 @@ private Objects() {} *

    Note for Java 7 and later: This method should be treated as deprecated; use {@link * java.util.Objects#equals} instead. */ - public static boolean equal(@NullableDecl Object a, @NullableDecl Object b) { + public static boolean equal(@Nullable Object a, @Nullable Object b) { return a == b || (a != null && a.equals(b)); } @@ -73,7 +73,7 @@ public static boolean equal(@NullableDecl Object a, @NullableDecl Object b) { *

    Note for Java 7 and later: This method should be treated as deprecated; use {@link * java.util.Objects#hash} instead. */ - public static int hashCode(@NullableDecl Object... objects) { + public static int hashCode(Object @Nullable... objects) { return Arrays.hashCode(objects); } } diff --git a/guava/src/com/google/common/base/Optional.java b/guava/src/com/google/common/base/Optional.java index b004f11dcb42..af4405075aa4 100644 --- a/guava/src/com/google/common/base/Optional.java +++ b/guava/src/com/google/common/base/Optional.java @@ -21,7 +21,7 @@ import java.io.Serializable; import java.util.Iterator; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable object that may contain a non-null reference to another object. Each instance of @@ -110,7 +110,7 @@ public static Optional of(T reference) { *

    Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's * {@code Optional.ofNullable}. */ - public static Optional fromNullable(@NullableDecl T nullableReference) { + public static Optional fromNullable(@Nullable T nullableReference) { return (nullableReference == null) ? Optional.absent() : new Present(nullableReference); } @@ -120,8 +120,8 @@ public static Optional fromNullable(@NullableDecl T nullableReference) { * * @since 21.0 */ - @NullableDecl - public static Optional fromJavaUtil(@NullableDecl java.util.Optional javaUtilOptional) { + @Nullable + public static Optional fromJavaUtil(java.util.@Nullable Optional javaUtilOptional) { return (javaUtilOptional == null) ? null : fromNullable(javaUtilOptional.orElse(null)); } @@ -138,8 +138,8 @@ public static Optional fromJavaUtil(@NullableDecl java.util.Optional j * * @since 21.0 */ - @NullableDecl - public static java.util.Optional toJavaUtil(@NullableDecl Optional googleOptional) { + public static java.util.@Nullable Optional toJavaUtil( + @Nullable Optional googleOptional) { return googleOptional == null ? null : googleOptional.toJavaUtil(); } @@ -246,7 +246,7 @@ public java.util.Optional toJavaUtil() { *

    Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's * {@code Optional.orElse(null)}. */ - @NullableDecl + @Nullable public abstract T orNull(); /** @@ -293,7 +293,7 @@ public java.util.Optional toJavaUtil() { *

    Comparison to {@code java.util.Optional}: no differences. */ @Override - public abstract boolean equals(@NullableDecl Object object); + public abstract boolean equals(@Nullable Object object); /** * Returns a hash code for this instance. diff --git a/guava/src/com/google/common/base/PairwiseEquivalence.java b/guava/src/com/google/common/base/PairwiseEquivalence.java index cb7d784f016c..89cb562092c0 100644 --- a/guava/src/com/google/common/base/PairwiseEquivalence.java +++ b/guava/src/com/google/common/base/PairwiseEquivalence.java @@ -17,7 +17,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; @GwtCompatible(serializable = true) final class PairwiseEquivalence extends Equivalence> implements Serializable { @@ -52,7 +52,7 @@ protected int doHash(Iterable iterable) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof PairwiseEquivalence) { PairwiseEquivalence that = (PairwiseEquivalence) object; return this.elementEquivalence.equals(that.elementEquivalence); diff --git a/guava/src/com/google/common/base/Platform.java b/guava/src/com/google/common/base/Platform.java index 2aea0125d790..c7076cf98aed 100644 --- a/guava/src/com/google/common/base/Platform.java +++ b/guava/src/com/google/common/base/Platform.java @@ -23,7 +23,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Methods factored out so that they can be emulated differently in GWT. @@ -55,15 +55,15 @@ static String formatCompact4Digits(double value) { return String.format(Locale.ROOT, "%.4g", value); } - static boolean stringIsNullOrEmpty(@NullableDecl String string) { + static boolean stringIsNullOrEmpty(@Nullable String string) { return string == null || string.isEmpty(); } - static String nullToEmpty(@NullableDecl String string) { + static String nullToEmpty(@Nullable String string) { return (string == null) ? "" : string; } - static String emptyToNull(@NullableDecl String string) { + static String emptyToNull(@Nullable String string) { return stringIsNullOrEmpty(string) ? null : string; } diff --git a/guava/src/com/google/common/base/Preconditions.java b/guava/src/com/google/common/base/Preconditions.java index e4c69fa137c9..3fc68bfe09be 100644 --- a/guava/src/com/google/common/base/Preconditions.java +++ b/guava/src/com/google/common/base/Preconditions.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static convenience methods that help a method or constructor check whether it was invoked @@ -130,7 +130,7 @@ public static void checkArgument(boolean expression) { * string using {@link String#valueOf(Object)} * @throws IllegalArgumentException if {@code expression} is false */ - public static void checkArgument(boolean expression, @NullableDecl Object errorMessage) { + public static void checkArgument(boolean expression, @Nullable Object errorMessage) { if (!expression) { throw new IllegalArgumentException(String.valueOf(errorMessage)); } @@ -151,8 +151,8 @@ public static void checkArgument(boolean expression, @NullableDecl Object errorM */ public static void checkArgument( boolean expression, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object... errorMessageArgs) { + @Nullable String errorMessageTemplate, + Object @Nullable... errorMessageArgs) { if (!expression) { throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs)); } @@ -165,7 +165,7 @@ public static void checkArgument( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, char p1) { + public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, char p1) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1)); } @@ -178,7 +178,7 @@ public static void checkArgument(boolean b, @NullableDecl String errorMessageTem * * @since 20.0 (varargs overload since 2.0) */ - public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, int p1) { + public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, int p1) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1)); } @@ -191,7 +191,7 @@ public static void checkArgument(boolean b, @NullableDecl String errorMessageTem * * @since 20.0 (varargs overload since 2.0) */ - public static void checkArgument(boolean b, @NullableDecl String errorMessageTemplate, long p1) { + public static void checkArgument(boolean b, @Nullable String errorMessageTemplate, long p1) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1)); } @@ -205,7 +205,7 @@ public static void checkArgument(boolean b, @NullableDecl String errorMessageTem * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1)); } @@ -219,7 +219,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, char p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, char p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -233,7 +233,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, char p1, int p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, int p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -247,7 +247,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, char p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, long p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -261,7 +261,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -275,7 +275,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, int p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, int p1, char p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -289,7 +289,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, int p1, int p2) { + boolean b, @Nullable String errorMessageTemplate, int p1, int p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -303,7 +303,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, int p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, int p1, long p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -317,7 +317,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -331,7 +331,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, long p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, char p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -345,7 +345,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, long p1, int p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, int p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -359,7 +359,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, long p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, long p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -373,7 +373,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -387,7 +387,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -401,7 +401,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -415,7 +415,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -429,10 +429,7 @@ public static void checkArgument( * @since 20.0 (varargs overload since 2.0) */ public static void checkArgument( - boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2)); } @@ -447,10 +444,10 @@ public static void checkArgument( */ public static void checkArgument( boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2, p3)); } @@ -465,11 +462,11 @@ public static void checkArgument( */ public static void checkArgument( boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3, - @NullableDecl Object p4) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3, + @Nullable Object p4) { if (!b) { throw new IllegalArgumentException(format(errorMessageTemplate, p1, p2, p3, p4)); } @@ -499,7 +496,7 @@ public static void checkState(boolean expression) { * @throws IllegalStateException if {@code expression} is false * @see Verify#verify Verify.verify() */ - public static void checkState(boolean expression, @NullableDecl Object errorMessage) { + public static void checkState(boolean expression, @Nullable Object errorMessage) { if (!expression) { throw new IllegalStateException(String.valueOf(errorMessage)); } @@ -522,8 +519,8 @@ public static void checkState(boolean expression, @NullableDecl Object errorMess */ public static void checkState( boolean expression, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object... errorMessageArgs) { + @Nullable String errorMessageTemplate, + @Nullable Object @Nullable... errorMessageArgs) { if (!expression) { throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs)); } @@ -537,7 +534,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, char p1) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, char p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } @@ -551,7 +548,7 @@ public static void checkState(boolean b, @NullableDecl String errorMessageTempla * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, int p1) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } @@ -565,7 +562,7 @@ public static void checkState(boolean b, @NullableDecl String errorMessageTempla * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState(boolean b, @NullableDecl String errorMessageTemplate, long p1) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } @@ -580,7 +577,7 @@ public static void checkState(boolean b, @NullableDecl String errorMessageTempla * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1)); } @@ -595,7 +592,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, char p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, char p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -609,8 +606,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, char p1, int p2) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, char p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -625,7 +621,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, char p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, long p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -640,7 +636,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -654,8 +650,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, int p1, char p2) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, char p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -669,8 +664,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, int p1, int p2) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -684,8 +678,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, int p1, long p2) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, int p1, long p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -700,7 +693,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -715,7 +708,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, long p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, char p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -729,8 +722,7 @@ public static void checkState( * * @since 20.0 (varargs overload since 2.0) */ - public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, long p1, int p2) { + public static void checkState(boolean b, @Nullable String errorMessageTemplate, long p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -745,7 +737,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, long p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, long p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -760,7 +752,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -775,7 +767,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -790,7 +782,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -805,7 +797,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -820,10 +812,7 @@ public static void checkState( * @since 20.0 (varargs overload since 2.0) */ public static void checkState( - boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2) { + boolean b, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2)); } @@ -839,10 +828,10 @@ public static void checkState( */ public static void checkState( boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2, p3)); } @@ -858,11 +847,11 @@ public static void checkState( */ public static void checkState( boolean b, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3, - @NullableDecl Object p4) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3, + @Nullable Object p4) { if (!b) { throw new IllegalStateException(format(errorMessageTemplate, p1, p2, p3, p4)); } @@ -895,7 +884,7 @@ public static T checkNotNull(T reference) { * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull(T reference, @NullableDecl Object errorMessage) { + public static T checkNotNull(T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } @@ -919,9 +908,7 @@ public static T checkNotNull(T reference, @NullableDecl Object errorMessage) */ @CanIgnoreReturnValue public static T checkNotNull( - T reference, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object... errorMessageArgs) { + T reference, @Nullable String errorMessageTemplate, Object @Nullable... errorMessageArgs) { if (reference == null) { throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs)); } @@ -936,7 +923,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, char p1) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } @@ -951,7 +938,7 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, int p1) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } @@ -966,7 +953,7 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, long p1) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } @@ -982,7 +969,7 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) { + T obj, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1)); } @@ -997,8 +984,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, char p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, char p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1013,8 +999,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, int p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, int p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1029,8 +1014,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, long p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, long p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1046,7 +1030,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) { + T obj, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1061,8 +1045,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, char p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, char p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1077,8 +1060,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, int p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, int p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1093,8 +1075,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, long p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, long p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1110,7 +1091,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) { + T obj, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1125,8 +1106,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, char p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, char p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1141,8 +1121,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, int p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, int p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1157,8 +1136,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, long p2) { + public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, long p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1174,7 +1152,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) { + T obj, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1190,7 +1168,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) { + T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1206,7 +1184,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) { + T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1222,7 +1200,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) { + T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1238,10 +1216,7 @@ public static T checkNotNull( */ @CanIgnoreReturnValue public static T checkNotNull( - T obj, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2) { + T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2)); } @@ -1258,10 +1233,10 @@ public static T checkNotNull( @CanIgnoreReturnValue public static T checkNotNull( T obj, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2, p3)); } @@ -1278,11 +1253,11 @@ public static T checkNotNull( @CanIgnoreReturnValue public static T checkNotNull( T obj, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object p1, - @NullableDecl Object p2, - @NullableDecl Object p3, - @NullableDecl Object p4) { + @Nullable String errorMessageTemplate, + @Nullable Object p1, + @Nullable Object p2, + @Nullable Object p3, + @Nullable Object p4) { if (obj == null) { throw new NullPointerException(format(errorMessageTemplate, p1, p2, p3, p4)); } @@ -1342,7 +1317,7 @@ public static int checkElementIndex(int index, int size) { * @throws IllegalArgumentException if {@code size} is negative */ @CanIgnoreReturnValue - public static int checkElementIndex(int index, int size, @NullableDecl String desc) { + public static int checkElementIndex(int index, int size, @Nullable String desc) { // Carefully optimized for execution by hotspot (explanatory comment above) if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(badElementIndex(index, size, desc)); @@ -1350,7 +1325,7 @@ public static int checkElementIndex(int index, int size, @NullableDecl String de return index; } - private static String badElementIndex(int index, int size, @NullableDecl String desc) { + private static String badElementIndex(int index, int size, @Nullable String desc) { if (index < 0) { return format("%s (%s) must not be negative", desc, index); } else if (size < 0) { @@ -1387,7 +1362,7 @@ public static int checkPositionIndex(int index, int size) { * @throws IllegalArgumentException if {@code size} is negative */ @CanIgnoreReturnValue - public static int checkPositionIndex(int index, int size, @NullableDecl String desc) { + public static int checkPositionIndex(int index, int size, @Nullable String desc) { // Carefully optimized for execution by hotspot (explanatory comment above) if (index < 0 || index > size) { throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc)); @@ -1395,7 +1370,7 @@ public static int checkPositionIndex(int index, int size, @NullableDecl String d return index; } - private static String badPositionIndex(int index, int size, @NullableDecl String desc) { + private static String badPositionIndex(int index, int size, @Nullable String desc) { if (index < 0) { return format("%s (%s) must not be negative", desc, index); } else if (size < 0) { @@ -1447,7 +1422,7 @@ private static String badPositionIndexes(int start, int end, int size) { * to strings using {@link String#valueOf(Object)}. Arguments can be null. */ // Note that this is somewhat-improperly used from Verify.java as well. - static String format(@NullableDecl String template, @NullableDecl Object... args) { + static String format(@Nullable String template, @Nullable Object @Nullable... args) { template = String.valueOf(template); // null -> "null" args = args == null ? new Object[] {"(Object[])null"} : args; diff --git a/guava/src/com/google/common/base/Predicate.java b/guava/src/com/google/common/base/Predicate.java index a73e4f8014c4..a116cec20c6f 100644 --- a/guava/src/com/google/common/base/Predicate.java +++ b/guava/src/com/google/common/base/Predicate.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Legacy version of {@link java.util.function.Predicate java.util.function.Predicate}. Determines a @@ -59,7 +59,7 @@ public interface Predicate extends java.util.function.Predicate { * arguments */ @CanIgnoreReturnValue - boolean apply(@NullableDecl T input); + boolean apply(@Nullable T input); /** * Indicates whether another object is equal to this predicate. @@ -72,10 +72,10 @@ public interface Predicate extends java.util.function.Predicate { * predicates are known not to be interchangeable. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); @Override - default boolean test(@NullableDecl T input) { + default boolean test(@Nullable T input) { return apply(input); } } diff --git a/guava/src/com/google/common/base/Predicates.java b/guava/src/com/google/common/base/Predicates.java index 9c8f1e5ea256..033ab6c26c37 100644 --- a/guava/src/com/google/common/base/Predicates.java +++ b/guava/src/com/google/common/base/Predicates.java @@ -25,7 +25,7 @@ import java.util.Collection; import java.util.List; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code Predicate} instances. @@ -151,7 +151,7 @@ public static Predicate or(Predicate first, Predicate Predicate equalTo(@NullableDecl T target) { + public static Predicate equalTo(@Nullable T target) { return (target == null) ? Predicates.isNull() : new IsEqualToPredicate(target); } @@ -251,7 +251,7 @@ enum ObjectPredicate implements Predicate { /** @see Predicates#alwaysTrue() */ ALWAYS_TRUE { @Override - public boolean apply(@NullableDecl Object o) { + public boolean apply(@Nullable Object o) { return true; } @@ -263,7 +263,7 @@ public String toString() { /** @see Predicates#alwaysFalse() */ ALWAYS_FALSE { @Override - public boolean apply(@NullableDecl Object o) { + public boolean apply(@Nullable Object o) { return false; } @@ -275,7 +275,7 @@ public String toString() { /** @see Predicates#isNull() */ IS_NULL { @Override - public boolean apply(@NullableDecl Object o) { + public boolean apply(@Nullable Object o) { return o == null; } @@ -287,7 +287,7 @@ public String toString() { /** @see Predicates#notNull() */ NOT_NULL { @Override - public boolean apply(@NullableDecl Object o) { + public boolean apply(@Nullable Object o) { return o != null; } @@ -312,7 +312,7 @@ private static class NotPredicate implements Predicate, Serializable { } @Override - public boolean apply(@NullableDecl T t) { + public boolean apply(@Nullable T t) { return !predicate.apply(t); } @@ -322,7 +322,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof NotPredicate) { NotPredicate that = (NotPredicate) obj; return predicate.equals(that.predicate); @@ -347,7 +347,7 @@ private AndPredicate(List> components) { } @Override - public boolean apply(@NullableDecl T t) { + public boolean apply(@Nullable T t) { // Avoid using the Iterator to avoid generating garbage (issue 820). for (int i = 0; i < components.size(); i++) { if (!components.get(i).apply(t)) { @@ -364,7 +364,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof AndPredicate) { AndPredicate that = (AndPredicate) obj; return components.equals(that.components); @@ -389,7 +389,7 @@ private OrPredicate(List> components) { } @Override - public boolean apply(@NullableDecl T t) { + public boolean apply(@Nullable T t) { // Avoid using the Iterator to avoid generating garbage (issue 820). for (int i = 0; i < components.size(); i++) { if (components.get(i).apply(t)) { @@ -406,7 +406,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof OrPredicate) { OrPredicate that = (OrPredicate) obj; return components.equals(that.components); @@ -454,7 +454,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof IsEqualToPredicate) { IsEqualToPredicate that = (IsEqualToPredicate) obj; return target.equals(that.target); @@ -480,7 +480,7 @@ private InstanceOfPredicate(Class clazz) { } @Override - public boolean apply(@NullableDecl Object o) { + public boolean apply(@Nullable Object o) { return clazz.isInstance(o); } @@ -490,7 +490,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof InstanceOfPredicate) { InstanceOfPredicate that = (InstanceOfPredicate) obj; return clazz == that.clazz; @@ -526,7 +526,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof SubtypeOfPredicate) { SubtypeOfPredicate that = (SubtypeOfPredicate) obj; return clazz == that.clazz; @@ -551,7 +551,7 @@ private InPredicate(Collection target) { } @Override - public boolean apply(@NullableDecl T t) { + public boolean apply(@Nullable T t) { try { return target.contains(t); } catch (NullPointerException | ClassCastException e) { @@ -560,7 +560,7 @@ public boolean apply(@NullableDecl T t) { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof InPredicate) { InPredicate that = (InPredicate) obj; return target.equals(that.target); @@ -592,12 +592,12 @@ private CompositionPredicate(Predicate p, Function f) { } @Override - public boolean apply(@NullableDecl A a) { + public boolean apply(@Nullable A a) { return p.apply(f.apply(a)); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof CompositionPredicate) { CompositionPredicate that = (CompositionPredicate) obj; return f.equals(that.f) && p.equals(that.p); @@ -642,7 +642,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof ContainsPatternPredicate) { ContainsPatternPredicate that = (ContainsPatternPredicate) obj; diff --git a/guava/src/com/google/common/base/Present.java b/guava/src/com/google/common/base/Present.java index d33eb8e38567..a25de826b89e 100644 --- a/guava/src/com/google/common/base/Present.java +++ b/guava/src/com/google/common/base/Present.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Collections; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Implementation of an {@link Optional} containing a reference. */ @GwtCompatible @@ -77,7 +77,7 @@ public Optional transform(Function function) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Present) { Present other = (Present) object; return reference.equals(other.reference); diff --git a/guava/src/com/google/common/base/StandardSystemProperty.java b/guava/src/com/google/common/base/StandardSystemProperty.java index 2feb073231ea..d0674cbbc4b9 100644 --- a/guava/src/com/google/common/base/StandardSystemProperty.java +++ b/guava/src/com/google/common/base/StandardSystemProperty.java @@ -15,7 +15,7 @@ package com.google.common.base; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Represents a {@linkplain System#getProperties() standard system property}. @@ -125,7 +125,7 @@ public String key() { * Returns the current value for this system property by delegating to {@link * System#getProperty(String)}. */ - @NullableDecl + @Nullable public String value() { return System.getProperty(key); } diff --git a/guava/src/com/google/common/base/Strings.java b/guava/src/com/google/common/base/Strings.java index 998d1a50bedd..d3207b5f2836 100644 --- a/guava/src/com/google/common/base/Strings.java +++ b/guava/src/com/google/common/base/Strings.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.VisibleForTesting; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code String} or {@code CharSequence} instances. @@ -37,7 +37,7 @@ private Strings() {} * @param string the string to test and possibly return * @return {@code string} itself if it is non-null; {@code ""} if it is null */ - public static String nullToEmpty(@NullableDecl String string) { + public static String nullToEmpty(@Nullable String string) { return Platform.nullToEmpty(string); } @@ -47,8 +47,8 @@ public static String nullToEmpty(@NullableDecl String string) { * @param string the string to test and possibly return * @return {@code string} itself if it is nonempty; {@code null} if it is empty or null */ - @NullableDecl - public static String emptyToNull(@NullableDecl String string) { + @Nullable + public static String emptyToNull(@Nullable String string) { return Platform.emptyToNull(string); } @@ -63,7 +63,7 @@ public static String emptyToNull(@NullableDecl String string) { * @param string a string reference to check * @return {@code true} if the string is null or is the empty string */ - public static boolean isNullOrEmpty(@NullableDecl String string) { + public static boolean isNullOrEmpty(@Nullable String string) { return Platform.stringIsNullOrEmpty(string); } diff --git a/guava/src/com/google/common/base/Suppliers.java b/guava/src/com/google/common/base/Suppliers.java index 7923716d59af..6c4fc745958b 100644 --- a/guava/src/com/google/common/base/Suppliers.java +++ b/guava/src/com/google/common/base/Suppliers.java @@ -18,7 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import java.io.Serializable; import java.util.concurrent.TimeUnit; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Useful suppliers. @@ -60,7 +60,7 @@ public T get() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof SupplierComposition) { SupplierComposition that = (SupplierComposition) obj; return function.equals(that.function) && supplier.equals(that.supplier); @@ -113,7 +113,7 @@ static class MemoizingSupplier implements Supplier, Serializable { transient volatile boolean initialized; // "value" does not need to be volatile; visibility piggy-backs // on volatile read of "initialized". - @NullableDecl transient T value; + @Nullable transient T value; MemoizingSupplier(Supplier delegate) { this.delegate = Preconditions.checkNotNull(delegate); @@ -151,7 +151,7 @@ static class NonSerializableMemoizingSupplier implements Supplier { volatile boolean initialized; // "value" does not need to be volatile; visibility piggy-backs // on volatile read of "initialized". - @NullableDecl T value; + @Nullable T value; NonSerializableMemoizingSupplier(Supplier delegate) { this.delegate = Preconditions.checkNotNull(delegate); @@ -214,7 +214,7 @@ public static Supplier memoizeWithExpiration( static class ExpiringMemoizingSupplier implements Supplier, Serializable { final Supplier delegate; final long durationNanos; - @NullableDecl transient volatile T value; + @Nullable transient volatile T value; // The special value 0 means "not yet initialized". transient volatile long expirationNanos; @@ -261,14 +261,14 @@ public String toString() { } /** Returns a supplier that always supplies {@code instance}. */ - public static Supplier ofInstance(@NullableDecl T instance) { + public static Supplier ofInstance(@Nullable T instance) { return new SupplierOfInstance(instance); } private static class SupplierOfInstance implements Supplier, Serializable { - @NullableDecl final T instance; + @Nullable final T instance; - SupplierOfInstance(@NullableDecl T instance) { + SupplierOfInstance(@Nullable T instance) { this.instance = instance; } @@ -278,7 +278,7 @@ public T get() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof SupplierOfInstance) { SupplierOfInstance that = (SupplierOfInstance) obj; return Objects.equal(instance, that.instance); diff --git a/guava/src/com/google/common/base/Throwables.java b/guava/src/com/google/common/base/Throwables.java index 1fba558dc705..c8ace433700f 100644 --- a/guava/src/com/google/common/base/Throwables.java +++ b/guava/src/com/google/common/base/Throwables.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to instances of {@link Throwable}. @@ -99,7 +99,7 @@ public static void throwIfInstanceOf( @Deprecated @GwtIncompatible // throwIfInstanceOf public static void propagateIfInstanceOf( - @NullableDecl Throwable throwable, Class declaredType) throws X { + @Nullable Throwable throwable, Class declaredType) throws X { if (throwable != null) { throwIfInstanceOf(throwable, declaredType); } @@ -154,7 +154,7 @@ public static void throwIfUnchecked(Throwable throwable) { */ @Deprecated @GwtIncompatible - public static void propagateIfPossible(@NullableDecl Throwable throwable) { + public static void propagateIfPossible(@Nullable Throwable throwable) { if (throwable != null) { throwIfUnchecked(throwable); } @@ -180,7 +180,7 @@ public static void propagateIfPossible(@NullableDecl Throwable throwable) { */ @GwtIncompatible // propagateIfInstanceOf public static void propagateIfPossible( - @NullableDecl Throwable throwable, Class declaredType) throws X { + @Nullable Throwable throwable, Class declaredType) throws X { propagateIfInstanceOf(throwable, declaredType); propagateIfPossible(throwable); } @@ -198,7 +198,7 @@ public static void propagateIfPossible( */ @GwtIncompatible // propagateIfInstanceOf public static void propagateIfPossible( - @NullableDecl Throwable throwable, Class declaredType1, Class declaredType2) + @Nullable Throwable throwable, Class declaredType1, Class declaredType2) throws X1, X2 { checkNotNull(declaredType2); propagateIfInstanceOf(throwable, declaredType1); @@ -448,7 +448,7 @@ private static Object invokeAccessibleNonThrowingMethod( /** Access to some fancy internal JVM internals. */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static final Object jla = getJLA(); /** @@ -456,7 +456,7 @@ private static Object invokeAccessibleNonThrowingMethod( * find it when available. When this is null, use the slow way. */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static final Method getStackTraceElementMethod = (jla == null) ? null : getGetMethod(); /** @@ -464,7 +464,7 @@ private static Object invokeAccessibleNonThrowingMethod( * when available. When this is null, use the slow way. */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static final Method getStackTraceDepthMethod = (jla == null) ? null : getSizeMethod(); /** @@ -472,7 +472,7 @@ private static Object invokeAccessibleNonThrowingMethod( * AppEngine, and not present in non-Sun JDKs. */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static Object getJLA() { try { /* @@ -498,7 +498,7 @@ private static Object getJLA() { * method cannot be found (it is only to be found in fairly recent JDKs). */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static Method getGetMethod() { return getJlaMethod("getStackTraceElement", Throwable.class, int.class); } @@ -513,7 +513,7 @@ private static Method getGetMethod() { * UnsupportedOperationException. */ @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); @@ -528,7 +528,7 @@ private static Method getSizeMethod() { } @GwtIncompatible // java.lang.reflect - @NullableDecl + @Nullable private static Method getJlaMethod(String name, Class... parameterTypes) throws ThreadDeath { try { return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes); diff --git a/guava/src/com/google/common/base/Verify.java b/guava/src/com/google/common/base/Verify.java index 7840ae23b1ed..6aae161b127d 100644 --- a/guava/src/com/google/common/base/Verify.java +++ b/guava/src/com/google/common/base/Verify.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static convenience methods that serve the same purpose as Java language T verifyNotNull(@NullableDecl T reference) { + public static T verifyNotNull(@Nullable T reference) { return verifyNotNull(reference, "expected a non-null reference"); } @@ -513,9 +493,9 @@ public static T verifyNotNull(@NullableDecl T reference) { */ @CanIgnoreReturnValue public static T verifyNotNull( - @NullableDecl T reference, - @NullableDecl String errorMessageTemplate, - @NullableDecl Object... errorMessageArgs) { + @Nullable T reference, + @Nullable String errorMessageTemplate, + @Nullable Object @Nullable... errorMessageArgs) { verify(reference != null, errorMessageTemplate, errorMessageArgs); return reference; } diff --git a/guava/src/com/google/common/base/VerifyException.java b/guava/src/com/google/common/base/VerifyException.java index eed5c6df2996..1b6781b817b2 100644 --- a/guava/src/com/google/common/base/VerifyException.java +++ b/guava/src/com/google/common/base/VerifyException.java @@ -15,7 +15,7 @@ package com.google.common.base; import com.google.common.annotations.GwtCompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Exception thrown upon the failure of a bigThreadConstructor = getBigThreadConstructor(); - @NullableDecl + @Nullable private static final Field inheritableThreadLocals = (bigThreadConstructor == null) ? getInheritableThreadLocalsField() : null; @@ -192,7 +192,7 @@ private boolean cleanUp(Reference reference) { } /** Looks up FinalizableReference.finalizeReferent() method. */ - @NullableDecl + @Nullable private Method getFinalizeReferentMethod() { Class finalizableReferenceClass = finalizableReferenceClassReference.get(); if (finalizableReferenceClass == null) { @@ -211,7 +211,7 @@ private Method getFinalizeReferentMethod() { } } - @NullableDecl + @Nullable private static Field getInheritableThreadLocalsField() { try { Field inheritableThreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals"); @@ -226,7 +226,7 @@ private static Field getInheritableThreadLocalsField() { } } - @NullableDecl + @Nullable private static Constructor getBigThreadConstructor() { try { return Thread.class.getConstructor( diff --git a/guava/src/com/google/common/cache/Cache.java b/guava/src/com/google/common/cache/Cache.java index 1db6c01c3962..af662a9d58b2 100644 --- a/guava/src/com/google/common/cache/Cache.java +++ b/guava/src/com/google/common/cache/Cache.java @@ -23,7 +23,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A semi-persistent mapping from keys to values. Cache entries are manually added using {@link @@ -45,7 +45,7 @@ public interface Cache { * * @since 11.0 */ - @NullableDecl + @Nullable V getIfPresent(@CompatibleWith("K") Object key); /** diff --git a/guava/src/com/google/common/cache/CacheBuilderSpec.java b/guava/src/com/google/common/cache/CacheBuilderSpec.java index 43922651ffe7..39d94c817dc2 100644 --- a/guava/src/com/google/common/cache/CacheBuilderSpec.java +++ b/guava/src/com/google/common/cache/CacheBuilderSpec.java @@ -28,7 +28,7 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A specification of a {@link CacheBuilder} configuration. @@ -81,7 +81,7 @@ public final class CacheBuilderSpec { /** Parses a single value. */ private interface ValueParser { - void parse(CacheBuilderSpec spec, String key, @NullableDecl String value); + void parse(CacheBuilderSpec spec, String key, @Nullable String value); } /** Splits each key-value pair. */ @@ -248,7 +248,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } @@ -278,8 +278,8 @@ public boolean equals(@NullableDecl Object obj) { * Converts an expiration duration/unit pair into a single Long for hashing and equality. Uses * nanos to match CacheBuilder implementation. */ - @NullableDecl - private static Long durationInNanos(long duration, @NullableDecl TimeUnit unit) { + @Nullable + private static Long durationInNanos(long duration, @Nullable TimeUnit unit) { return (unit == null) ? null : unit.toNanos(duration); } @@ -370,7 +370,7 @@ public KeyStrengthParser(Strength strength) { } @Override - public void parse(CacheBuilderSpec spec, String key, @NullableDecl String value) { + public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "key %s does not take values", key); checkArgument(spec.keyStrength == null, "%s was already set to %s", key, spec.keyStrength); spec.keyStrength = strength; @@ -386,7 +386,7 @@ public ValueStrengthParser(Strength strength) { } @Override - public void parse(CacheBuilderSpec spec, String key, @NullableDecl String value) { + public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "key %s does not take values", key); checkArgument( spec.valueStrength == null, "%s was already set to %s", key, spec.valueStrength); @@ -399,7 +399,7 @@ public void parse(CacheBuilderSpec spec, String key, @NullableDecl String value) static class RecordStatsParser implements ValueParser { @Override - public void parse(CacheBuilderSpec spec, String key, @NullableDecl String value) { + public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "recordStats does not take values"); checkArgument(spec.recordStats == null, "recordStats already set"); spec.recordStats = true; diff --git a/guava/src/com/google/common/cache/CacheStats.java b/guava/src/com/google/common/cache/CacheStats.java index dc39186d489f..edd5be0acc1f 100644 --- a/guava/src/com/google/common/cache/CacheStats.java +++ b/guava/src/com/google/common/cache/CacheStats.java @@ -20,7 +20,7 @@ import com.google.common.base.MoreObjects; import com.google.common.base.Objects; import java.util.concurrent.Callable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Statistics about the performance of a {@link Cache}. Instances of this class are immutable. @@ -249,7 +249,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof CacheStats) { CacheStats other = (CacheStats) object; return hitCount == other.hitCount diff --git a/guava/src/com/google/common/cache/ForwardingCache.java b/guava/src/com/google/common/cache/ForwardingCache.java index 217042b099e1..fa4f1a428da5 100644 --- a/guava/src/com/google/common/cache/ForwardingCache.java +++ b/guava/src/com/google/common/cache/ForwardingCache.java @@ -22,7 +22,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A cache which forwards all its method calls to another cache. Subclasses should override one or @@ -43,7 +43,7 @@ protected ForwardingCache() {} /** @since 11.0 */ @Override - @NullableDecl + @Nullable public V getIfPresent(Object key) { return delegate().getIfPresent(key); } diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java index e752d8cef7be..f27e157a2cef 100644 --- a/guava/src/com/google/common/cache/LocalCache.java +++ b/guava/src/com/google/common/cache/LocalCache.java @@ -86,7 +86,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * The concurrent hash map implementation built by {@link CacheBuilder}. @@ -230,13 +230,13 @@ class LocalCache extends AbstractMap implements ConcurrentMap final StatsCounter globalStatsCounter; /** The default cache loader to use on loading operations. */ - @NullableDecl final CacheLoader defaultLoader; + @Nullable final CacheLoader defaultLoader; /** * Creates a new, empty map with the specified strategy, initial capacity and concurrency level. */ LocalCache( - CacheBuilder builder, @NullableDecl CacheLoader loader) { + CacheBuilder builder, @Nullable CacheLoader loader) { concurrencyLevel = Math.min(builder.getConcurrencyLevel(), MAX_SEGMENTS); keyStrength = builder.getKeyStrength(); @@ -440,14 +440,14 @@ enum EntryFactory { STRONG { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new StrongEntry<>(key, hash, next); } }, STRONG_ACCESS { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new StrongAccessEntry<>(key, hash, next); } @@ -462,7 +462,7 @@ ReferenceEntry copyEntry( STRONG_WRITE { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new StrongWriteEntry<>(key, hash, next); } @@ -477,7 +477,7 @@ ReferenceEntry copyEntry( STRONG_ACCESS_WRITE { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new StrongAccessWriteEntry<>(key, hash, next); } @@ -493,14 +493,14 @@ ReferenceEntry copyEntry( WEAK { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new WeakEntry<>(segment.keyReferenceQueue, key, hash, next); } }, WEAK_ACCESS { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new WeakAccessEntry<>(segment.keyReferenceQueue, key, hash, next); } @@ -515,7 +515,7 @@ ReferenceEntry copyEntry( WEAK_WRITE { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new WeakWriteEntry<>(segment.keyReferenceQueue, key, hash, next); } @@ -530,7 +530,7 @@ ReferenceEntry copyEntry( WEAK_ACCESS_WRITE { @Override ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next) { + Segment segment, K key, int hash, @Nullable ReferenceEntry next) { return new WeakAccessWriteEntry<>(segment.keyReferenceQueue, key, hash, next); } @@ -580,7 +580,7 @@ static EntryFactory getFactory( * @param next entry in the same bucket */ abstract ReferenceEntry newEntry( - Segment segment, K key, int hash, @NullableDecl ReferenceEntry next); + Segment segment, K key, int hash, @Nullable ReferenceEntry next); /** * Copies an entry, assigning it a new {@code next} entry. @@ -622,7 +622,7 @@ void copyWriteEntry(ReferenceEntry original, ReferenceEntry n /** A reference to a value. */ interface ValueReference { /** Returns the value. Does not block or throw exceptions. */ - @NullableDecl + @Nullable V get(); /** @@ -641,7 +641,7 @@ interface ValueReference { * Returns the entry associated with this value reference, or {@code null} if this value * reference is independent of any entry. */ - @NullableDecl + @Nullable ReferenceEntry getEntry(); /** @@ -650,13 +650,13 @@ interface ValueReference { *

    {@code value} may be null only for a loading reference. */ ValueReference copyFor( - ReferenceQueue queue, @NullableDecl V value, ReferenceEntry entry); + ReferenceQueue queue, @Nullable V value, ReferenceEntry entry); /** * Notify pending loads that a new value was set. This is only relevant to loading value * references. */ - void notifyNewValue(@NullableDecl V newValue); + void notifyNewValue(@Nullable V newValue); /** * Returns true if a new value is currently loading, regardless of whether or not there is an @@ -696,7 +696,7 @@ public ReferenceEntry getEntry() { @Override public ValueReference copyFor( ReferenceQueue queue, - @NullableDecl Object value, + @Nullable Object value, ReferenceEntry entry) { return this; } @@ -939,7 +939,7 @@ static Queue discardingQueue() { static class StrongEntry extends AbstractReferenceEntry { final K key; - StrongEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + StrongEntry(K key, int hash, @Nullable ReferenceEntry next) { this.key = key; this.hash = hash; this.next = next; @@ -953,7 +953,7 @@ public K getKey() { // The code below is exactly the same for each entry type. final int hash; - @NullableDecl final ReferenceEntry next; + @Nullable final ReferenceEntry next; volatile ValueReference valueReference = unset(); @Override @@ -978,7 +978,7 @@ public ReferenceEntry getNext() { } static final class StrongAccessEntry extends StrongEntry { - StrongAccessEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + StrongAccessEntry(K key, int hash, @Nullable ReferenceEntry next) { super(key, hash, next); } @@ -1024,7 +1024,7 @@ public void setPreviousInAccessQueue(ReferenceEntry previous) { } static final class StrongWriteEntry extends StrongEntry { - StrongWriteEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + StrongWriteEntry(K key, int hash, @Nullable ReferenceEntry next) { super(key, hash, next); } @@ -1070,7 +1070,7 @@ public void setPreviousInWriteQueue(ReferenceEntry previous) { } static final class StrongAccessWriteEntry extends StrongEntry { - StrongAccessWriteEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + StrongAccessWriteEntry(K key, int hash, @Nullable ReferenceEntry next) { super(key, hash, next); } @@ -1157,7 +1157,7 @@ public void setPreviousInWriteQueue(ReferenceEntry previous) { /** Used for weakly-referenced keys. */ static class WeakEntry extends WeakReference implements ReferenceEntry { - WeakEntry(ReferenceQueue queue, K key, int hash, @NullableDecl ReferenceEntry next) { + WeakEntry(ReferenceQueue queue, K key, int hash, @Nullable ReferenceEntry next) { super(key, queue); this.hash = hash; this.next = next; @@ -1240,7 +1240,7 @@ public void setPreviousInWriteQueue(ReferenceEntry previous) { // The code below is exactly the same for each entry type. final int hash; - @NullableDecl final ReferenceEntry next; + @Nullable final ReferenceEntry next; volatile ValueReference valueReference = unset(); @Override @@ -1265,8 +1265,7 @@ public ReferenceEntry getNext() { } static final class WeakAccessEntry extends WeakEntry { - WeakAccessEntry( - ReferenceQueue queue, K key, int hash, @NullableDecl ReferenceEntry next) { + WeakAccessEntry(ReferenceQueue queue, K key, int hash, @Nullable ReferenceEntry next) { super(queue, key, hash, next); } @@ -1312,8 +1311,7 @@ public void setPreviousInAccessQueue(ReferenceEntry previous) { } static final class WeakWriteEntry extends WeakEntry { - WeakWriteEntry( - ReferenceQueue queue, K key, int hash, @NullableDecl ReferenceEntry next) { + WeakWriteEntry(ReferenceQueue queue, K key, int hash, @Nullable ReferenceEntry next) { super(queue, key, hash, next); } @@ -1360,7 +1358,7 @@ public void setPreviousInWriteQueue(ReferenceEntry previous) { static final class WeakAccessWriteEntry extends WeakEntry { WeakAccessWriteEntry( - ReferenceQueue queue, K key, int hash, @NullableDecl ReferenceEntry next) { + ReferenceQueue queue, K key, int hash, @Nullable ReferenceEntry next) { super(queue, key, hash, next); } @@ -1664,7 +1662,7 @@ static int rehash(int h) { * This method is a convenience for testing. Code should call {@link Segment#newEntry} directly. */ @VisibleForTesting - ReferenceEntry newEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + ReferenceEntry newEntry(K key, int hash, @Nullable ReferenceEntry next) { Segment segment = segmentFor(hash); segment.lock(); try { @@ -1694,7 +1692,7 @@ ValueReference newValueReference(ReferenceEntry entry, V value, int return valueStrength.referenceValue(segmentFor(hash), entry, checkNotNull(value), weight); } - int hash(@NullableDecl Object key) { + int hash(@Nullable Object key) { int h = keyEquivalence.hash(key); return rehash(h); } @@ -1741,7 +1739,7 @@ Segment createSegment( * cleanup stale entries. As such it should only be called outside of a segment context, such as * during iteration. */ - @NullableDecl + @Nullable V getLiveValue(ReferenceEntry entry, long now) { if (entry.getKey() == null) { return null; @@ -1895,13 +1893,13 @@ static class Segment extends ReentrantLock { * The key reference queue contains entries whose keys have been garbage collected, and which * need to be cleaned up internally. */ - @NullableDecl final ReferenceQueue keyReferenceQueue; + @Nullable final ReferenceQueue keyReferenceQueue; /** * The value reference queue contains value references whose values have been garbage collected, * and which need to be cleaned up internally. */ - @NullableDecl final ReferenceQueue valueReferenceQueue; + @Nullable final ReferenceQueue valueReferenceQueue; /** * The recency queue is used to record which entries were accessed for updating the access @@ -1977,7 +1975,7 @@ void initTable(AtomicReferenceArray> newTable) { } @GuardedBy("this") - ReferenceEntry newEntry(K key, int hash, @NullableDecl ReferenceEntry next) { + ReferenceEntry newEntry(K key, int hash, @Nullable ReferenceEntry next) { return map.entryFactory.newEntry(this, checkNotNull(key), hash, next); } @@ -2057,7 +2055,7 @@ V get(K key, int hash, CacheLoader loader) throws ExecutionExcepti } } - @NullableDecl + @Nullable V get(Object key, int hash) { try { if (count != 0) { // read-volatile @@ -2349,7 +2347,7 @@ V scheduleRefresh( * {@code null} if another thread is performing the refresh or if an error occurs during * refresh. */ - @NullableDecl + @Nullable V refresh(K key, int hash, CacheLoader loader, boolean checkTime) { final LoadingValueReference loadingValueReference = insertLoadingValueReference(key, hash, checkTime); @@ -2372,7 +2370,7 @@ V refresh(K key, int hash, CacheLoader loader, boolean checkTime) * Returns a newly inserted {@code LoadingValueReference}, or null if the live value reference * is already loading. */ - @NullableDecl + @Nullable LoadingValueReference insertLoadingValueReference( final K key, final int hash, boolean checkTime) { ReferenceEntry e = null; @@ -2602,7 +2600,7 @@ void expireEntries(long now) { @GuardedBy("this") void enqueueNotification( - @NullableDecl K key, int hash, @NullableDecl V value, int weight, RemovalCause cause) { + @Nullable K key, int hash, @Nullable V value, int weight, RemovalCause cause) { totalWeight -= weight; if (cause.wasEvicted()) { statsCounter.recordEviction(); @@ -2664,7 +2662,7 @@ ReferenceEntry getFirst(int hash) { // Specialized implementations of map methods - @NullableDecl + @Nullable ReferenceEntry getEntry(Object key, int hash) { for (ReferenceEntry e = getFirst(hash); e != null; e = e.getNext()) { if (e.getHash() != hash) { @@ -2685,7 +2683,7 @@ ReferenceEntry getEntry(Object key, int hash) { return null; } - @NullableDecl + @Nullable ReferenceEntry getLiveEntry(Object key, int hash, long now) { ReferenceEntry e = getEntry(key, hash); if (e == null) { @@ -2766,7 +2764,7 @@ boolean containsValue(Object value) { } } - @NullableDecl + @Nullable V put(K key, int hash, V value, boolean onlyIfAbsent) { lock(); try { @@ -2972,7 +2970,7 @@ boolean replace(K key, int hash, V oldValue, V newValue) { } } - @NullableDecl + @Nullable V replace(K key, int hash, V newValue) { lock(); try { @@ -3027,7 +3025,7 @@ V replace(K key, int hash, V newValue) { } } - @NullableDecl + @Nullable V remove(Object key, int hash) { lock(); try { @@ -3219,11 +3217,11 @@ void clear() { } @GuardedBy("this") - @NullableDecl + @Nullable ReferenceEntry removeValueFromChain( ReferenceEntry first, ReferenceEntry entry, - @NullableDecl K key, + @Nullable K key, int hash, V value, ValueReference valueReference, @@ -3241,7 +3239,7 @@ ReferenceEntry removeValueFromChain( } @GuardedBy("this") - @NullableDecl + @Nullable ReferenceEntry removeEntryFromChain( ReferenceEntry first, ReferenceEntry entry) { int newCount = count; @@ -3495,7 +3493,7 @@ public int getWeight() { return oldValue.getWeight(); } - public boolean set(@NullableDecl V newValue) { + public boolean set(@Nullable V newValue) { return futureValue.set(newValue); } @@ -3508,7 +3506,7 @@ private ListenableFuture fullyFailedFuture(Throwable t) { } @Override - public void notifyNewValue(@NullableDecl V newValue) { + public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. @@ -3592,7 +3590,7 @@ public ReferenceEntry getEntry() { @Override public ValueReference copyFor( - ReferenceQueue queue, @NullableDecl V value, ReferenceEntry entry) { + ReferenceQueue queue, @Nullable V value, ReferenceEntry entry) { return this; } } @@ -3934,8 +3932,8 @@ public int size() { } @Override - @NullableDecl - public V get(@NullableDecl Object key) { + @Nullable + public V get(@Nullable Object key) { if (key == null) { return null; } @@ -3948,7 +3946,7 @@ V get(K key, CacheLoader loader) throws ExecutionException { return segmentFor(hash).get(key, hash, loader); } - @NullableDecl + @Nullable public V getIfPresent(Object key) { int hash = hash(checkNotNull(key)); V value = segmentFor(hash).get(key, hash); @@ -3962,8 +3960,8 @@ public V getIfPresent(Object key) { // Only becomes available in Java 8 when it's on the interface. // @Override - @NullableDecl - public V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) { + @Nullable + public V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { V result = get(key); return (result != null) ? result : defaultValue; } @@ -4043,7 +4041,7 @@ ImmutableMap getAll(Iterable keys) throws ExecutionException * Returns the result of calling {@link CacheLoader#loadAll}, or null if {@code loader} doesn't * implement {@code loadAll}. */ - @NullableDecl + @Nullable Map loadAll(Set keys, CacheLoader loader) throws ExecutionException { checkNotNull(loader); @@ -4107,7 +4105,7 @@ Map loadAll(Set keys, CacheLoader loader) * Returns the internal entry for the specified key. The entry may be loading, expired, or * partially collected. */ - ReferenceEntry getEntry(@NullableDecl Object key) { + ReferenceEntry getEntry(@Nullable Object key) { // does not impact recency ordering if (key == null) { return null; @@ -4122,7 +4120,7 @@ void refresh(K key) { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { // does not impact recency ordering if (key == null) { return false; @@ -4132,7 +4130,7 @@ public boolean containsKey(@NullableDecl Object key) { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { // does not impact recency ordering if (value == null) { return false; @@ -4226,7 +4224,7 @@ public void putAll(Map m) { } @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { if (key == null) { return null; } @@ -4235,7 +4233,7 @@ public V remove(@NullableDecl Object key) { } @Override - public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { + public boolean remove(@Nullable Object key, @Nullable Object value) { if (key == null || value == null) { return false; } @@ -4244,7 +4242,7 @@ public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { } @Override - public boolean replace(K key, @NullableDecl V oldValue, V newValue) { + public boolean replace(K key, @Nullable V oldValue, V newValue) { checkNotNull(key); checkNotNull(newValue); if (oldValue == null) { @@ -4312,9 +4310,9 @@ abstract class HashIterator implements Iterator { int nextTableIndex; @MonotonicNonNullDecl Segment currentSegment; @MonotonicNonNullDecl AtomicReferenceArray> currentTable; - @NullableDecl ReferenceEntry nextEntry; - @NullableDecl WriteThroughEntry nextExternal; - @NullableDecl WriteThroughEntry lastReturned; + @Nullable ReferenceEntry nextEntry; + @Nullable WriteThroughEntry nextExternal; + @Nullable WriteThroughEntry lastReturned; HashIterator() { nextSegmentIndex = segments.length - 1; @@ -4455,7 +4453,7 @@ public V getValue() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { // Cannot use key and value equivalence if (object instanceof Entry) { Entry that = (Entry) object; @@ -4695,7 +4693,7 @@ static class ManualSerializationProxy extends ForwardingCache final Weigher weigher; final int concurrencyLevel; final RemovalListener removalListener; - @NullableDecl final Ticker ticker; + @Nullable final Ticker ticker; final CacheLoader loader; @MonotonicNonNullDecl transient Cache delegate; @@ -4859,7 +4857,7 @@ private LocalManualCache(LocalCache localCache) { // Cache methods @Override - @NullableDecl + @Nullable public V getIfPresent(Object key) { return localCache.getIfPresent(key); } diff --git a/guava/src/com/google/common/cache/ReferenceEntry.java b/guava/src/com/google/common/cache/ReferenceEntry.java index eaa901313cd0..fff9b7119ef0 100644 --- a/guava/src/com/google/common/cache/ReferenceEntry.java +++ b/guava/src/com/google/common/cache/ReferenceEntry.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.cache.LocalCache.ValueReference; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An entry in a reference map. @@ -47,14 +47,14 @@ interface ReferenceEntry { void setValueReference(ValueReference valueReference); /** Returns the next entry in the chain. */ - @NullableDecl + @Nullable ReferenceEntry getNext(); /** Returns the entry's hash. */ int getHash(); /** Returns the key for this entry. */ - @NullableDecl + @Nullable K getKey(); /* diff --git a/guava/src/com/google/common/cache/RemovalNotification.java b/guava/src/com/google/common/cache/RemovalNotification.java index e30ec0c05dec..641d18f72438 100644 --- a/guava/src/com/google/common/cache/RemovalNotification.java +++ b/guava/src/com/google/common/cache/RemovalNotification.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.AbstractMap.SimpleImmutableEntry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A notification of the removal of a single entry. The key and/or value may be null if they were @@ -43,11 +43,11 @@ public final class RemovalNotification extends SimpleImmutableEntry * @since 19.0 */ public static RemovalNotification create( - @NullableDecl K key, @NullableDecl V value, RemovalCause cause) { + @Nullable K key, @Nullable V value, RemovalCause cause) { return new RemovalNotification(key, value, cause); } - private RemovalNotification(@NullableDecl K key, @NullableDecl V value, RemovalCause cause) { + private RemovalNotification(@Nullable K key, @Nullable V value, RemovalCause cause) { super(key, value); this.cause = checkNotNull(cause); } diff --git a/guava/src/com/google/common/cache/Striped64.java b/guava/src/com/google/common/cache/Striped64.java index 14e28c7b889e..e2f1cbf1377c 100644 --- a/guava/src/com/google/common/cache/Striped64.java +++ b/guava/src/com/google/common/cache/Striped64.java @@ -13,7 +13,7 @@ import com.google.common.annotations.GwtIncompatible; import java.util.Random; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A package-local class holding common representation and mechanics for classes supporting dynamic @@ -134,7 +134,7 @@ final boolean cas(long cmp, long val) { static final int NCPU = Runtime.getRuntime().availableProcessors(); /** Table of cells. When non-null, size is a power of 2. */ - @NullableDecl transient volatile Cell[] cells; + transient volatile Cell @Nullable [] cells; /** * Base value, used mainly when there is no contention, but also as a fallback during table diff --git a/guava/src/com/google/common/collect/AbstractBiMap.java b/guava/src/com/google/common/collect/AbstractBiMap.java index 54742226c4ab..ef6971cffbf5 100644 --- a/guava/src/com/google/common/collect/AbstractBiMap.java +++ b/guava/src/com/google/common/collect/AbstractBiMap.java @@ -36,7 +36,7 @@ import java.util.Set; import java.util.function.BiFunction; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A general-purpose bimap implementation using any two backing {@code Map} instances. @@ -72,13 +72,13 @@ protected Map delegate() { /** Returns its input, or throws an exception if this is not a valid key. */ @CanIgnoreReturnValue - K checkKey(@NullableDecl K key) { + K checkKey(@Nullable K key) { return key; } /** Returns its input, or throws an exception if this is not a valid value. */ @CanIgnoreReturnValue - V checkValue(@NullableDecl V value) { + V checkValue(@Nullable V value) { return value; } @@ -107,7 +107,7 @@ void setInverse(AbstractBiMap inverse) { // Query Operations (optimizations) @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return inverse.containsKey(value); } @@ -115,17 +115,17 @@ public boolean containsValue(@NullableDecl Object value) { @CanIgnoreReturnValue @Override - public V put(@NullableDecl K key, @NullableDecl V value) { + public V put(@Nullable K key, @Nullable V value) { return putInBothMaps(key, value, false); } @CanIgnoreReturnValue @Override - public V forcePut(@NullableDecl K key, @NullableDecl V value) { + public V forcePut(@Nullable K key, @Nullable V value) { return putInBothMaps(key, value, true); } - private V putInBothMaps(@NullableDecl K key, @NullableDecl V value, boolean force) { + private V putInBothMaps(@Nullable K key, @Nullable V value, boolean force) { checkKey(key); checkValue(value); boolean containedKey = containsKey(key); @@ -151,7 +151,7 @@ private void updateInverseMap(K key, boolean containedKey, V oldValue, V newValu @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { return containsKey(key) ? removeFromBothMaps(key) : null; } @@ -338,7 +338,7 @@ public V setValue(V value) { Iterator> entrySetIterator() { final Iterator> iterator = delegate.entrySet().iterator(); return new Iterator>() { - @NullableDecl Entry entry; + @Nullable Entry entry; @Override public boolean hasNext() { diff --git a/guava/src/com/google/common/collect/AbstractIterator.java b/guava/src/com/google/common/collect/AbstractIterator.java index ea5ea7a58326..c514bd063a01 100644 --- a/guava/src/com/google/common/collect/AbstractIterator.java +++ b/guava/src/com/google/common/collect/AbstractIterator.java @@ -21,7 +21,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of the {@code Iterator} interface, to make this @@ -81,7 +81,7 @@ private enum State { FAILED, } - @NullableDecl private T next; + @Nullable private T next; /** * Returns the next element. Note: the implementation must call {@link #endOfData()} when diff --git a/guava/src/com/google/common/collect/AbstractListMultimap.java b/guava/src/com/google/common/collect/AbstractListMultimap.java index 4f075d1aebb6..d1c87c9907f3 100644 --- a/guava/src/com/google/common/collect/AbstractListMultimap.java +++ b/guava/src/com/google/common/collect/AbstractListMultimap.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Basic implementation of the {@link ListMultimap} interface. It's a wrapper around {@link @@ -72,7 +72,7 @@ Collection wrapCollection(K key, Collection collection) { * Multimap} interface. */ @Override - public List get(@NullableDecl K key) { + public List get(@Nullable K key) { return (List) super.get(key); } @@ -85,7 +85,7 @@ public List get(@NullableDecl K key) { */ @CanIgnoreReturnValue @Override - public List removeAll(@NullableDecl Object key) { + public List removeAll(@Nullable Object key) { return (List) super.removeAll(key); } @@ -98,7 +98,7 @@ public List removeAll(@NullableDecl Object key) { */ @CanIgnoreReturnValue @Override - public List replaceValues(@NullableDecl K key, Iterable values) { + public List replaceValues(@Nullable K key, Iterable values) { return (List) super.replaceValues(key, values); } @@ -111,7 +111,7 @@ public List replaceValues(@NullableDecl K key, Iterable values) */ @CanIgnoreReturnValue @Override - public boolean put(@NullableDecl K key, @NullableDecl V value) { + public boolean put(@Nullable K key, @Nullable V value) { return super.put(key, value); } @@ -133,7 +133,7 @@ public Map> asMap() { * in the same order. If the value orderings disagree, the multimaps will not be considered equal. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return super.equals(object); } diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index 221850d23660..036cbd94b224 100644 --- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -45,7 +45,7 @@ import java.util.Spliterator; import java.util.function.BiConsumer; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Basic implementation of the {@link Multimap} interface. This class represents a multimap as a map @@ -160,7 +160,7 @@ Collection createUnmodifiableEmptyCollection() { * @param key key to associate with values in the collection * @return an empty collection of values */ - Collection createCollection(@NullableDecl K key) { + Collection createCollection(@Nullable K key) { return createCollection(); } @@ -176,14 +176,14 @@ public int size() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return map.containsKey(key); } // Modification Operations @Override - public boolean put(@NullableDecl K key, @NullableDecl V value) { + public boolean put(@Nullable K key, @Nullable V value) { Collection collection = map.get(key); if (collection == null) { collection = createCollection(key); @@ -202,7 +202,7 @@ public boolean put(@NullableDecl K key, @NullableDecl V value) { } } - private Collection getOrCreateCollection(@NullableDecl K key) { + private Collection getOrCreateCollection(@Nullable K key) { Collection collection = map.get(key); if (collection == null) { collection = createCollection(key); @@ -219,7 +219,7 @@ private Collection getOrCreateCollection(@NullableDecl K key) { *

    The returned collection is immutable. */ @Override - public Collection replaceValues(@NullableDecl K key, Iterable values) { + public Collection replaceValues(@Nullable K key, Iterable values) { Iterator iterator = values.iterator(); if (!iterator.hasNext()) { return removeAll(key); @@ -248,7 +248,7 @@ public Collection replaceValues(@NullableDecl K key, Iterable va *

    The returned collection is immutable. */ @Override - public Collection removeAll(@NullableDecl Object key) { + public Collection removeAll(@Nullable Object key) { Collection collection = map.remove(key); if (collection == null) { @@ -285,7 +285,7 @@ public void clear() { *

    The returned collection is not serializable. */ @Override - public Collection get(@NullableDecl K key) { + public Collection get(@Nullable K key) { Collection collection = map.get(key); if (collection == null) { collection = createCollection(key); @@ -297,12 +297,11 @@ public Collection get(@NullableDecl K key) { * Generates a decorated collection that remains consistent with the values in the multimap for * the provided key. Changes to the multimap may alter the returned collection, and vice versa. */ - Collection wrapCollection(@NullableDecl K key, Collection collection) { + Collection wrapCollection(@Nullable K key, Collection collection) { return new WrappedCollection(key, collection, null); } - final List wrapList( - @NullableDecl K key, List list, @NullableDecl WrappedCollection ancestor) { + final List wrapList(@Nullable K key, List list, @Nullable WrappedCollection ancestor) { return (list instanceof RandomAccess) ? new RandomAccessWrappedList(key, list, ancestor) : new WrappedList(key, list, ancestor); @@ -325,13 +324,13 @@ final List wrapList( */ @WeakOuter class WrappedCollection extends AbstractCollection { - @NullableDecl final K key; + @Nullable final K key; Collection delegate; - @NullableDecl final WrappedCollection ancestor; - @NullableDecl final Collection ancestorDelegate; + @Nullable final WrappedCollection ancestor; + @Nullable final Collection ancestorDelegate; WrappedCollection( - @NullableDecl K key, Collection delegate, @NullableDecl WrappedCollection ancestor) { + @Nullable K key, Collection delegate, @Nullable WrappedCollection ancestor) { this.key = key; this.delegate = delegate; this.ancestor = ancestor; @@ -396,7 +395,7 @@ public int size() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -589,7 +588,7 @@ private static Iterator iteratorOrListIterator(Collection collection) /** Set decorator that stays in sync with the multimap values for a key. */ @WeakOuter class WrappedSet extends WrappedCollection implements Set { - WrappedSet(@NullableDecl K key, Set delegate) { + WrappedSet(@Nullable K key, Set delegate) { super(key, delegate, null); } @@ -616,8 +615,7 @@ public boolean removeAll(Collection c) { /** SortedSet decorator that stays in sync with the multimap values for a key. */ @WeakOuter class WrappedSortedSet extends WrappedCollection implements SortedSet { - WrappedSortedSet( - @NullableDecl K key, SortedSet delegate, @NullableDecl WrappedCollection ancestor) { + WrappedSortedSet(@Nullable K key, SortedSet delegate, @Nullable WrappedCollection ancestor) { super(key, delegate, ancestor); } @@ -673,7 +671,7 @@ public SortedSet tailSet(V fromElement) { @WeakOuter class WrappedNavigableSet extends WrappedSortedSet implements NavigableSet { WrappedNavigableSet( - @NullableDecl K key, NavigableSet delegate, @NullableDecl WrappedCollection ancestor) { + @Nullable K key, NavigableSet delegate, @Nullable WrappedCollection ancestor) { super(key, delegate, ancestor); } @@ -747,7 +745,7 @@ public NavigableSet tailSet(V fromElement, boolean inclusive) { /** List decorator that stays in sync with the multimap values for a key. */ @WeakOuter class WrappedList extends WrappedCollection implements List { - WrappedList(@NullableDecl K key, List delegate, @NullableDecl WrappedCollection ancestor) { + WrappedList(@Nullable K key, List delegate, @Nullable WrappedCollection ancestor) { super(key, delegate, ancestor); } @@ -892,7 +890,7 @@ public void add(V value) { */ private class RandomAccessWrappedList extends WrappedList implements RandomAccess { RandomAccessWrappedList( - @NullableDecl K key, List delegate, @NullableDecl WrappedCollection ancestor) { + @Nullable K key, List delegate, @Nullable WrappedCollection ancestor) { super(key, delegate, ancestor); } } @@ -922,7 +920,7 @@ private class KeySet extends Maps.KeySet> { public Iterator iterator() { final Iterator>> entryIterator = map().entrySet().iterator(); return new Iterator() { - @NullableDecl Entry> entry; + @Nullable Entry> entry; @Override public boolean hasNext() { @@ -977,7 +975,7 @@ public boolean containsAll(Collection c) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return this == object || this.map().keySet().equals(object); } @@ -1126,7 +1124,7 @@ private void removeValuesForKey(Object key) { private abstract class Itr implements Iterator { final Iterator>> keyIterator; - @NullableDecl K key; + @Nullable K key; @MonotonicNonNullDecl Collection collection; Iterator valueIterator; @@ -1345,7 +1343,7 @@ public Collection remove(Object key) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return this == object || submap.equals(object); } @@ -1411,7 +1409,7 @@ public boolean remove(Object o) { /** Iterator across all keys and value collections. */ class AsMapIterator implements Iterator>> { final Iterator>> delegateIterator = submap.entrySet().iterator(); - @NullableDecl Collection collection; + @Nullable Collection collection; @Override public boolean hasNext() { diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java b/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java index 4a62f01144c7..2a8757f8e6a3 100644 --- a/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java +++ b/guava/src/com/google/common/collect/AbstractMapBasedMultiset.java @@ -34,7 +34,7 @@ import java.util.Set; import java.util.function.ObjIntConsumer; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Basic implementation of {@code Multiset} backed by an instance of {@code Map}. @@ -85,7 +85,7 @@ public Set> entrySet() { Iterator elementIterator() { final Iterator> backingEntries = backingMap.entrySet().iterator(); return new Iterator() { - @NullableDecl Map.Entry toRemove; + Map.@Nullable Entry toRemove; @Override public boolean hasNext() { @@ -113,7 +113,7 @@ public void remove() { Iterator> entryIterator() { final Iterator> backingEntries = backingMap.entrySet().iterator(); return new Iterator>() { - @NullableDecl Map.Entry toRemove; + Map.@Nullable Entry toRemove; @Override public boolean hasNext() { @@ -233,7 +233,7 @@ public void remove() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { Count frequency = Maps.safeGet(backingMap, element); return (frequency == null) ? 0 : frequency.get(); } @@ -248,7 +248,7 @@ public int count(@NullableDecl Object element) { */ @CanIgnoreReturnValue @Override - public int add(@NullableDecl E element, int occurrences) { + public int add(@Nullable E element, int occurrences) { if (occurrences == 0) { return count(element); } @@ -270,7 +270,7 @@ public int add(@NullableDecl E element, int occurrences) { @CanIgnoreReturnValue @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { if (occurrences == 0) { return count(element); } @@ -298,7 +298,7 @@ public int remove(@NullableDecl Object element, int occurrences) { // Roughly a 33% performance improvement over AbstractMultiset.setCount(). @CanIgnoreReturnValue @Override - public int setCount(@NullableDecl E element, int count) { + public int setCount(@Nullable E element, int count) { checkNonnegative(count, "count"); Count existingCounter; @@ -319,7 +319,7 @@ public int setCount(@NullableDecl E element, int count) { return oldCount; } - private static int getAndSet(@NullableDecl Count i, int count) { + private static int getAndSet(@Nullable Count i, int count) { if (i == null) { return 0; } diff --git a/guava/src/com/google/common/collect/AbstractMapEntry.java b/guava/src/com/google/common/collect/AbstractMapEntry.java index 27ea432ba3de..267897db6210 100644 --- a/guava/src/com/google/common/collect/AbstractMapEntry.java +++ b/guava/src/com/google/common/collect/AbstractMapEntry.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.base.Objects; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of the {@code equals}, {@code hashCode}, and {@code toString} methods of {@code @@ -42,7 +42,7 @@ public V setValue(V value) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Entry) { Entry that = (Entry) object; return Objects.equal(this.getKey(), that.getKey()) diff --git a/guava/src/com/google/common/collect/AbstractMultimap.java b/guava/src/com/google/common/collect/AbstractMultimap.java index 216546fec468..3150930890cf 100644 --- a/guava/src/com/google/common/collect/AbstractMultimap.java +++ b/guava/src/com/google/common/collect/AbstractMultimap.java @@ -30,7 +30,7 @@ import java.util.Spliterator; import java.util.Spliterators; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A skeleton {@code Multimap} implementation, not necessarily in terms of a {@code Map}. @@ -45,7 +45,7 @@ public boolean isEmpty() { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { for (Collection collection : asMap().values()) { if (collection.contains(value)) { return true; @@ -56,27 +56,27 @@ public boolean containsValue(@NullableDecl Object value) { } @Override - public boolean containsEntry(@NullableDecl Object key, @NullableDecl Object value) { + public boolean containsEntry(@Nullable Object key, @Nullable Object value) { Collection collection = asMap().get(key); return collection != null && collection.contains(value); } @CanIgnoreReturnValue @Override - public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { + public boolean remove(@Nullable Object key, @Nullable Object value) { Collection collection = asMap().get(key); return collection != null && collection.remove(value); } @CanIgnoreReturnValue @Override - public boolean put(@NullableDecl K key, @NullableDecl V value) { + public boolean put(@Nullable K key, @Nullable V value) { return get(key).add(value); } @CanIgnoreReturnValue @Override - public boolean putAll(@NullableDecl K key, Iterable values) { + public boolean putAll(@Nullable K key, Iterable values) { checkNotNull(values); // make sure we only call values.iterator() once // and we only call get(key) if values is nonempty @@ -101,7 +101,7 @@ public boolean putAll(Multimap multimap) { @CanIgnoreReturnValue @Override - public Collection replaceValues(@NullableDecl K key, Iterable values) { + public Collection replaceValues(@Nullable K key, Iterable values) { checkNotNull(values); Collection result = removeAll(key); putAll(key, values); @@ -144,7 +144,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return Sets.equalsImpl(this, obj); } } @@ -204,7 +204,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { return AbstractMultimap.this.containsValue(o); } @@ -235,7 +235,7 @@ public Map> asMap() { // Comparison and hashing @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return Multimaps.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/AbstractMultiset.java b/guava/src/com/google/common/collect/AbstractMultiset.java index f0480e39833f..0fce3bdcc77b 100644 --- a/guava/src/com/google/common/collect/AbstractMultiset.java +++ b/guava/src/com/google/common/collect/AbstractMultiset.java @@ -26,7 +26,7 @@ import java.util.Iterator; import java.util.Set; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of the {@link Multiset} interface. A new multiset @@ -51,45 +51,45 @@ public boolean isEmpty() { } @Override - public boolean contains(@NullableDecl Object element) { + public boolean contains(@Nullable Object element) { return count(element) > 0; } // Modification Operations @CanIgnoreReturnValue @Override - public final boolean add(@NullableDecl E element) { + public final boolean add(@Nullable E element) { add(element, 1); return true; } @CanIgnoreReturnValue @Override - public int add(@NullableDecl E element, int occurrences) { + public int add(@Nullable E element, int occurrences) { throw new UnsupportedOperationException(); } @CanIgnoreReturnValue @Override - public final boolean remove(@NullableDecl Object element) { + public final boolean remove(@Nullable Object element) { return remove(element, 1) > 0; } @CanIgnoreReturnValue @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { throw new UnsupportedOperationException(); } @CanIgnoreReturnValue @Override - public int setCount(@NullableDecl E element, int count) { + public int setCount(@Nullable E element, int count) { return setCountImpl(this, element, count); } @CanIgnoreReturnValue @Override - public boolean setCount(@NullableDecl E element, int oldCount, int newCount) { + public boolean setCount(@Nullable E element, int oldCount, int newCount) { return setCountImpl(this, element, oldCount, newCount); } @@ -204,7 +204,7 @@ Set> createEntrySet() { * and if, for each element, the two multisets have the same count. */ @Override - public final boolean equals(@NullableDecl Object object) { + public final boolean equals(@Nullable Object object) { return Multisets.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/AbstractNavigableMap.java b/guava/src/com/google/common/collect/AbstractNavigableMap.java index e5259e829e4e..7004b7211fbf 100644 --- a/guava/src/com/google/common/collect/AbstractNavigableMap.java +++ b/guava/src/com/google/common/collect/AbstractNavigableMap.java @@ -24,7 +24,7 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Skeletal implementation of {@link NavigableMap}. @@ -36,29 +36,29 @@ abstract class AbstractNavigableMap extends IteratorBasedAbstractMap implements NavigableMap { @Override - @NullableDecl - public abstract V get(@NullableDecl Object key); + @Nullable + public abstract V get(@Nullable Object key); @Override - @NullableDecl + @Nullable public Entry firstEntry() { return Iterators.getNext(entryIterator(), null); } @Override - @NullableDecl + @Nullable public Entry lastEntry() { return Iterators.getNext(descendingEntryIterator(), null); } @Override - @NullableDecl + @Nullable public Entry pollFirstEntry() { return Iterators.pollNext(entryIterator()); } @Override - @NullableDecl + @Nullable public Entry pollLastEntry() { return Iterators.pollNext(descendingEntryIterator()); } @@ -84,25 +84,25 @@ public K lastKey() { } @Override - @NullableDecl + @Nullable public Entry lowerEntry(K key) { return headMap(key, false).lastEntry(); } @Override - @NullableDecl + @Nullable public Entry floorEntry(K key) { return headMap(key, true).lastEntry(); } @Override - @NullableDecl + @Nullable public Entry ceilingEntry(K key) { return tailMap(key, true).firstEntry(); } @Override - @NullableDecl + @Nullable public Entry higherEntry(K key) { return tailMap(key, false).firstEntry(); } diff --git a/guava/src/com/google/common/collect/AbstractRangeSet.java b/guava/src/com/google/common/collect/AbstractRangeSet.java index cbea4cdb8f07..1c454cdfc318 100644 --- a/guava/src/com/google/common/collect/AbstractRangeSet.java +++ b/guava/src/com/google/common/collect/AbstractRangeSet.java @@ -15,7 +15,7 @@ package com.google.common.collect; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A skeletal implementation of {@code RangeSet}. @@ -78,7 +78,7 @@ public boolean intersects(Range otherRange) { public abstract boolean encloses(Range otherRange); @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } else if (obj instanceof RangeSet) { diff --git a/guava/src/com/google/common/collect/AbstractSequentialIterator.java b/guava/src/com/google/common/collect/AbstractSequentialIterator.java index f9a57198be1a..05f561d68502 100644 --- a/guava/src/com/google/common/collect/AbstractSequentialIterator.java +++ b/guava/src/com/google/common/collect/AbstractSequentialIterator.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of the {@code Iterator} interface for sequences @@ -41,13 +41,13 @@ */ @GwtCompatible public abstract class AbstractSequentialIterator extends UnmodifiableIterator { - @NullableDecl private T nextOrNull; + @Nullable private T nextOrNull; /** * Creates a new iterator with the given first element, or, if {@code firstOrNull} is null, * creates a new empty iterator. */ - protected AbstractSequentialIterator(@NullableDecl T firstOrNull) { + protected AbstractSequentialIterator(@Nullable T firstOrNull) { this.nextOrNull = firstOrNull; } diff --git a/guava/src/com/google/common/collect/AbstractSetMultimap.java b/guava/src/com/google/common/collect/AbstractSetMultimap.java index 2779d1cbde5d..326f99808d95 100644 --- a/guava/src/com/google/common/collect/AbstractSetMultimap.java +++ b/guava/src/com/google/common/collect/AbstractSetMultimap.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Basic implementation of the {@link SetMultimap} interface. It's a wrapper around {@link @@ -71,7 +71,7 @@ Collection wrapCollection(K key, Collection collection) { * {@link Set}, instead of the {@link Collection} specified in the {@link Multimap} interface. */ @Override - public Set get(@NullableDecl K key) { + public Set get(@Nullable K key) { return (Set) super.get(key); } @@ -94,7 +94,7 @@ public Set> entries() { */ @CanIgnoreReturnValue @Override - public Set removeAll(@NullableDecl Object key) { + public Set removeAll(@Nullable Object key) { return (Set) super.removeAll(key); } @@ -108,7 +108,7 @@ public Set removeAll(@NullableDecl Object key) { */ @CanIgnoreReturnValue @Override - public Set replaceValues(@NullableDecl K key, Iterable values) { + public Set replaceValues(@Nullable K key, Iterable values) { return (Set) super.replaceValues(key, values); } @@ -133,7 +133,7 @@ public Map> asMap() { */ @CanIgnoreReturnValue @Override - public boolean put(@NullableDecl K key, @NullableDecl V value) { + public boolean put(@Nullable K key, @Nullable V value) { return super.put(key, value); } @@ -144,7 +144,7 @@ public boolean put(@NullableDecl K key, @NullableDecl V value) { * Equality does not depend on the ordering of keys or values. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return super.equals(object); } diff --git a/guava/src/com/google/common/collect/AbstractSortedMultiset.java b/guava/src/com/google/common/collect/AbstractSortedMultiset.java index c1e44f67481a..93691c1d5592 100644 --- a/guava/src/com/google/common/collect/AbstractSortedMultiset.java +++ b/guava/src/com/google/common/collect/AbstractSortedMultiset.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.NavigableSet; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of the {@link SortedMultiset} interface. @@ -100,9 +100,9 @@ public Entry pollLastEntry() { @Override public SortedMultiset subMultiset( - @NullableDecl E fromElement, + @Nullable E fromElement, BoundType fromBoundType, - @NullableDecl E toElement, + @Nullable E toElement, BoundType toBoundType) { // These are checked elsewhere, but NullPointerTester wants them checked eagerly. checkNotNull(fromBoundType); diff --git a/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java b/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java index 6254a6e62980..2e4de2e63ef2 100644 --- a/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java +++ b/guava/src/com/google/common/collect/AbstractSortedSetMultimap.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.NavigableSet; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Basic implementation of the {@link SortedSetMultimap} interface. It's a wrapper around {@link @@ -83,7 +83,7 @@ Collection wrapCollection(K key, Collection collection) { * Multimap} interface. */ @Override - public SortedSet get(@NullableDecl K key) { + public SortedSet get(@Nullable K key) { return (SortedSet) super.get(key); } @@ -96,7 +96,7 @@ public SortedSet get(@NullableDecl K key) { */ @CanIgnoreReturnValue @Override - public SortedSet removeAll(@NullableDecl Object key) { + public SortedSet removeAll(@Nullable Object key) { return (SortedSet) super.removeAll(key); } @@ -112,7 +112,7 @@ public SortedSet removeAll(@NullableDecl Object key) { */ @CanIgnoreReturnValue @Override - public SortedSet replaceValues(@NullableDecl K key, Iterable values) { + public SortedSet replaceValues(@Nullable K key, Iterable values) { return (SortedSet) super.replaceValues(key, values); } diff --git a/guava/src/com/google/common/collect/AbstractTable.java b/guava/src/com/google/common/collect/AbstractTable.java index 9a15a60b1509..93ff7f9684b4 100644 --- a/guava/src/com/google/common/collect/AbstractTable.java +++ b/guava/src/com/google/common/collect/AbstractTable.java @@ -26,7 +26,7 @@ import java.util.Set; import java.util.Spliterator; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Skeletal, implementation-agnostic implementation of the {@link Table} interface. @@ -37,12 +37,12 @@ abstract class AbstractTable implements Table { @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { return Maps.safeContainsKey(rowMap(), rowKey); } @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { return Maps.safeContainsKey(columnMap(), columnKey); } @@ -57,7 +57,7 @@ public Set columnKeySet() { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { for (Map row : rowMap().values()) { if (row.containsValue(value)) { return true; @@ -67,13 +67,13 @@ public boolean containsValue(@NullableDecl Object value) { } @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { Map row = Maps.safeGet(rowMap(), rowKey); return row != null && Maps.safeContainsKey(row, columnKey); } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { Map row = Maps.safeGet(rowMap(), rowKey); return (row == null) ? null : Maps.safeGet(row, columnKey); } @@ -90,7 +90,7 @@ public void clear() { @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { Map row = Maps.safeGet(rowMap(), rowKey); return (row == null) ? null : Maps.safeRemove(row, columnKey); } @@ -139,7 +139,7 @@ public boolean contains(Object o) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o instanceof Cell) { Cell cell = (Cell) o; Map row = Maps.safeGet(rowMap(), cell.getRowKey()); @@ -225,7 +225,7 @@ public int size() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return Tables.equalsImpl(this, obj); } diff --git a/guava/src/com/google/common/collect/AllEqualOrdering.java b/guava/src/com/google/common/collect/AllEqualOrdering.java index bbcd19e01f85..357b1fcd2c0f 100644 --- a/guava/src/com/google/common/collect/AllEqualOrdering.java +++ b/guava/src/com/google/common/collect/AllEqualOrdering.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An ordering that treats all references as equals, even nulls. @@ -31,7 +31,7 @@ final class AllEqualOrdering extends Ordering implements Serializable { static final AllEqualOrdering INSTANCE = new AllEqualOrdering(); @Override - public int compare(@NullableDecl Object left, @NullableDecl Object right) { + public int compare(@Nullable Object left, @Nullable Object right) { return 0; } diff --git a/guava/src/com/google/common/collect/ArrayTable.java b/guava/src/com/google/common/collect/ArrayTable.java index 0157ae6fcddc..1a40c21cf909 100644 --- a/guava/src/com/google/common/collect/ArrayTable.java +++ b/guava/src/com/google/common/collect/ArrayTable.java @@ -36,7 +36,7 @@ import java.util.Set; import java.util.Spliterator; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Fixed-size {@link Table} implementation backed by a two-dimensional array. @@ -190,10 +190,10 @@ K getKey(int index) { abstract String getKeyRole(); - @NullableDecl + @Nullable abstract V getValue(int index); - @NullableDecl + @Nullable abstract V setValue(int index, V newValue); @Override @@ -244,12 +244,12 @@ Spliterator> entrySpliterator() { // TODO(lowasser): consider an optimized values() implementation @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return keyIndex.containsKey(key); } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { Integer index = keyIndex.get(key); if (index == null) { return null; @@ -328,7 +328,7 @@ public V at(int rowIndex, int columnIndex) { * to the number of allowed column keys */ @CanIgnoreReturnValue - public V set(int rowIndex, int columnIndex, @NullableDecl V value) { + public V set(int rowIndex, int columnIndex, @Nullable V value) { // In GWT array access never throws IndexOutOfBoundsException. checkElementIndex(rowIndex, rowList.size()); checkElementIndex(columnIndex, columnList.size()); @@ -380,7 +380,7 @@ public void eraseAll() { * constructed. */ @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return containsRow(rowKey) && containsColumn(columnKey); } @@ -389,7 +389,7 @@ public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object column * table was constructed. */ @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { return columnKeyToIndex.containsKey(columnKey); } @@ -398,12 +398,12 @@ public boolean containsColumn(@NullableDecl Object columnKey) { * constructed. */ @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { return rowKeyToIndex.containsKey(rowKey); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { for (V[] row : array) { for (V element : row) { if (Objects.equal(value, element)) { @@ -415,7 +415,7 @@ public boolean containsValue(@NullableDecl Object value) { } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { Integer rowIndex = rowKeyToIndex.get(rowKey); Integer columnIndex = columnKeyToIndex.get(columnKey); return (rowIndex == null || columnIndex == null) ? null : at(rowIndex, columnIndex); @@ -437,7 +437,7 @@ public boolean isEmpty() { */ @CanIgnoreReturnValue @Override - public V put(R rowKey, C columnKey, @NullableDecl V value) { + public V put(R rowKey, C columnKey, @Nullable V value) { checkNotNull(rowKey); checkNotNull(columnKey); Integer rowIndex = rowKeyToIndex.get(rowKey); @@ -494,7 +494,7 @@ public V remove(Object rowKey, Object columnKey) { * for the keys */ @CanIgnoreReturnValue - public V erase(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V erase(@Nullable Object rowKey, @Nullable Object columnKey) { Integer rowIndex = rowKeyToIndex.get(rowKey); Integer columnIndex = columnKeyToIndex.get(columnKey); if (rowIndex == null || columnIndex == null) { diff --git a/guava/src/com/google/common/collect/BiMap.java b/guava/src/com/google/common/collect/BiMap.java index 0fd75c0a1e5e..e4a755ebb250 100644 --- a/guava/src/com/google/common/collect/BiMap.java +++ b/guava/src/com/google/common/collect/BiMap.java @@ -20,7 +20,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as @@ -46,8 +46,8 @@ public interface BiMap extends Map { */ @CanIgnoreReturnValue @Override - @NullableDecl - V put(@NullableDecl K key, @NullableDecl V value); + @Nullable + V put(@Nullable K key, @Nullable V value); /** * An alternate form of {@code put} that silently removes any existing entry with the value {@code @@ -66,8 +66,8 @@ public interface BiMap extends Map { * {@code null} if there was no previous entry */ @CanIgnoreReturnValue - @NullableDecl - V forcePut(@NullableDecl K key, @NullableDecl V value); + @Nullable + V forcePut(@Nullable K key, @Nullable V value); // Bulk Operations diff --git a/guava/src/com/google/common/collect/ByFunctionOrdering.java b/guava/src/com/google/common/collect/ByFunctionOrdering.java index 9e8671b12583..f05bf01aa9ed 100644 --- a/guava/src/com/google/common/collect/ByFunctionOrdering.java +++ b/guava/src/com/google/common/collect/ByFunctionOrdering.java @@ -22,7 +22,7 @@ import com.google.common.base.Function; import com.google.common.base.Objects; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An ordering that orders elements by applying an order to the result of a function on those @@ -44,7 +44,7 @@ public int compare(F left, F right) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/CartesianList.java b/guava/src/com/google/common/collect/CartesianList.java index 3c1deab56ae9..74f202097222 100644 --- a/guava/src/com/google/common/collect/CartesianList.java +++ b/guava/src/com/google/common/collect/CartesianList.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.ListIterator; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Lists#cartesianProduct(List)}. @@ -96,7 +96,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (!(o instanceof List)) { return false; } diff --git a/guava/src/com/google/common/collect/ClassToInstanceMap.java b/guava/src/com/google/common/collect/ClassToInstanceMap.java index d22f57d12e15..2f1b3e847604 100644 --- a/guava/src/com/google/common/collect/ClassToInstanceMap.java +++ b/guava/src/com/google/common/collect/ClassToInstanceMap.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A map, each entry of which maps a Java raw type to an @@ -58,5 +58,5 @@ public interface ClassToInstanceMap extends Map, B> { * null} if there was no previous entry. */ @CanIgnoreReturnValue - T putInstance(Class type, @NullableDecl T value); + T putInstance(Class type, @Nullable T value); } diff --git a/guava/src/com/google/common/collect/CollectSpliterators.java b/guava/src/com/google/common/collect/CollectSpliterators.java index 8872c8d7874c..f697a8d23e07 100644 --- a/guava/src/com/google/common/collect/CollectSpliterators.java +++ b/guava/src/com/google/common/collect/CollectSpliterators.java @@ -28,7 +28,7 @@ import java.util.function.IntFunction; import java.util.function.Predicate; import java.util.stream.IntStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Spliterator utilities for {@code common.collect} internals. */ @GwtCompatible @@ -65,7 +65,7 @@ public void forEachRemaining(Consumer action) { } @Override - @NullableDecl + @Nullable public Spliterator trySplit() { Spliterator.OfInt split = delegate.trySplit(); return (split == null) ? null : new WithCharacteristics(split); @@ -209,7 +209,7 @@ static Spliterator flatMap( checkNotNull(fromSpliterator); checkNotNull(function); class FlatMapSpliterator implements Spliterator { - @NullableDecl Spliterator prefix; + @Nullable Spliterator prefix; final Spliterator from; int characteristics; long estimatedSize; diff --git a/guava/src/com/google/common/collect/Collections2.java b/guava/src/com/google/common/collect/Collections2.java index 9f9b62c63138..2685be9daa9b 100644 --- a/guava/src/com/google/common/collect/Collections2.java +++ b/guava/src/com/google/common/collect/Collections2.java @@ -37,7 +37,7 @@ import java.util.List; import java.util.Spliterator; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides static methods for working with {@code Collection} instances. @@ -97,7 +97,7 @@ public static Collection filter(Collection unfiltered, Predicate collection, @NullableDecl Object object) { + static boolean safeContains(Collection collection, @Nullable Object object) { checkNotNull(collection); try { return collection.contains(object); @@ -110,7 +110,7 @@ static boolean safeContains(Collection collection, @NullableDecl Object objec * Delegates to {@link Collection#remove}. Returns {@code false} if the {@code remove} method * throws a {@code ClassCastException} or {@code NullPointerException}. */ - static boolean safeRemove(Collection collection, @NullableDecl Object object) { + static boolean safeRemove(Collection collection, @Nullable Object object) { checkNotNull(collection); try { return collection.remove(object); @@ -153,7 +153,7 @@ public void clear() { } @Override - public boolean contains(@NullableDecl Object element) { + public boolean contains(@Nullable Object element) { if (safeContains(unfiltered, element)) { @SuppressWarnings("unchecked") // element is in unfiltered, so it must be an E E e = (E) element; @@ -494,7 +494,7 @@ public Iterator> iterator() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (obj instanceof List) { List list = (List) obj; return isPermutation(inputList, list); @@ -509,7 +509,7 @@ public String toString() { } private static final class OrderedPermutationIterator extends AbstractIterator> { - @NullableDecl List nextPermutation; + @Nullable List nextPermutation; final Comparator comparator; OrderedPermutationIterator(List list, Comparator comparator) { @@ -605,7 +605,7 @@ public Iterator> iterator() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (obj instanceof List) { List list = (List) obj; return isPermutation(inputList, list); diff --git a/guava/src/com/google/common/collect/CompactHashMap.java b/guava/src/com/google/common/collect/CompactHashMap.java index 77ada16c5855..ad8f54e02523 100644 --- a/guava/src/com/google/common/collect/CompactHashMap.java +++ b/guava/src/com/google/common/collect/CompactHashMap.java @@ -44,7 +44,7 @@ import java.util.function.BiFunction; import java.util.function.Consumer; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * CompactHashMap is an implementation of a Map. All optional operations (put and remove) are @@ -236,8 +236,8 @@ void accessEntry(int index) { @CanIgnoreReturnValue @Override - @NullableDecl - public V put(@NullableDecl K key, @NullableDecl V value) { + @Nullable + public V put(@Nullable K key, @Nullable V value) { long[] entries = this.entries; Object[] keys = this.keys; Object[] values = this.values; @@ -256,7 +256,7 @@ public V put(@NullableDecl K key, @NullableDecl V value) { entry = entries[next]; if (getHash(entry) == hash && Objects.equal(key, keys[next])) { @SuppressWarnings("unchecked") // known to be a V - @NullableDecl + @Nullable V oldValue = (V) values[next]; values[next] = value; @@ -284,7 +284,7 @@ public V put(@NullableDecl K key, @NullableDecl V value) { /** * Creates a fresh entry with the specified object at the specified position in the entry arrays. */ - void insertEntry(int entryIndex, @NullableDecl K key, @NullableDecl V value, int hash) { + void insertEntry(int entryIndex, @Nullable K key, @Nullable V value, int hash) { this.entries[entryIndex] = ((long) hash << 32) | (NEXT_MASK & UNSET); this.keys[entryIndex] = key; this.values[entryIndex] = value; @@ -345,7 +345,7 @@ private void resizeTable(int newCapacity) { // newCapacity always a power of two this.table = newTable; } - private int indexOf(@NullableDecl Object key) { + private int indexOf(@Nullable Object key) { int hash = smearedHash(key); int next = table[hash & hashTableMask()]; while (next != UNSET) { @@ -359,13 +359,13 @@ private int indexOf(@NullableDecl Object key) { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return indexOf(key) != -1; } @SuppressWarnings("unchecked") // values only contains Vs @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { int index = indexOf(key); accessEntry(index); return (index == -1) ? null : (V) values[index]; @@ -373,13 +373,13 @@ public V get(@NullableDecl Object key) { @CanIgnoreReturnValue @Override - @NullableDecl - public V remove(@NullableDecl Object key) { + @Nullable + public V remove(@Nullable Object key) { return remove(key, smearedHash(key)); } - @NullableDecl - private V remove(@NullableDecl Object key, int hash) { + @Nullable + private V remove(@Nullable Object key, int hash) { int tableIndex = hash & hashTableMask(); int next = table[tableIndex]; if (next == UNSET) { // empty bucket @@ -390,7 +390,7 @@ private V remove(@NullableDecl Object key, int hash) { if (getHash(entries[next]) == hash) { if (Objects.equal(key, keys[next])) { @SuppressWarnings("unchecked") // values only contains Vs - @NullableDecl + @Nullable V oldValue = (V) values[next]; if (last == UNSET) { @@ -554,7 +554,7 @@ public T[] toArray(T[] a) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { int index = indexOf(o); if (index == -1) { return false; @@ -631,7 +631,7 @@ public Spliterator> spliterator() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o instanceof Entry) { Entry entry = (Entry) o; int index = indexOf(entry.getKey()); @@ -641,7 +641,7 @@ public boolean contains(@NullableDecl Object o) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o instanceof Entry) { Entry entry = (Entry) o; int index = indexOf(entry.getKey()); @@ -664,7 +664,7 @@ Entry getOutput(int entry) { } final class MapEntry extends AbstractMapEntry { - @NullableDecl private final K key; + @Nullable private final K key; private int lastKnownIndex; @@ -720,7 +720,7 @@ public boolean isEmpty() { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { for (int i = 0; i < size; i++) { if (Objects.equal(value, values[i])) { return true; diff --git a/guava/src/com/google/common/collect/CompactHashSet.java b/guava/src/com/google/common/collect/CompactHashSet.java index d4f9f8bf5763..f1293bfb4a74 100644 --- a/guava/src/com/google/common/collect/CompactHashSet.java +++ b/guava/src/com/google/common/collect/CompactHashSet.java @@ -39,7 +39,7 @@ import java.util.Spliterators; import java.util.function.Consumer; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * CompactHashSet is an implementation of a Set. All optional operations (adding and removing) are @@ -226,7 +226,7 @@ private int hashTableMask() { @CanIgnoreReturnValue @Override - public boolean add(@NullableDecl E object) { + public boolean add(@Nullable E object) { long[] entries = this.entries; Object[] elements = this.elements; int hash = smearedHash(object); @@ -325,7 +325,7 @@ private void resizeTable(int newCapacity) { // newCapacity always a power of two } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { int hash = smearedHash(object); int next = table[hash & hashTableMask()]; while (next != UNSET) { @@ -340,7 +340,7 @@ public boolean contains(@NullableDecl Object object) { @CanIgnoreReturnValue @Override - public boolean remove(@NullableDecl Object object) { + public boolean remove(@Nullable Object object) { return remove(object, smearedHash(object)); } diff --git a/guava/src/com/google/common/collect/ComparatorOrdering.java b/guava/src/com/google/common/collect/ComparatorOrdering.java index a40892003e64..52cbf2af6fd8 100644 --- a/guava/src/com/google/common/collect/ComparatorOrdering.java +++ b/guava/src/com/google/common/collect/ComparatorOrdering.java @@ -21,7 +21,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.Comparator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering for a pre-existing comparator. */ @GwtCompatible(serializable = true) @@ -38,7 +38,7 @@ public int compare(T a, T b) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/ComparisonChain.java b/guava/src/com/google/common/collect/ComparisonChain.java index 2f748961949a..578166de0e93 100644 --- a/guava/src/com/google/common/collect/ComparisonChain.java +++ b/guava/src/com/google/common/collect/ComparisonChain.java @@ -21,7 +21,7 @@ import com.google.common.primitives.Ints; import com.google.common.primitives.Longs; import java.util.Comparator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A utility for performing a chained comparison statement. For example: @@ -75,7 +75,7 @@ public ComparisonChain compare(Comparable left, Comparable right) { @Override public ComparisonChain compare( - @NullableDecl T left, @NullableDecl T right, Comparator comparator) { + @Nullable T left, @Nullable T right, Comparator comparator) { return classify(comparator.compare(left, right)); } @@ -131,13 +131,13 @@ private static final class InactiveComparisonChain extends ComparisonChain { } @Override - public ComparisonChain compare(@NullableDecl Comparable left, @NullableDecl Comparable right) { + public ComparisonChain compare(@Nullable Comparable left, @Nullable Comparable right) { return this; } @Override public ComparisonChain compare( - @NullableDecl T left, @NullableDecl T right, @NullableDecl Comparator comparator) { + @Nullable T left, @Nullable T right, @Nullable Comparator comparator) { return this; } @@ -188,7 +188,7 @@ public int result() { * already been determined. */ public abstract ComparisonChain compare( - @NullableDecl T left, @NullableDecl T right, Comparator comparator); + @Nullable T left, @Nullable T right, Comparator comparator); /** * Compares two {@code int} values as specified by {@link Ints#compare}, if the result of diff --git a/guava/src/com/google/common/collect/ComputationException.java b/guava/src/com/google/common/collect/ComputationException.java index 29046f76e00c..590546784fc8 100644 --- a/guava/src/com/google/common/collect/ComputationException.java +++ b/guava/src/com/google/common/collect/ComputationException.java @@ -17,7 +17,7 @@ package com.google.common.collect; import com.google.common.annotations.GwtCompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Wraps an exception that occurred during a computation. @@ -28,7 +28,7 @@ @GwtCompatible public class ComputationException extends RuntimeException { /** Creates a new instance with the given cause. */ - public ComputationException(@NullableDecl Throwable cause) { + public ComputationException(@Nullable Throwable cause) { super(cause); } diff --git a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java index 8bdfca32d0d4..ab49e9aa97ef 100644 --- a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java +++ b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java @@ -41,7 +41,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A multiset that supports concurrent modifications and that provides atomic versions of most @@ -137,7 +137,7 @@ public static ConcurrentHashMultiset create(ConcurrentMap delegate() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && Collections2.safeContains(delegate, object); } @@ -522,7 +522,7 @@ protected Entry computeNext() { }; return new ForwardingIterator>() { - @NullableDecl private Entry last; + @Nullable private Entry last; @Override protected Iterator> delegate() { diff --git a/guava/src/com/google/common/collect/Count.java b/guava/src/com/google/common/collect/Count.java index 9a0ea41d9cba..e2da82a36144 100644 --- a/guava/src/com/google/common/collect/Count.java +++ b/guava/src/com/google/common/collect/Count.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A mutable value of type {@code int}, for multisets to use in tracking counts of values. @@ -59,7 +59,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return obj instanceof Count && ((Count) obj).value == value; } diff --git a/guava/src/com/google/common/collect/Cut.java b/guava/src/com/google/common/collect/Cut.java index b792d84e0403..3a12b2473a76 100644 --- a/guava/src/com/google/common/collect/Cut.java +++ b/guava/src/com/google/common/collect/Cut.java @@ -20,7 +20,7 @@ import com.google.common.primitives.Booleans; import java.io.Serializable; import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation detail for the internal structure of {@link Range} instances. Represents a unique @@ -33,9 +33,9 @@ */ @GwtCompatible abstract class Cut implements Comparable>, Serializable { - @NullableDecl final C endpoint; + @Nullable final C endpoint; - Cut(@NullableDecl C endpoint) { + Cut(@Nullable C endpoint) { this.endpoint = endpoint; } @@ -326,7 +326,7 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case CLOSED: return this; case OPEN: - @NullableDecl C previous = domain.previous(endpoint); + @Nullable C previous = domain.previous(endpoint); return (previous == null) ? Cut.belowAll() : new AboveValue(previous); default: throw new AssertionError(); @@ -337,7 +337,7 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { switch (boundType) { case CLOSED: - @NullableDecl C previous = domain.previous(endpoint); + @Nullable C previous = domain.previous(endpoint); return (previous == null) ? Cut.aboveAll() : new AboveValue(previous); case OPEN: return this; @@ -409,7 +409,7 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { case OPEN: return this; case CLOSED: - @NullableDecl C next = domain.next(endpoint); + @Nullable C next = domain.next(endpoint); return (next == null) ? Cut.belowAll() : belowValue(next); default: throw new AssertionError(); @@ -420,7 +420,7 @@ Cut withLowerBoundType(BoundType boundType, DiscreteDomain domain) { Cut withUpperBoundType(BoundType boundType, DiscreteDomain domain) { switch (boundType) { case OPEN: - @NullableDecl C next = domain.next(endpoint); + @Nullable C next = domain.next(endpoint); return (next == null) ? Cut.aboveAll() : belowValue(next); case CLOSED: return this; diff --git a/guava/src/com/google/common/collect/DenseImmutableTable.java b/guava/src/com/google/common/collect/DenseImmutableTable.java index 2ff1a12921dc..2e2688a99a81 100644 --- a/guava/src/com/google/common/collect/DenseImmutableTable.java +++ b/guava/src/com/google/common/collect/DenseImmutableTable.java @@ -21,7 +21,7 @@ import com.google.errorprone.annotations.Immutable; import com.google.j2objc.annotations.WeakOuter; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** A {@code RegularImmutableTable} optimized for dense data. */ @GwtCompatible @@ -101,7 +101,7 @@ K getKey(int index) { return keyToIndex().keySet().asList().get(index); } - @NullableDecl + @Nullable abstract V getValue(int keyIndex); @Override @@ -115,7 +115,7 @@ public int size() { } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { Integer keyIndex = keyToIndex().get(key); return (keyIndex == null) ? null : getValue(keyIndex); } @@ -247,7 +247,7 @@ public ImmutableMap> rowMap() { } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { Integer rowIndex = rowKeyToIndex.get(rowKey); Integer columnIndex = columnKeyToIndex.get(columnKey); return ((rowIndex == null) || (columnIndex == null)) ? null : values[rowIndex][columnIndex]; diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java b/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java index 189acdb5fd26..346bafb5ee20 100644 --- a/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java +++ b/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java @@ -15,7 +15,7 @@ package com.google.common.collect; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A descending wrapper around an {@code ImmutableSortedMultiset} @@ -32,7 +32,7 @@ final class DescendingImmutableSortedMultiset extends ImmutableSortedMultiset } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { return forward.count(element); } diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java b/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java index 64e3e89acb07..635437837386 100644 --- a/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java @@ -17,7 +17,7 @@ package com.google.common.collect; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Skeletal implementation of {@link ImmutableSortedSet#descendingSet()}. @@ -34,7 +34,7 @@ final class DescendingImmutableSortedSet extends ImmutableSortedSet { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return forward.contains(object); } @@ -103,7 +103,7 @@ public E higher(E element) { } @Override - int indexOf(@NullableDecl Object target) { + int indexOf(@Nullable Object target) { int index = forward.indexOf(target); if (index == -1) { return index; diff --git a/guava/src/com/google/common/collect/EmptyContiguousSet.java b/guava/src/com/google/common/collect/EmptyContiguousSet.java index b86fda0e0321..325566485fee 100644 --- a/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -18,7 +18,7 @@ import java.io.Serializable; import java.util.NoSuchElementException; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An empty contiguous set. @@ -121,7 +121,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Set) { Set that = (Set) object; return that.isEmpty(); diff --git a/guava/src/com/google/common/collect/EnumHashBiMap.java b/guava/src/com/google/common/collect/EnumHashBiMap.java index b67e126758f2..1a5f0f51b9cb 100644 --- a/guava/src/com/google/common/collect/EnumHashBiMap.java +++ b/guava/src/com/google/common/collect/EnumHashBiMap.java @@ -27,7 +27,7 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@code BiMap} backed by an {@code EnumMap} instance for keys-to-values, and a {@code HashMap} @@ -85,13 +85,13 @@ K checkKey(K key) { @CanIgnoreReturnValue @Override - public V put(K key, @NullableDecl V value) { + public V put(K key, @Nullable V value) { return super.put(key, value); } @CanIgnoreReturnValue @Override - public V forcePut(K key, @NullableDecl V value) { + public V forcePut(K key, @Nullable V value) { return super.forcePut(key, value); } diff --git a/guava/src/com/google/common/collect/EnumMultiset.java b/guava/src/com/google/common/collect/EnumMultiset.java index 9d3b9339e4de..bf1f3944d56e 100644 --- a/guava/src/com/google/common/collect/EnumMultiset.java +++ b/guava/src/com/google/common/collect/EnumMultiset.java @@ -31,7 +31,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.function.ObjIntConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Multiset implementation specialized for enum elements, supporting all single-element operations @@ -94,7 +94,7 @@ private EnumMultiset(Class type) { this.counts = new int[enumConstants.length]; } - private boolean isActuallyE(@NullableDecl Object o) { + private boolean isActuallyE(@Nullable Object o) { if (o instanceof Enum) { Enum e = (Enum) o; int index = e.ordinal(); @@ -108,7 +108,7 @@ private boolean isActuallyE(@NullableDecl Object o) { * either a NullPointerException or a ClassCastException as appropriate. */ @SuppressWarnings("unchecked") - void checkIsE(@NullableDecl Object element) { + void checkIsE(@Nullable Object element) { checkNotNull(element); if (!isActuallyE(element)) { throw new ClassCastException("Expected an " + type + " but got " + element); @@ -126,7 +126,7 @@ public int size() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { if (element == null || !isActuallyE(element)) { return 0; } @@ -158,7 +158,7 @@ public int add(E element, int occurrences) { // Modification Operations @CanIgnoreReturnValue @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { if (element == null || !isActuallyE(element)) { return 0; } diff --git a/guava/src/com/google/common/collect/ExplicitOrdering.java b/guava/src/com/google/common/collect/ExplicitOrdering.java index 710c1aea0722..526e6e39b425 100644 --- a/guava/src/com/google/common/collect/ExplicitOrdering.java +++ b/guava/src/com/google/common/collect/ExplicitOrdering.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering that compares objects according to a given order. */ @GwtCompatible(serializable = true) @@ -48,7 +48,7 @@ private int rank(T value) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof ExplicitOrdering) { ExplicitOrdering that = (ExplicitOrdering) object; return this.rankMap.equals(that.rankMap); diff --git a/guava/src/com/google/common/collect/FilteredEntryMultimap.java b/guava/src/com/google/common/collect/FilteredEntryMultimap.java index 5860d885c625..ced909a2120b 100644 --- a/guava/src/com/google/common/collect/FilteredEntryMultimap.java +++ b/guava/src/com/google/common/collect/FilteredEntryMultimap.java @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Multimaps#filterEntries(Multimap, Predicate)}. @@ -78,7 +78,7 @@ final class ValuePredicate implements Predicate { } @Override - public boolean apply(@NullableDecl V value) { + public boolean apply(@Nullable V value) { return satisfies(key, value); } } @@ -93,12 +93,12 @@ static Collection filterCollection( } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return asMap().get(key) != null; } @Override - public Collection removeAll(@NullableDecl Object key) { + public Collection removeAll(@Nullable Object key) { return MoreObjects.firstNonNull(asMap().remove(key), unmodifiableEmptyCollection()); } @@ -166,7 +166,7 @@ boolean removeEntriesIf(Predicate>> predicate) { @WeakOuter class AsMap extends ViewCachingAbstractMap> { @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @@ -176,7 +176,7 @@ public void clear() { } @Override - public Collection get(@NullableDecl Object key) { + public Collection get(@Nullable Object key) { Collection result = unfiltered.asMap().get(key); if (result == null) { return null; @@ -188,7 +188,7 @@ public Collection get(@NullableDecl Object key) { } @Override - public Collection remove(@NullableDecl Object key) { + public Collection remove(@Nullable Object key) { Collection collection = unfiltered.asMap().get(key); if (collection == null) { return null; @@ -232,7 +232,7 @@ public boolean retainAll(Collection c) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { return AsMap.this.remove(o) != null; } } @@ -297,7 +297,7 @@ class ValuesImpl extends Maps.Values> { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o instanceof Collection) { Collection c = (Collection) o; Iterator>> entryIterator = @@ -346,7 +346,7 @@ class Keys extends Multimaps.Keys { } @Override - public int remove(@NullableDecl Object key, int occurrences) { + public int remove(@Nullable Object key, int occurrences) { checkNonnegative(occurrences, "occurrences"); if (occurrences == 0) { return count(key); diff --git a/guava/src/com/google/common/collect/FilteredKeyListMultimap.java b/guava/src/com/google/common/collect/FilteredKeyListMultimap.java index 2a5522541222..8de9ed426042 100644 --- a/guava/src/com/google/common/collect/FilteredKeyListMultimap.java +++ b/guava/src/com/google/common/collect/FilteredKeyListMultimap.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.base.Predicate; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Multimaps#filterKeys(ListMultimap, Predicate)}. @@ -44,7 +44,7 @@ public List get(K key) { } @Override - public List removeAll(@NullableDecl Object key) { + public List removeAll(@Nullable Object key) { return (List) super.removeAll(key); } diff --git a/guava/src/com/google/common/collect/FilteredKeyMultimap.java b/guava/src/com/google/common/collect/FilteredKeyMultimap.java index 2a3003d15c92..12456b3891f7 100644 --- a/guava/src/com/google/common/collect/FilteredKeyMultimap.java +++ b/guava/src/com/google/common/collect/FilteredKeyMultimap.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Multimaps#filterKeys(Multimap, Predicate)}. @@ -65,7 +65,7 @@ public int size() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { if (unfiltered.containsKey(key)) { @SuppressWarnings("unchecked") // k is equal to a K, if not one itself K k = (K) key; @@ -190,7 +190,7 @@ protected Collection> delegate() { @Override @SuppressWarnings("unchecked") - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o instanceof Entry) { Entry entry = (Entry) o; if (unfiltered.containsKey(entry.getKey()) diff --git a/guava/src/com/google/common/collect/FilteredKeySetMultimap.java b/guava/src/com/google/common/collect/FilteredKeySetMultimap.java index 1ec8e6532e39..f6fb61d58830 100644 --- a/guava/src/com/google/common/collect/FilteredKeySetMultimap.java +++ b/guava/src/com/google/common/collect/FilteredKeySetMultimap.java @@ -20,7 +20,7 @@ import com.google.common.base.Predicate; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Multimaps#filterKeys(SetMultimap, Predicate)}. @@ -72,7 +72,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { return Sets.equalsImpl(this, o); } } diff --git a/guava/src/com/google/common/collect/FilteredMultimapValues.java b/guava/src/com/google/common/collect/FilteredMultimapValues.java index b92707af5d57..7e3d25707855 100644 --- a/guava/src/com/google/common/collect/FilteredMultimapValues.java +++ b/guava/src/com/google/common/collect/FilteredMultimapValues.java @@ -25,7 +25,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation for {@link FilteredMultimap#values()}. @@ -46,7 +46,7 @@ public Iterator iterator() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { return multimap.containsValue(o); } @@ -56,7 +56,7 @@ public int size() { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { Predicate> entryPredicate = multimap.entryPredicate(); for (Iterator> unfilteredItr = multimap.unfiltered().entries().iterator(); unfilteredItr.hasNext(); ) { diff --git a/guava/src/com/google/common/collect/FluentIterable.java b/guava/src/com/google/common/collect/FluentIterable.java index 60892f9a98c1..9f7214b5dbc1 100644 --- a/guava/src/com/google/common/collect/FluentIterable.java +++ b/guava/src/com/google/common/collect/FluentIterable.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.SortedSet; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A discouraged (but not deprecated) precursor to Java's superior {@link Stream} library. @@ -321,7 +321,7 @@ public static FluentIterable of() { * @since 20.0 */ @Beta - public static FluentIterable of(@NullableDecl E element, E... elements) { + public static FluentIterable of(@Nullable E element, E... elements) { return from(Lists.asList(element, elements)); } @@ -352,7 +352,7 @@ public final int size() { * *

    {@code Stream} equivalent: {@code stream.anyMatch(Predicate.isEqual(target))}. */ - public final boolean contains(@NullableDecl Object target) { + public final boolean contains(@Nullable Object target) { return Iterables.contains(getDelegate(), target); } @@ -822,7 +822,7 @@ public final String join(Joiner joiner) { * @throws IndexOutOfBoundsException if {@code position} is negative or greater than or equal to * the size of this fluent iterable */ - // TODO(kevinb): add @NullableDecl? + // TODO(kevinb): add @Nullable? public final E get(int position) { return Iterables.get(getDelegate(), position); } diff --git a/guava/src/com/google/common/collect/ForwardingCollection.java b/guava/src/com/google/common/collect/ForwardingCollection.java index 416ff968a715..66219c8622eb 100644 --- a/guava/src/com/google/common/collect/ForwardingCollection.java +++ b/guava/src/com/google/common/collect/ForwardingCollection.java @@ -21,7 +21,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Collection; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection which forwards all its method calls to another collection. Subclasses should @@ -133,7 +133,7 @@ public T[] toArray(T[] array) { * * @since 7.0 */ - protected boolean standardContains(@NullableDecl Object object) { + protected boolean standardContains(@Nullable Object object) { return Iterators.contains(iterator(), object); } @@ -165,7 +165,7 @@ protected boolean standardAddAll(Collection collection) { * * @since 7.0 */ - protected boolean standardRemove(@NullableDecl Object object) { + protected boolean standardRemove(@Nullable Object object) { Iterator iterator = iterator(); while (iterator.hasNext()) { if (Objects.equal(iterator.next(), object)) { diff --git a/guava/src/com/google/common/collect/ForwardingList.java b/guava/src/com/google/common/collect/ForwardingList.java index bfd208313410..d2ba154c6227 100644 --- a/guava/src/com/google/common/collect/ForwardingList.java +++ b/guava/src/com/google/common/collect/ForwardingList.java @@ -23,7 +23,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A list which forwards all its method calls to another list. Subclasses should override one or @@ -114,7 +114,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this || delegate().equals(object); } @@ -153,7 +153,7 @@ protected boolean standardAddAll(int index, Iterable elements) { * * @since 7.0 */ - protected int standardIndexOf(@NullableDecl Object element) { + protected int standardIndexOf(@Nullable Object element) { return Lists.indexOfImpl(this, element); } @@ -164,7 +164,7 @@ protected int standardIndexOf(@NullableDecl Object element) { * * @since 7.0 */ - protected int standardLastIndexOf(@NullableDecl Object element) { + protected int standardLastIndexOf(@Nullable Object element) { return Lists.lastIndexOfImpl(this, element); } @@ -222,7 +222,7 @@ protected List standardSubList(int fromIndex, int toIndex) { * @since 7.0 */ @Beta - protected boolean standardEquals(@NullableDecl Object object) { + protected boolean standardEquals(@Nullable Object object) { return Lists.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/ForwardingListMultimap.java b/guava/src/com/google/common/collect/ForwardingListMultimap.java index 8cf3d703b483..c67d56c47e43 100644 --- a/guava/src/com/google/common/collect/ForwardingListMultimap.java +++ b/guava/src/com/google/common/collect/ForwardingListMultimap.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A list multimap which forwards all its method calls to another list multimap. Subclasses should @@ -44,13 +44,13 @@ protected ForwardingListMultimap() {} protected abstract ListMultimap delegate(); @Override - public List get(@NullableDecl K key) { + public List get(@Nullable K key) { return delegate().get(key); } @CanIgnoreReturnValue @Override - public List removeAll(@NullableDecl Object key) { + public List removeAll(@Nullable Object key) { return delegate().removeAll(key); } diff --git a/guava/src/com/google/common/collect/ForwardingMap.java b/guava/src/com/google/common/collect/ForwardingMap.java index 761a54173188..20e32b3009ee 100644 --- a/guava/src/com/google/common/collect/ForwardingMap.java +++ b/guava/src/com/google/common/collect/ForwardingMap.java @@ -24,7 +24,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A map which forwards all its method calls to another map. Subclasses should override one or more @@ -86,17 +86,17 @@ public void clear() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return delegate().containsKey(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return delegate().containsValue(value); } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return delegate().get(key); } @@ -127,7 +127,7 @@ public Set> entrySet() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this || delegate().equals(object); } @@ -158,7 +158,7 @@ protected void standardPutAll(Map map) { * @since 7.0 */ @Beta - protected V standardRemove(@NullableDecl Object key) { + protected V standardRemove(@Nullable Object key) { Iterator> entryIterator = entrySet().iterator(); while (entryIterator.hasNext()) { Entry entry = entryIterator.next(); @@ -207,7 +207,7 @@ public StandardKeySet() { * @since 7.0 */ @Beta - protected boolean standardContainsKey(@NullableDecl Object key) { + protected boolean standardContainsKey(@Nullable Object key) { return Maps.containsKeyImpl(this, key); } @@ -235,7 +235,7 @@ public StandardValues() { * * @since 7.0 */ - protected boolean standardContainsValue(@NullableDecl Object value) { + protected boolean standardContainsValue(@Nullable Object value) { return Maps.containsValueImpl(this, value); } @@ -277,7 +277,7 @@ protected boolean standardIsEmpty() { * * @since 7.0 */ - protected boolean standardEquals(@NullableDecl Object object) { + protected boolean standardEquals(@Nullable Object object) { return Maps.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/ForwardingMapEntry.java b/guava/src/com/google/common/collect/ForwardingMapEntry.java index 198b94bd5506..c775986d6052 100644 --- a/guava/src/com/google/common/collect/ForwardingMapEntry.java +++ b/guava/src/com/google/common/collect/ForwardingMapEntry.java @@ -21,7 +21,7 @@ import com.google.common.base.Objects; import java.util.Map; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A map entry which forwards all its method calls to another map entry. Subclasses should override @@ -72,7 +72,7 @@ public V setValue(V value) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return delegate().equals(object); } @@ -88,7 +88,7 @@ public int hashCode() { * * @since 7.0 */ - protected boolean standardEquals(@NullableDecl Object object) { + protected boolean standardEquals(@Nullable Object object) { if (object instanceof Entry) { Entry that = (Entry) object; return Objects.equal(this.getKey(), that.getKey()) diff --git a/guava/src/com/google/common/collect/ForwardingMultimap.java b/guava/src/com/google/common/collect/ForwardingMultimap.java index 991d0cf9a089..bc6d9020e125 100644 --- a/guava/src/com/google/common/collect/ForwardingMultimap.java +++ b/guava/src/com/google/common/collect/ForwardingMultimap.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A multimap which forwards all its method calls to another multimap. Subclasses should override @@ -56,17 +56,17 @@ public void clear() { } @Override - public boolean containsEntry(@NullableDecl Object key, @NullableDecl Object value) { + public boolean containsEntry(@Nullable Object key, @Nullable Object value) { return delegate().containsEntry(key, value); } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return delegate().containsKey(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return delegate().containsValue(value); } @@ -76,7 +76,7 @@ public Collection> entries() { } @Override - public Collection get(@NullableDecl K key) { + public Collection get(@Nullable K key) { return delegate().get(key); } @@ -115,13 +115,13 @@ public boolean putAll(Multimap multimap) { @CanIgnoreReturnValue @Override - public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { + public boolean remove(@Nullable Object key, @Nullable Object value) { return delegate().remove(key, value); } @CanIgnoreReturnValue @Override - public Collection removeAll(@NullableDecl Object key) { + public Collection removeAll(@Nullable Object key) { return delegate().removeAll(key); } @@ -142,7 +142,7 @@ public Collection values() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this || delegate().equals(object); } diff --git a/guava/src/com/google/common/collect/ForwardingMultiset.java b/guava/src/com/google/common/collect/ForwardingMultiset.java index 9a7084f54950..6bf5c33bc3f7 100644 --- a/guava/src/com/google/common/collect/ForwardingMultiset.java +++ b/guava/src/com/google/common/collect/ForwardingMultiset.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A multiset which forwards all its method calls to another multiset. Subclasses should override @@ -84,7 +84,7 @@ public Set> entrySet() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this || delegate().equals(object); } @@ -112,7 +112,7 @@ public boolean setCount(E element, int oldCount, int newCount) { * @since 7.0 */ @Override - protected boolean standardContains(@NullableDecl Object object) { + protected boolean standardContains(@Nullable Object object) { return count(object) > 0; } @@ -136,7 +136,7 @@ protected void standardClear() { * @since 7.0 */ @Beta - protected int standardCount(@NullableDecl Object object) { + protected int standardCount(@Nullable Object object) { for (Entry entry : this.entrySet()) { if (Objects.equal(entry.getElement(), object)) { return entry.getCount(); @@ -285,7 +285,7 @@ protected int standardSize() { * * @since 7.0 */ - protected boolean standardEquals(@NullableDecl Object object) { + protected boolean standardEquals(@Nullable Object object) { return Multisets.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/ForwardingSet.java b/guava/src/com/google/common/collect/ForwardingSet.java index 73b1413a3c5d..ff21924c0e6c 100644 --- a/guava/src/com/google/common/collect/ForwardingSet.java +++ b/guava/src/com/google/common/collect/ForwardingSet.java @@ -21,7 +21,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Collection; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A set which forwards all its method calls to another set. Subclasses should override one or more @@ -56,7 +56,7 @@ protected ForwardingSet() {} protected abstract Set delegate(); @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return object == this || delegate().equals(object); } @@ -84,7 +84,7 @@ protected boolean standardRemoveAll(Collection collection) { * * @since 7.0 */ - protected boolean standardEquals(@NullableDecl Object object) { + protected boolean standardEquals(@Nullable Object object) { return Sets.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/ForwardingSetMultimap.java b/guava/src/com/google/common/collect/ForwardingSetMultimap.java index 61a0de2bd19b..a4d6c76f5d5b 100644 --- a/guava/src/com/google/common/collect/ForwardingSetMultimap.java +++ b/guava/src/com/google/common/collect/ForwardingSetMultimap.java @@ -20,7 +20,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A set multimap which forwards all its method calls to another set multimap. Subclasses should @@ -47,13 +47,13 @@ public Set> entries() { } @Override - public Set get(@NullableDecl K key) { + public Set get(@Nullable K key) { return delegate().get(key); } @CanIgnoreReturnValue @Override - public Set removeAll(@NullableDecl Object key) { + public Set removeAll(@Nullable Object key) { return delegate().removeAll(key); } diff --git a/guava/src/com/google/common/collect/ForwardingSortedMap.java b/guava/src/com/google/common/collect/ForwardingSortedMap.java index 4866fb9850b6..8539adf1b676 100644 --- a/guava/src/com/google/common/collect/ForwardingSortedMap.java +++ b/guava/src/com/google/common/collect/ForwardingSortedMap.java @@ -23,7 +23,7 @@ import java.util.Comparator; import java.util.NoSuchElementException; import java.util.SortedMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A sorted map which forwards all its method calls to another sorted map. Subclasses should @@ -126,7 +126,7 @@ private int unsafeCompare(Object k1, Object k2) { */ @Override @Beta - protected boolean standardContainsKey(@NullableDecl Object key) { + protected boolean standardContainsKey(@Nullable Object key) { try { // any CCE will be caught @SuppressWarnings("unchecked") diff --git a/guava/src/com/google/common/collect/ForwardingSortedSet.java b/guava/src/com/google/common/collect/ForwardingSortedSet.java index 9879944838e8..4c4ddf4ebeec 100644 --- a/guava/src/com/google/common/collect/ForwardingSortedSet.java +++ b/guava/src/com/google/common/collect/ForwardingSortedSet.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A sorted set which forwards all its method calls to another sorted set. Subclasses should @@ -92,7 +92,7 @@ public SortedSet tailSet(E fromElement) { // unsafe, but worst case is a CCE is thrown, which callers will be expecting @SuppressWarnings("unchecked") - private int unsafeCompare(@NullableDecl Object o1, @NullableDecl Object o2) { + private int unsafeCompare(@Nullable Object o1, @Nullable Object o2) { Comparator comparator = comparator(); return (comparator == null) ? ((Comparable) o1).compareTo(o2) @@ -108,7 +108,7 @@ private int unsafeCompare(@NullableDecl Object o1, @NullableDecl Object o2) { */ @Override @Beta - protected boolean standardContains(@NullableDecl Object object) { + protected boolean standardContains(@Nullable Object object) { try { // any ClassCastExceptions are caught @SuppressWarnings("unchecked") @@ -129,7 +129,7 @@ protected boolean standardContains(@NullableDecl Object object) { */ @Override @Beta - protected boolean standardRemove(@NullableDecl Object object) { + protected boolean standardRemove(@Nullable Object object) { try { // any ClassCastExceptions are caught @SuppressWarnings("unchecked") diff --git a/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java b/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java index 78319a7732db..546eb477e942 100644 --- a/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java +++ b/guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java @@ -19,7 +19,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Comparator; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A sorted set multimap which forwards all its method calls to another sorted set multimap. @@ -44,12 +44,12 @@ protected ForwardingSortedSetMultimap() {} protected abstract SortedSetMultimap delegate(); @Override - public SortedSet get(@NullableDecl K key) { + public SortedSet get(@Nullable K key) { return delegate().get(key); } @Override - public SortedSet removeAll(@NullableDecl Object key) { + public SortedSet removeAll(@Nullable Object key) { return delegate().removeAll(key); } diff --git a/guava/src/com/google/common/collect/GeneralRange.java b/guava/src/com/google/common/collect/GeneralRange.java index fca07bc0bbcc..697769ace6e6 100644 --- a/guava/src/com/google/common/collect/GeneralRange.java +++ b/guava/src/com/google/common/collect/GeneralRange.java @@ -24,7 +24,7 @@ import java.io.Serializable; import java.util.Comparator; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A generalized interval on any ordering, for internal use. Supports {@code null}. Unlike {@link @@ -39,10 +39,10 @@ final class GeneralRange implements Serializable { /** Converts a Range to a GeneralRange. */ static GeneralRange from(Range range) { - @NullableDecl T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null; + @Nullable T lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : null; BoundType lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : OPEN; - @NullableDecl T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null; + @Nullable T upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : null; BoundType upperBoundType = range.hasUpperBound() ? range.upperBoundType() : OPEN; return new GeneralRange( Ordering.natural(), @@ -64,7 +64,7 @@ static GeneralRange all(Comparator comparator) { * endpoint behavior. */ static GeneralRange downTo( - Comparator comparator, @NullableDecl T endpoint, BoundType boundType) { + Comparator comparator, @Nullable T endpoint, BoundType boundType) { return new GeneralRange(comparator, true, endpoint, boundType, false, null, OPEN); } @@ -73,7 +73,7 @@ static GeneralRange downTo( * endpoint behavior. */ static GeneralRange upTo( - Comparator comparator, @NullableDecl T endpoint, BoundType boundType) { + Comparator comparator, @Nullable T endpoint, BoundType boundType) { return new GeneralRange(comparator, false, null, OPEN, true, endpoint, boundType); } @@ -83,28 +83,28 @@ static GeneralRange upTo( */ static GeneralRange range( Comparator comparator, - @NullableDecl T lower, + @Nullable T lower, BoundType lowerType, - @NullableDecl T upper, + @Nullable T upper, BoundType upperType) { return new GeneralRange(comparator, true, lower, lowerType, true, upper, upperType); } private final Comparator comparator; private final boolean hasLowerBound; - @NullableDecl private final T lowerEndpoint; + @Nullable private final T lowerEndpoint; private final BoundType lowerBoundType; private final boolean hasUpperBound; - @NullableDecl private final T upperEndpoint; + @Nullable private final T upperEndpoint; private final BoundType upperBoundType; private GeneralRange( Comparator comparator, boolean hasLowerBound, - @NullableDecl T lowerEndpoint, + @Nullable T lowerEndpoint, BoundType lowerBoundType, boolean hasUpperBound, - @NullableDecl T upperEndpoint, + @Nullable T upperEndpoint, BoundType upperBoundType) { this.comparator = checkNotNull(comparator); this.hasLowerBound = hasLowerBound; @@ -148,7 +148,7 @@ boolean isEmpty() { || (hasLowerBound() && tooHigh(getLowerEndpoint())); } - boolean tooLow(@NullableDecl T t) { + boolean tooLow(@Nullable T t) { if (!hasLowerBound()) { return false; } @@ -157,7 +157,7 @@ boolean tooLow(@NullableDecl T t) { return cmp < 0 | (cmp == 0 & getLowerBoundType() == OPEN); } - boolean tooHigh(@NullableDecl T t) { + boolean tooHigh(@Nullable T t) { if (!hasUpperBound()) { return false; } @@ -166,7 +166,7 @@ boolean tooHigh(@NullableDecl T t) { return cmp > 0 | (cmp == 0 & getUpperBoundType() == OPEN); } - boolean contains(@NullableDecl T t) { + boolean contains(@Nullable T t) { return !tooLow(t) && !tooHigh(t); } @@ -178,7 +178,7 @@ GeneralRange intersect(GeneralRange other) { checkArgument(comparator.equals(other.comparator)); boolean hasLowBound = this.hasLowerBound; - @NullableDecl T lowEnd = getLowerEndpoint(); + @Nullable T lowEnd = getLowerEndpoint(); BoundType lowType = getLowerBoundType(); if (!hasLowerBound()) { hasLowBound = other.hasLowerBound; @@ -193,7 +193,7 @@ GeneralRange intersect(GeneralRange other) { } boolean hasUpBound = this.hasUpperBound; - @NullableDecl T upEnd = getUpperEndpoint(); + @Nullable T upEnd = getUpperEndpoint(); BoundType upType = getUpperBoundType(); if (!hasUpperBound()) { hasUpBound = other.hasUpperBound; @@ -221,7 +221,7 @@ GeneralRange intersect(GeneralRange other) { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof GeneralRange) { GeneralRange r = (GeneralRange) obj; return comparator.equals(r.comparator) diff --git a/guava/src/com/google/common/collect/HashBasedTable.java b/guava/src/com/google/common/collect/HashBasedTable.java index 07c144f6d28b..8f6df57808e6 100644 --- a/guava/src/com/google/common/collect/HashBasedTable.java +++ b/guava/src/com/google/common/collect/HashBasedTable.java @@ -24,7 +24,7 @@ import java.io.Serializable; import java.util.LinkedHashMap; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link Table} using linked hash tables. This guarantees predictable iteration @@ -106,38 +106,38 @@ public static HashBasedTable create( // Overriding so NullPointerTester test passes. @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return super.contains(rowKey, columnKey); } @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { return super.containsColumn(columnKey); } @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { return super.containsRow(rowKey); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return super.containsValue(value); } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { return super.get(rowKey, columnKey); } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return super.equals(obj); } @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { return super.remove(rowKey, columnKey); } diff --git a/guava/src/com/google/common/collect/HashBiMap.java b/guava/src/com/google/common/collect/HashBiMap.java index 61e557908577..c1c4bf6046c1 100644 --- a/guava/src/com/google/common/collect/HashBiMap.java +++ b/guava/src/com/google/common/collect/HashBiMap.java @@ -40,7 +40,7 @@ import java.util.function.BiConsumer; import java.util.function.BiFunction; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link BiMap} backed by two hash tables. This implementation allows null keys and values. A @@ -88,11 +88,11 @@ private static final class BiEntry extends ImmutableEntry { final int keyHash; final int valueHash; - @NullableDecl BiEntry nextInKToVBucket; - @NullableDecl BiEntry nextInVToKBucket; + @Nullable BiEntry nextInKToVBucket; + @Nullable BiEntry nextInVToKBucket; - @NullableDecl BiEntry nextInKeyInsertionOrder; - @NullableDecl BiEntry prevInKeyInsertionOrder; + @Nullable BiEntry nextInKeyInsertionOrder; + @Nullable BiEntry prevInKeyInsertionOrder; BiEntry(K key, int keyHash, V value, int valueHash) { super(key, value); @@ -105,8 +105,8 @@ private static final class BiEntry extends ImmutableEntry { private transient BiEntry[] hashTableKToV; private transient BiEntry[] hashTableVToK; - @NullableDecl private transient BiEntry firstInKeyInsertionOrder; - @NullableDecl private transient BiEntry lastInKeyInsertionOrder; + @Nullable private transient BiEntry firstInKeyInsertionOrder; + @Nullable private transient BiEntry lastInKeyInsertionOrder; private transient int size; private transient int mask; private transient int modCount; @@ -180,7 +180,7 @@ private void delete(BiEntry entry) { modCount++; } - private void insert(BiEntry entry, @NullableDecl BiEntry oldEntryForKey) { + private void insert(BiEntry entry, @Nullable BiEntry oldEntryForKey) { int keyBucket = entry.keyHash & mask; entry.nextInKToVBucket = hashTableKToV[keyBucket]; hashTableKToV[keyBucket] = entry; @@ -217,7 +217,7 @@ private void insert(BiEntry entry, @NullableDecl BiEntry oldEntryFor modCount++; } - private BiEntry seekByKey(@NullableDecl Object key, int keyHash) { + private BiEntry seekByKey(@Nullable Object key, int keyHash) { for (BiEntry entry = hashTableKToV[keyHash & mask]; entry != null; entry = entry.nextInKToVBucket) { @@ -228,7 +228,7 @@ private BiEntry seekByKey(@NullableDecl Object key, int keyHash) { return null; } - private BiEntry seekByValue(@NullableDecl Object value, int valueHash) { + private BiEntry seekByValue(@Nullable Object value, int valueHash) { for (BiEntry entry = hashTableVToK[valueHash & mask]; entry != null; entry = entry.nextInVToKBucket) { @@ -240,28 +240,28 @@ private BiEntry seekByValue(@NullableDecl Object value, int valueHash) { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return seekByKey(key, smearedHash(key)) != null; } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return seekByValue(value, smearedHash(value)) != null; } - @NullableDecl + @Nullable @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return Maps.valueOrNull(seekByKey(key, smearedHash(key))); } @CanIgnoreReturnValue @Override - public V put(@NullableDecl K key, @NullableDecl V value) { + public V put(@Nullable K key, @Nullable V value) { return put(key, value, false); } - private V put(@NullableDecl K key, @NullableDecl V value, boolean force) { + private V put(@Nullable K key, @Nullable V value, boolean force) { int keyHash = smearedHash(key); int valueHash = smearedHash(value); @@ -297,12 +297,12 @@ private V put(@NullableDecl K key, @NullableDecl V value, boolean force) { @CanIgnoreReturnValue @Override - public V forcePut(@NullableDecl K key, @NullableDecl V value) { + public V forcePut(@Nullable K key, @Nullable V value) { return put(key, value, true); } - @NullableDecl - private K putInverse(@NullableDecl V value, @NullableDecl K key, boolean force) { + @Nullable + private K putInverse(@Nullable V value, @Nullable K key, boolean force) { int valueHash = smearedHash(value); int keyHash = smearedHash(key); @@ -372,7 +372,7 @@ private BiEntry[] createTable(int length) { @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { BiEntry entry = seekByKey(key, smearedHash(key)); if (entry == null) { return null; @@ -462,7 +462,7 @@ K output(BiEntry entry) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { BiEntry entry = seekByKey(o, smearedHash(o)); if (entry == null) { return false; @@ -574,28 +574,28 @@ public void clear() { } @Override - public boolean containsKey(@NullableDecl Object value) { + public boolean containsKey(@Nullable Object value) { return forward().containsValue(value); } @Override - public K get(@NullableDecl Object value) { + public K get(@Nullable Object value) { return Maps.keyOrNull(seekByValue(value, smearedHash(value))); } @CanIgnoreReturnValue @Override - public K put(@NullableDecl V value, @NullableDecl K key) { + public K put(@Nullable V value, @Nullable K key) { return putInverse(value, key, false); } @Override - public K forcePut(@NullableDecl V value, @NullableDecl K key) { + public K forcePut(@Nullable V value, @Nullable K key) { return putInverse(value, key, true); } @Override - public K remove(@NullableDecl Object value) { + public K remove(@Nullable Object value) { BiEntry entry = seekByValue(value, smearedHash(value)); if (entry == null) { return null; @@ -624,7 +624,7 @@ private final class InverseKeySet extends Maps.KeySet { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { BiEntry entry = seekByValue(o, smearedHash(o)); if (entry == null) { return false; diff --git a/guava/src/com/google/common/collect/Hashing.java b/guava/src/com/google/common/collect/Hashing.java index d5cab1faf1e0..8d7c874180c8 100644 --- a/guava/src/com/google/common/collect/Hashing.java +++ b/guava/src/com/google/common/collect/Hashing.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.primitives.Ints; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static methods for implementing hash-based collections. @@ -50,7 +50,7 @@ static int smear(int hashCode) { return (int) (C2 * Integer.rotateLeft((int) (hashCode * C1), 15)); } - static int smearedHash(@NullableDecl Object o) { + static int smearedHash(@Nullable Object o) { return smear((o == null) ? 0 : o.hashCode()); } diff --git a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java index 0846039acd1b..b775baa23c3f 100644 --- a/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java +++ b/guava/src/com/google/common/collect/ImmutableClassToInstanceMap.java @@ -23,7 +23,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.Serializable; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link ClassToInstanceMap} whose contents will never change, with many other important @@ -169,7 +169,7 @@ protected Map, B> delegate() { @Override @SuppressWarnings("unchecked") // value could not get in if not a T - @NullableDecl + @Nullable public T getInstance(Class type) { return (T) delegate.get(checkNotNull(type)); } diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java index 1fa4e62e99ff..daac3af80fa4 100644 --- a/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/guava/src/com/google/common/collect/ImmutableCollection.java @@ -29,7 +29,7 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.function.Predicate; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Collection} whose contents will never change, and which offers a few additional @@ -207,7 +207,7 @@ public final T[] toArray(T[] other) { } @Override - public abstract boolean contains(@NullableDecl Object object); + public abstract boolean contains(@Nullable Object object); /** * Guaranteed to throw an exception and leave the collection unmodified. diff --git a/guava/src/com/google/common/collect/ImmutableEntry.java b/guava/src/com/google/common/collect/ImmutableEntry.java index 806ecb7cdd79..5122e08019bf 100644 --- a/guava/src/com/google/common/collect/ImmutableEntry.java +++ b/guava/src/com/google/common/collect/ImmutableEntry.java @@ -18,26 +18,26 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** @see com.google.common.collect.Maps#immutableEntry(Object, Object) */ @GwtCompatible(serializable = true) class ImmutableEntry extends AbstractMapEntry implements Serializable { - @NullableDecl final K key; - @NullableDecl final V value; + @Nullable final K key; + @Nullable final V value; - ImmutableEntry(@NullableDecl K key, @NullableDecl V value) { + ImmutableEntry(@Nullable K key, @Nullable V value) { this.key = key; this.value = value; } - @NullableDecl + @Nullable @Override public final K getKey() { return key; } - @NullableDecl + @Nullable @Override public final V getValue() { return value; diff --git a/guava/src/com/google/common/collect/ImmutableEnumMap.java b/guava/src/com/google/common/collect/ImmutableEnumMap.java index da7bef3ef544..f12e1a9e686c 100644 --- a/guava/src/com/google/common/collect/ImmutableEnumMap.java +++ b/guava/src/com/google/common/collect/ImmutableEnumMap.java @@ -24,7 +24,7 @@ import java.util.EnumMap; import java.util.Spliterator; import java.util.function.BiConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link ImmutableMap} backed by a non-empty {@link java.util.EnumMap}. @@ -69,7 +69,7 @@ public int size() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return delegate.containsKey(key); } diff --git a/guava/src/com/google/common/collect/ImmutableList.java b/guava/src/com/google/common/collect/ImmutableList.java index 4b8227f6da4d..683dfad0a9b2 100644 --- a/guava/src/com/google/common/collect/ImmutableList.java +++ b/guava/src/com/google/common/collect/ImmutableList.java @@ -42,7 +42,7 @@ import java.util.function.Consumer; import java.util.function.UnaryOperator; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link List} whose contents will never change, with many other important properties detailed at @@ -409,17 +409,17 @@ public void forEach(Consumer consumer) { } @Override - public int indexOf(@NullableDecl Object object) { + public int indexOf(@Nullable Object object) { return (object == null) ? -1 : Lists.indexOfImpl(this, object); } @Override - public int lastIndexOf(@NullableDecl Object object) { + public int lastIndexOf(@Nullable Object object) { return (object == null) ? -1 : Lists.lastIndexOfImpl(this, object); } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return indexOf(object) >= 0; } @@ -617,18 +617,18 @@ public ImmutableList reverse() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return forwardList.contains(object); } @Override - public int indexOf(@NullableDecl Object object) { + public int indexOf(@Nullable Object object) { int index = forwardList.lastIndexOf(object); return (index >= 0) ? reverseIndex(index) : -1; } @Override - public int lastIndexOf(@NullableDecl Object object) { + public int lastIndexOf(@Nullable Object object) { int index = forwardList.indexOf(object); return (index >= 0) ? reverseIndex(index) : -1; } @@ -657,7 +657,7 @@ boolean isPartialView() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { return Lists.equalsImpl(this, obj); } diff --git a/guava/src/com/google/common/collect/ImmutableListMultimap.java b/guava/src/com/google/common/collect/ImmutableListMultimap.java index 0cfdd4daa3a1..decbcf63cbae 100644 --- a/guava/src/com/google/common/collect/ImmutableListMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableListMultimap.java @@ -37,7 +37,7 @@ import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link ListMultimap} whose contents will never change, with many other important properties @@ -365,7 +365,7 @@ public static ImmutableListMultimap copyOf( /** Creates an ImmutableListMultimap from an asMap.entrySet. */ static ImmutableListMultimap fromMapEntries( Collection>> mapEntries, - @NullableDecl Comparator valueComparator) { + @Nullable Comparator valueComparator) { if (mapEntries.isEmpty()) { return of(); } @@ -401,7 +401,7 @@ static ImmutableListMultimap fromMapEntries( * parameters used to build this multimap. */ @Override - public ImmutableList get(@NullableDecl K key) { + public ImmutableList get(@Nullable K key) { // This cast is safe as its type is known in constructor. ImmutableList list = (ImmutableList) map.get(key); return (list == null) ? ImmutableList.of() : list; diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index fbdcafdf3821..401c893a3853 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -46,7 +46,7 @@ import java.util.stream.Collector; import java.util.stream.Collectors; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Map} whose contents will never change, with many other important properties detailed at @@ -682,18 +682,18 @@ public boolean isEmpty() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return values().contains(value); } // Overriding to mark it Nullable @Override - public abstract V get(@NullableDecl Object key); + public abstract V get(@Nullable Object key); /** * @since 21.0 (but only since 23.5 in the Android createKeySet() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return ImmutableMap.this.containsKey(key); } @Override - public ImmutableSet get(@NullableDecl Object key) { + public ImmutableSet get(@Nullable Object key) { V outerValue = ImmutableMap.this.get(key); return (outerValue == null) ? null : ImmutableSet.of(outerValue); } @@ -866,7 +866,7 @@ public ImmutableSet getValue() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return Maps.equalsImpl(this, object); } diff --git a/guava/src/com/google/common/collect/ImmutableMapEntry.java b/guava/src/com/google/common/collect/ImmutableMapEntry.java index 1aee9b513669..8d5eb84ad971 100644 --- a/guava/src/com/google/common/collect/ImmutableMapEntry.java +++ b/guava/src/com/google/common/collect/ImmutableMapEntry.java @@ -19,7 +19,7 @@ import static com.google.common.collect.CollectPreconditions.checkEntryNotNull; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@code Entry} for {@link ImmutableMap} that adds extra methods to traverse hash @@ -53,12 +53,12 @@ static ImmutableMapEntry[] createEntryArray(int size) { // null check would be redundant } - @NullableDecl + @Nullable ImmutableMapEntry getNextInKeyBucket() { return null; } - @NullableDecl + @Nullable ImmutableMapEntry getNextInValueBucket() { return null; } @@ -80,7 +80,7 @@ static class NonTerminalImmutableMapEntry extends ImmutableMapEntry } @Override - @NullableDecl + @Nullable final ImmutableMapEntry getNextInKeyBucket() { return nextInKeyBucket; } @@ -105,7 +105,7 @@ static final class NonTerminalImmutableBiMapEntry } @Override - @NullableDecl + @Nullable ImmutableMapEntry getNextInValueBucket() { return nextInValueBucket; } diff --git a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java index 5677a07e3ea1..323dba3844bc 100644 --- a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java +++ b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java @@ -23,7 +23,7 @@ import java.util.Map.Entry; import java.util.Spliterator; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@code entrySet()} implementation for {@link ImmutableMap}. @@ -88,7 +88,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { if (object instanceof Entry) { Entry entry = (Entry) object; V value = map().get(entry.getKey()); diff --git a/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/guava/src/com/google/common/collect/ImmutableMapKeySet.java index f98a33d1bee9..b858023b65c2 100644 --- a/guava/src/com/google/common/collect/ImmutableMapKeySet.java +++ b/guava/src/com/google/common/collect/ImmutableMapKeySet.java @@ -24,7 +24,7 @@ import java.io.Serializable; import java.util.Spliterator; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@code keySet()} implementation for {@link ImmutableMap}. @@ -56,7 +56,7 @@ public Spliterator spliterator() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return map.containsKey(object); } diff --git a/guava/src/com/google/common/collect/ImmutableMapValues.java b/guava/src/com/google/common/collect/ImmutableMapValues.java index ab02c1d6aff0..6ccf98f6a26b 100644 --- a/guava/src/com/google/common/collect/ImmutableMapValues.java +++ b/guava/src/com/google/common/collect/ImmutableMapValues.java @@ -25,7 +25,7 @@ import java.util.Map.Entry; import java.util.Spliterator; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@code values()} implementation for {@link ImmutableMap}. @@ -69,7 +69,7 @@ public Spliterator spliterator() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return object != null && Iterators.contains(iterator(), object); } diff --git a/guava/src/com/google/common/collect/ImmutableMultimap.java b/guava/src/com/google/common/collect/ImmutableMultimap.java index dea4bb7040d8..e65cdc44c3b6 100644 --- a/guava/src/com/google/common/collect/ImmutableMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableMultimap.java @@ -37,7 +37,7 @@ import java.util.Spliterator; import java.util.function.BiConsumer; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Multimap} whose contents will never change, with many other important properties @@ -467,12 +467,12 @@ boolean isPartialView() { // accessors @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return map.containsKey(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return value != null && super.containsValue(value); } @@ -623,12 +623,12 @@ ImmutableMultiset createKeys() { @WeakOuter class Keys extends ImmutableMultiset { @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return containsKey(object); } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { Collection values = map.get(element); return (values == null) ? 0 : values.size(); } @@ -717,7 +717,7 @@ private static final class Values extends ImmutableCollection { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return multimap.containsValue(object); } diff --git a/guava/src/com/google/common/collect/ImmutableMultiset.java b/guava/src/com/google/common/collect/ImmutableMultiset.java index eb9c889f5a10..1c825cac2f4c 100644 --- a/guava/src/com/google/common/collect/ImmutableMultiset.java +++ b/guava/src/com/google/common/collect/ImmutableMultiset.java @@ -35,7 +35,7 @@ import java.util.function.ToIntFunction; import java.util.stream.Collector; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Multiset} whose contents will never change, with many other important properties @@ -268,7 +268,7 @@ public ImmutableList asList() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return count(object) > 0; } @@ -335,7 +335,7 @@ int copyIntoArray(Object[] dst, int offset) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return Multisets.equalsImpl(this, object); } @@ -600,7 +600,7 @@ E get(int index) { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return delegate.contains(object); } diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java index 41bdbd93e3e4..9d758d9a4357 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeMap.java +++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java @@ -31,7 +31,7 @@ import java.util.NoSuchElementException; import java.util.function.Function; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link RangeMap} whose contents will never change, with many other important properties @@ -169,7 +169,7 @@ public ImmutableRangeMap build() { } @Override - @NullableDecl + @Nullable public V get(K key) { int index = SortedLists.binarySearch( @@ -187,7 +187,7 @@ public V get(K key) { } @Override - @NullableDecl + @Nullable public Entry, V> getEntry(K key) { int index = SortedLists.binarySearch( @@ -361,7 +361,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof RangeMap) { RangeMap rangeMap = (RangeMap) o; return asMapOfRanges().equals(rangeMap.asMapOfRanges()); diff --git a/guava/src/com/google/common/collect/ImmutableRangeSet.java b/guava/src/com/google/common/collect/ImmutableRangeSet.java index bbc621ad44ba..3407bfb98989 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeSet.java +++ b/guava/src/com/google/common/collect/ImmutableRangeSet.java @@ -36,7 +36,7 @@ import java.util.Set; import java.util.stream.Collector; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link RangeSet} whose contents will never change, with many other important properties @@ -629,7 +629,7 @@ ImmutableSortedSet tailSetImpl(C fromElement, boolean inclusive) { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o == null) { return false; } diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java index a9b6dab226ff..9af82851ca13 100644 --- a/guava/src/com/google/common/collect/ImmutableSet.java +++ b/guava/src/com/google/common/collect/ImmutableSet.java @@ -40,7 +40,7 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Set} whose contents will never change, with many other important properties detailed at @@ -280,7 +280,7 @@ boolean isHashCodeFast() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } else if (object instanceof ImmutableSet @@ -302,7 +302,7 @@ public int hashCode() { @Override public abstract UnmodifiableIterator iterator(); - @LazyInit @NullableDecl @RetainedWith private transient ImmutableList asList; + @LazyInit @Nullable @RetainedWith private transient ImmutableList asList; @Override public ImmutableList asList() { diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java index 997586c1c916..a26330c12936 100644 --- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -41,7 +41,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link SetMultimap} whose contents will never change, with many other important properties @@ -414,7 +414,7 @@ public static ImmutableSetMultimap copyOf( /** Creates an ImmutableSetMultimap from an asMap.entrySet. */ static ImmutableSetMultimap fromMapEntries( Collection>> mapEntries, - @NullableDecl Comparator valueComparator) { + @Nullable Comparator valueComparator) { if (mapEntries.isEmpty()) { return of(); } @@ -444,7 +444,7 @@ static ImmutableSetMultimap fromMapEntries( ImmutableSetMultimap( ImmutableMap> map, int size, - @NullableDecl Comparator valueComparator) { + @Nullable Comparator valueComparator) { super(map, size); this.emptySet = emptySet(valueComparator); } @@ -457,7 +457,7 @@ static ImmutableSetMultimap fromMapEntries( * parameters used to build this multimap. */ @Override - public ImmutableSet get(@NullableDecl K key) { + public ImmutableSet get(@Nullable K key) { // This cast is safe as its type is known in constructor. ImmutableSet set = (ImmutableSet) map.get(key); return MoreObjects.firstNonNull(set, emptySet); @@ -536,7 +536,7 @@ private static final class EntrySet extends ImmutableSet> { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { if (object instanceof Entry) { Entry entry = (Entry) object; return multimap.containsEntry(entry.getKey(), entry.getValue()); @@ -561,20 +561,20 @@ boolean isPartialView() { } private static ImmutableSet valueSet( - @NullableDecl Comparator valueComparator, Collection values) { + @Nullable Comparator valueComparator, Collection values) { return (valueComparator == null) ? ImmutableSet.copyOf(values) : ImmutableSortedSet.copyOf(valueComparator, values); } - private static ImmutableSet emptySet(@NullableDecl Comparator valueComparator) { + private static ImmutableSet emptySet(@Nullable Comparator valueComparator) { return (valueComparator == null) ? ImmutableSet.of() : ImmutableSortedSet.emptySet(valueComparator); } private static ImmutableSet.Builder valuesBuilder( - @NullableDecl Comparator valueComparator) { + @Nullable Comparator valueComparator) { return (valueComparator == null) ? new ImmutableSet.Builder() : new ImmutableSortedSet.Builder(valueComparator); @@ -591,7 +591,7 @@ private void writeObject(ObjectOutputStream stream) throws IOException { Serialization.writeMultimap(this, stream); } - @NullableDecl + @Nullable Comparator valueComparator() { return emptySet instanceof ImmutableSortedSet ? ((ImmutableSortedSet) emptySet).comparator() diff --git a/guava/src/com/google/common/collect/ImmutableSortedAsList.java b/guava/src/com/google/common/collect/ImmutableSortedAsList.java index 1ef5ba537bda..91f700ece687 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedAsList.java +++ b/guava/src/com/google/common/collect/ImmutableSortedAsList.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtIncompatible; import java.util.Comparator; import java.util.Spliterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * List returned by {@code ImmutableSortedSet.asList()} when the set isn't empty. @@ -49,7 +49,7 @@ public Comparator comparator() { @GwtIncompatible // ImmutableSortedSet.indexOf // TODO(cpovirk): consider manual binary search under GWT to preserve O(log N) lookup @Override - public int indexOf(@NullableDecl Object target) { + public int indexOf(@Nullable Object target) { int index = delegateCollection().indexOf(target); // TODO(kevinb): reconsider if it's really worth making feeble attempts at @@ -62,7 +62,7 @@ public int indexOf(@NullableDecl Object target) { @GwtIncompatible // ImmutableSortedSet.indexOf @Override - public int lastIndexOf(@NullableDecl Object target) { + public int lastIndexOf(@Nullable Object target) { return indexOf(target); } diff --git a/guava/src/com/google/common/collect/ImmutableSortedMap.java b/guava/src/com/google/common/collect/ImmutableSortedMap.java index 5dd6a5174237..a3d55e20bfe4 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedMap.java +++ b/guava/src/com/google/common/collect/ImmutableSortedMap.java @@ -39,7 +39,7 @@ import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link NavigableMap} whose contents will never change, with many other important properties @@ -590,7 +590,7 @@ public void forEach(BiConsumer action) { } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { int index = keySet.indexOf(key); return (index == -1) ? null : valueList.get(index); } diff --git a/guava/src/com/google/common/collect/ImmutableSortedSet.java b/guava/src/com/google/common/collect/ImmutableSortedSet.java index 9899f8a934b1..c318ba11319e 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/ImmutableSortedSet.java @@ -39,7 +39,7 @@ import java.util.Spliterators; import java.util.function.Consumer; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link NavigableSet} whose contents will never change, with many other important properties @@ -807,7 +807,7 @@ public Comparator getComparator() { public abstract UnmodifiableIterator descendingIterator(); /** Returns the position of an element within the set, or -1 if not present. */ - abstract int indexOf(@NullableDecl Object target); + abstract int indexOf(@Nullable Object target); /* * This class is used to serialize all ImmutableSortedSet instances, diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java index 16a56156cf41..9cce716dce57 100644 --- a/guava/src/com/google/common/collect/ImmutableTable.java +++ b/guava/src/com/google/common/collect/ImmutableTable.java @@ -34,7 +34,7 @@ import java.util.function.Function; import java.util.stream.Collector; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Table} whose contents will never change, with many other important properties detailed @@ -442,12 +442,12 @@ public ImmutableSet rowKeySet() { public abstract ImmutableMap> rowMap(); @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return get(rowKey, columnKey) != null; } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return values().contains(value); } diff --git a/guava/src/com/google/common/collect/Iterables.java b/guava/src/com/google/common/collect/Iterables.java index 5893b3d8b831..2f000b6e6ffc 100644 --- a/guava/src/com/google/common/collect/Iterables.java +++ b/guava/src/com/google/common/collect/Iterables.java @@ -39,7 +39,7 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An assortment of mainly legacy static utility methods that operate on or return objects of type @@ -132,7 +132,7 @@ public static int size(Iterable iterable) { * cases where {@link Collection#contains} might throw {@link NullPointerException} or {@link * ClassCastException}. */ - public static boolean contains(Iterable iterable, @NullableDecl Object element) { + public static boolean contains(Iterable iterable, @Nullable Object element) { if (iterable instanceof Collection) { Collection collection = (Collection) iterable; return Collections2.safeContains(collection, element); @@ -199,7 +199,7 @@ public static boolean removeIf(Iterable removeFrom, Predicate } /** Removes and returns the first matching element, or returns {@code null} if there is none. */ - @NullableDecl + @Nullable static T removeFirstMatching(Iterable removeFrom, Predicate predicate) { checkNotNull(predicate); Iterator iterator = removeFrom.iterator(); @@ -263,8 +263,8 @@ public static T getOnlyElement(Iterable iterable) { * * @throws IllegalArgumentException if the iterator contains multiple elements */ - @NullableDecl - public static T getOnlyElement(Iterable iterable, @NullableDecl T defaultValue) { + @Nullable + public static T getOnlyElement(Iterable iterable, @Nullable T defaultValue) { return Iterators.getOnlyElement(iterable.iterator(), defaultValue); } @@ -331,7 +331,7 @@ public static boolean addAll(Collection addTo, Iterable elem * @see java.util.Collections#frequency(Collection, Object) Collections.frequency(Collection, * Object) */ - public static int frequency(Iterable iterable, @NullableDecl Object element) { + public static int frequency(Iterable iterable, @Nullable Object element) { if ((iterable instanceof Multiset)) { return ((Multiset) iterable).count(element); } else if ((iterable instanceof Set)) { @@ -641,11 +641,9 @@ public static T find(Iterable iterable, Predicate predicate) { * * @since 7.0 */ - @NullableDecl + @Nullable public static T find( - Iterable iterable, - Predicate predicate, - @NullableDecl T defaultValue) { + Iterable iterable, Predicate predicate, @Nullable T defaultValue) { return Iterators.find(iterable.iterator(), predicate, defaultValue); } @@ -747,9 +745,8 @@ public static T get(Iterable iterable, int position) { * @throws IndexOutOfBoundsException if {@code position} is negative * @since 4.0 */ - @NullableDecl - public static T get( - Iterable iterable, int position, @NullableDecl T defaultValue) { + @Nullable + public static T get(Iterable iterable, int position, @Nullable T defaultValue) { checkNotNull(iterable); Iterators.checkNonnegative(position); if (iterable instanceof List) { @@ -779,8 +776,8 @@ public static T get( * @return the first element of {@code iterable} or the default value * @since 7.0 */ - @NullableDecl - public static T getFirst(Iterable iterable, @NullableDecl T defaultValue) { + @Nullable + public static T getFirst(Iterable iterable, @Nullable T defaultValue) { return Iterators.getNext(iterable.iterator(), defaultValue); } @@ -817,8 +814,8 @@ public static T getLast(Iterable iterable) { * @return the last element of {@code iterable} or the default value * @since 3.0 */ - @NullableDecl - public static T getLast(Iterable iterable, @NullableDecl T defaultValue) { + @Nullable + public static T getLast(Iterable iterable, @Nullable T defaultValue) { if (iterable instanceof Collection) { Collection c = Collections2.cast(iterable); if (c.isEmpty()) { diff --git a/guava/src/com/google/common/collect/Iterators.java b/guava/src/com/google/common/collect/Iterators.java index 6b96ef5dc462..9bbaeec1983e 100644 --- a/guava/src/com/google/common/collect/Iterators.java +++ b/guava/src/com/google/common/collect/Iterators.java @@ -45,7 +45,7 @@ import java.util.NoSuchElementException; import java.util.PriorityQueue; import java.util.Queue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class contains static utility methods that operate on or return objects of type {@link @@ -168,7 +168,7 @@ public static int size(Iterator iterator) { } /** Returns {@code true} if {@code iterator} contains {@code element}. */ - public static boolean contains(Iterator iterator, @NullableDecl Object element) { + public static boolean contains(Iterator iterator, @Nullable Object element) { if (element == null) { while (iterator.hasNext()) { if (iterator.next() == null) { @@ -324,8 +324,8 @@ public static T getOnlyElement(Iterator iterator) { * iterator is unspecified. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this? - @NullableDecl - public static T getOnlyElement(Iterator iterator, @NullableDecl T defaultValue) { + @Nullable + public static T getOnlyElement(Iterator iterator, @Nullable T defaultValue) { return iterator.hasNext() ? getOnlyElement(iterator) : defaultValue; } @@ -366,7 +366,7 @@ public static boolean addAll(Collection addTo, Iterator iter * * @see Collections#frequency */ - public static int frequency(Iterator iterator, @NullableDecl Object element) { + public static int frequency(Iterator iterator, @Nullable Object element) { int count = 0; while (contains(iterator, element)) { // Since it lives in the same class, we know contains gets to the element and then stops, @@ -707,11 +707,9 @@ public static T find(Iterator iterator, Predicate predicate) { * * @since 7.0 */ - @NullableDecl + @Nullable public static T find( - Iterator iterator, - Predicate predicate, - @NullableDecl T defaultValue) { + Iterator iterator, Predicate predicate, @Nullable T defaultValue) { checkNotNull(iterator); checkNotNull(predicate); while (iterator.hasNext()) { @@ -825,9 +823,8 @@ public static T get(Iterator iterator, int position) { * @throws IndexOutOfBoundsException if {@code position} is negative * @since 4.0 */ - @NullableDecl - public static T get( - Iterator iterator, int position, @NullableDecl T defaultValue) { + @Nullable + public static T get(Iterator iterator, int position, @Nullable T defaultValue) { checkNonnegative(position); advance(iterator, position); return getNext(iterator, defaultValue); @@ -847,8 +844,8 @@ static void checkNonnegative(int position) { * @return the next element of {@code iterator} or the default value * @since 7.0 */ - @NullableDecl - public static T getNext(Iterator iterator, @NullableDecl T defaultValue) { + @Nullable + public static T getNext(Iterator iterator, @Nullable T defaultValue) { return iterator.hasNext() ? iterator.next() : defaultValue; } @@ -875,8 +872,8 @@ public static T getLast(Iterator iterator) { * @return the last element of {@code iterator} * @since 3.0 */ - @NullableDecl - public static T getLast(Iterator iterator, @NullableDecl T defaultValue) { + @Nullable + public static T getLast(Iterator iterator, @Nullable T defaultValue) { return iterator.hasNext() ? getLast(iterator) : defaultValue; } @@ -973,7 +970,7 @@ public String toString() { * Deletes and returns the next value from the iterator, or returns {@code null} if there is no * such value. */ - @NullableDecl + @Nullable static T pollNext(Iterator iterator) { if (iterator.hasNext()) { T result = iterator.next(); @@ -1054,7 +1051,7 @@ protected T get(int index) { * *

    The {@link Iterable} equivalent of this method is {@link Collections#singleton}. */ - public static UnmodifiableIterator singletonIterator(@NullableDecl final T value) { + public static UnmodifiableIterator singletonIterator(@Nullable final T value) { return new UnmodifiableIterator() { boolean done; @@ -1122,7 +1119,7 @@ private static class PeekingImpl implements PeekingIterator { private final Iterator iterator; private boolean hasPeeked; - @NullableDecl private E peekedElement; + @Nullable private E peekedElement; public PeekingImpl(Iterator iterator) { this.iterator = checkNotNull(iterator); @@ -1291,7 +1288,7 @@ public T next() { private static class ConcatenatedIterator implements Iterator { /* The last iterator to return an element. Calls to remove() go to this iterator. */ - @NullableDecl private Iterator toRemove; + @Nullable private Iterator toRemove; /* The iterator currently returning elements. */ private Iterator iterator; @@ -1306,7 +1303,7 @@ private static class ConcatenatedIterator implements Iterator { private Iterator> topMetaIterator; // Only becomes nonnull if we encounter nested concatenations. - @NullableDecl private Deque>> metaIterators; + @Nullable private Deque>> metaIterators; ConcatenatedIterator(Iterator> metaIterator) { iterator = emptyIterator(); @@ -1314,7 +1311,7 @@ private static class ConcatenatedIterator implements Iterator { } // Returns a nonempty meta-iterator or, if all meta-iterators are empty, null. - @NullableDecl + @Nullable private Iterator> getTopMetaIterator() { while (topMetaIterator == null || !topMetaIterator.hasNext()) { if (metaIterators != null && !metaIterators.isEmpty()) { diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java index c87b3426f037..6fceaa91f2bf 100644 --- a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java +++ b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java @@ -21,7 +21,7 @@ import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.WeakOuter; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of ImmutableBiMap backed by a pair of JDK HashMaps, which have smartness @@ -100,7 +100,7 @@ public int size() { } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return forwardDelegate.get(key); } diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableMap.java b/guava/src/com/google/common/collect/JdkBackedImmutableMap.java index 84462c9bf615..ffbd1892aaa7 100644 --- a/guava/src/com/google/common/collect/JdkBackedImmutableMap.java +++ b/guava/src/com/google/common/collect/JdkBackedImmutableMap.java @@ -22,7 +22,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Map; import java.util.function.BiConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of ImmutableMap backed by a JDK HashMap, which has smartness protecting against @@ -61,7 +61,7 @@ public int size() { } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return delegateMap.get(key); } diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java b/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java index b4eb5f05f408..f2f196b6b3fa 100644 --- a/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java +++ b/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java @@ -20,7 +20,7 @@ import com.google.common.primitives.Ints; import java.util.Collection; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of ImmutableMultiset backed by a JDK Map and a list of entries. Used to protect @@ -61,7 +61,7 @@ private JdkBackedImmutableMultiset( } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { return delegateMap.getOrDefault(element, 0); } diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableSet.java b/guava/src/com/google/common/collect/JdkBackedImmutableSet.java index 2ceb72959c79..fa2c615e2ca8 100644 --- a/guava/src/com/google/common/collect/JdkBackedImmutableSet.java +++ b/guava/src/com/google/common/collect/JdkBackedImmutableSet.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * ImmutableSet implementation backed by a JDK HashSet, used to defend against apparent hash @@ -41,7 +41,7 @@ E get(int index) { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { return delegate.contains(object); } diff --git a/guava/src/com/google/common/collect/LexicographicalOrdering.java b/guava/src/com/google/common/collect/LexicographicalOrdering.java index 0e6c19652abf..5e00eb439e4e 100644 --- a/guava/src/com/google/common/collect/LexicographicalOrdering.java +++ b/guava/src/com/google/common/collect/LexicographicalOrdering.java @@ -20,7 +20,7 @@ import java.io.Serializable; import java.util.Comparator; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering which sorts iterables by comparing corresponding elements pairwise. */ @GwtCompatible(serializable = true) @@ -51,7 +51,7 @@ public int compare(Iterable leftIterable, Iterable rightIterable) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/LinkedHashMultimap.java b/guava/src/com/google/common/collect/LinkedHashMultimap.java index 19ce88704f1b..f4a1c65eb15d 100644 --- a/guava/src/com/google/common/collect/LinkedHashMultimap.java +++ b/guava/src/com/google/common/collect/LinkedHashMultimap.java @@ -40,7 +40,7 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@code Multimap} that does not allow duplicate key-value entries and that @@ -153,25 +153,25 @@ private static void deleteFromMultimap(ValueEntry entry) { static final class ValueEntry extends ImmutableEntry implements ValueSetLink { final int smearedValueHash; - @NullableDecl ValueEntry nextInValueBucket; + @Nullable ValueEntry nextInValueBucket; - @NullableDecl ValueSetLink predecessorInValueSet; - @NullableDecl ValueSetLink successorInValueSet; + @Nullable ValueSetLink predecessorInValueSet; + @Nullable ValueSetLink successorInValueSet; - @NullableDecl ValueEntry predecessorInMultimap; - @NullableDecl ValueEntry successorInMultimap; + @Nullable ValueEntry predecessorInMultimap; + @Nullable ValueEntry successorInMultimap; ValueEntry( - @NullableDecl K key, - @NullableDecl V value, + @Nullable K key, + @Nullable V value, int smearedValueHash, - @NullableDecl ValueEntry nextInValueBucket) { + @Nullable ValueEntry nextInValueBucket) { super(key, value); this.smearedValueHash = smearedValueHash; this.nextInValueBucket = nextInValueBucket; } - boolean matchesValue(@NullableDecl Object v, int smearedVHash) { + boolean matchesValue(@Nullable Object v, int smearedVHash) { return smearedValueHash == smearedVHash && Objects.equal(getValue(), v); } @@ -263,7 +263,7 @@ Collection createCollection(K key) { */ @CanIgnoreReturnValue @Override - public Set replaceValues(@NullableDecl K key, Iterable values) { + public Set replaceValues(@Nullable K key, Iterable values) { return super.replaceValues(key, values); } @@ -368,7 +368,7 @@ public void setSuccessorInValueSet(ValueSetLink entry) { public Iterator iterator() { return new Iterator() { ValueSetLink nextEntry = firstEntry; - @NullableDecl ValueEntry toRemove; + @Nullable ValueEntry toRemove; int expectedModCount = modCount; private void checkForComodification() { @@ -422,7 +422,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { int smearedHash = Hashing.smearedHash(o); for (ValueEntry entry = hashTable[smearedHash & mask()]; entry != null; @@ -435,7 +435,7 @@ public boolean contains(@NullableDecl Object o) { } @Override - public boolean add(@NullableDecl V value) { + public boolean add(@Nullable V value) { int smearedHash = Hashing.smearedHash(value); int bucket = smearedHash & mask(); ValueEntry rowHead = hashTable[bucket]; @@ -476,7 +476,7 @@ private void rehashIfNecessary() { @CanIgnoreReturnValue @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { int smearedHash = Hashing.smearedHash(o); int bucket = smearedHash & mask(); ValueEntry prev = null; @@ -519,7 +519,7 @@ public void clear() { Iterator> entryIterator() { return new Iterator>() { ValueEntry nextEntry = multimapHeaderEntry.successorInMultimap; - @NullableDecl ValueEntry toRemove; + @Nullable ValueEntry toRemove; @Override public boolean hasNext() { diff --git a/guava/src/com/google/common/collect/LinkedListMultimap.java b/guava/src/com/google/common/collect/LinkedListMultimap.java index 5d6e094739d9..18489fc5d93d 100644 --- a/guava/src/com/google/common/collect/LinkedListMultimap.java +++ b/guava/src/com/google/common/collect/LinkedListMultimap.java @@ -41,7 +41,7 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@code ListMultimap} that supports deterministic iteration order for both @@ -106,14 +106,14 @@ public class LinkedListMultimap extends AbstractMultimap */ private static final class Node extends AbstractMapEntry { - @NullableDecl final K key; - @NullableDecl V value; - @NullableDecl Node next; // the next node (with any key) - @NullableDecl Node previous; // the previous node (with any key) - @NullableDecl Node nextSibling; // the next node with the same key - @NullableDecl Node previousSibling; // the previous node with the same key - - Node(@NullableDecl K key, @NullableDecl V value) { + @Nullable final K key; + @Nullable V value; + @Nullable Node next; // the next node (with any key) + @Nullable Node previous; // the previous node (with any key) + @Nullable Node nextSibling; // the next node with the same key + @Nullable Node previousSibling; // the previous node with the same key + + Node(@Nullable K key, @Nullable V value) { this.key = key; this.value = value; } @@ -129,7 +129,7 @@ public V getValue() { } @Override - public V setValue(@NullableDecl V newValue) { + public V setValue(@Nullable V newValue) { V result = value; this.value = newValue; return result; @@ -150,8 +150,8 @@ private static class KeyList { } } - @NullableDecl private transient Node head; // the head for all keys - @NullableDecl private transient Node tail; // the tail for all keys + @Nullable private transient Node head; // the head for all keys + @Nullable private transient Node tail; // the tail for all keys private transient Map> keyToKeyList; private transient int size; @@ -209,8 +209,7 @@ private LinkedListMultimap(Multimap multimap) { * is specified, it MUST be for an node for the same {@code key}! */ @CanIgnoreReturnValue - private Node addNode( - @NullableDecl K key, @NullableDecl V value, @NullableDecl Node nextSibling) { + private Node addNode(@Nullable K key, @Nullable V value, @Nullable Node nextSibling) { Node node = new Node<>(key, value); if (head == null) { // empty list head = tail = node; @@ -294,12 +293,12 @@ private void removeNode(Node node) { } /** Removes all nodes for the specified key. */ - private void removeAllNodes(@NullableDecl Object key) { + private void removeAllNodes(@Nullable Object key) { Iterators.clear(new ValueForKeyIterator(key)); } /** Helper method for verifying that an iterator element is present. */ - private static void checkElement(@NullableDecl Object node) { + private static void checkElement(@Nullable Object node) { if (node == null) { throw new NoSuchElementException(); } @@ -308,9 +307,9 @@ private static void checkElement(@NullableDecl Object node) { /** An {@code Iterator} over all nodes. */ private class NodeIterator implements ListIterator> { int nextIndex; - @NullableDecl Node next; - @NullableDecl Node current; - @NullableDecl Node previous; + @Nullable Node next; + @Nullable Node current; + @Nullable Node previous; int expectedModCount = modCount; NodeIterator(int index) { @@ -416,7 +415,7 @@ void setValue(V value) { private class DistinctKeyIterator implements Iterator { final Set seenKeys = Sets.newHashSetWithExpectedSize(keySet().size()); Node next = head; - @NullableDecl Node current; + @Nullable Node current; int expectedModCount = modCount; private void checkForConcurrentModification() { @@ -455,14 +454,14 @@ public void remove() { /** A {@code ListIterator} over values for a specified key. */ private class ValueForKeyIterator implements ListIterator { - @NullableDecl final Object key; + @Nullable final Object key; int nextIndex; - @NullableDecl Node next; - @NullableDecl Node current; - @NullableDecl Node previous; + @Nullable Node next; + @Nullable Node current; + @Nullable Node previous; /** Constructs a new iterator over all values for the specified key. */ - ValueForKeyIterator(@NullableDecl Object key) { + ValueForKeyIterator(@Nullable Object key) { this.key = key; KeyList keyList = keyToKeyList.get(key); next = (keyList == null) ? null : keyList.head; @@ -476,7 +475,7 @@ private class ValueForKeyIterator implements ListIterator { * * @throws IndexOutOfBoundsException if index is invalid */ - public ValueForKeyIterator(@NullableDecl Object key, int index) { + public ValueForKeyIterator(@Nullable Object key, int index) { KeyList keyList = keyToKeyList.get(key); int size = (keyList == null) ? 0 : keyList.count; checkPositionIndex(index, size); @@ -577,12 +576,12 @@ public boolean isEmpty() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return keyToKeyList.containsKey(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return values().contains(value); } @@ -597,7 +596,7 @@ public boolean containsValue(@NullableDecl Object value) { */ @CanIgnoreReturnValue @Override - public boolean put(@NullableDecl K key, @NullableDecl V value) { + public boolean put(@Nullable K key, @Nullable V value) { addNode(key, value, null); return true; } @@ -614,7 +613,7 @@ public boolean put(@NullableDecl K key, @NullableDecl V value) { */ @CanIgnoreReturnValue @Override - public List replaceValues(@NullableDecl K key, Iterable values) { + public List replaceValues(@Nullable K key, Iterable values) { List oldValues = getCopy(key); ListIterator keyValues = new ValueForKeyIterator(key); Iterator newValues = values.iterator(); @@ -639,7 +638,7 @@ public List replaceValues(@NullableDecl K key, Iterable values) return oldValues; } - private List getCopy(@NullableDecl Object key) { + private List getCopy(@Nullable Object key) { return unmodifiableList(Lists.newArrayList(new ValueForKeyIterator(key))); } @@ -650,7 +649,7 @@ private List getCopy(@NullableDecl Object key) { */ @CanIgnoreReturnValue @Override - public List removeAll(@NullableDecl Object key) { + public List removeAll(@Nullable Object key) { List oldValues = getCopy(key); removeAllNodes(key); return oldValues; @@ -677,7 +676,7 @@ public void clear() { *

    The returned list is not serializable and does not have random access. */ @Override - public List get(final @NullableDecl K key) { + public List get(final @Nullable K key) { return new AbstractSequentialList() { @Override public int size() { diff --git a/guava/src/com/google/common/collect/ListMultimap.java b/guava/src/com/google/common/collect/ListMultimap.java index 46c18ac38614..967c9a0c403c 100644 --- a/guava/src/com/google/common/collect/ListMultimap.java +++ b/guava/src/com/google/common/collect/ListMultimap.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@code Multimap} that can hold duplicate key-value pairs and that maintains the insertion @@ -49,7 +49,7 @@ public interface ListMultimap extends Multimap { * the {@link Multimap} interface. */ @Override - List get(@NullableDecl K key); + List get(@Nullable K key); /** * {@inheritDoc} @@ -60,7 +60,7 @@ public interface ListMultimap extends Multimap { */ @CanIgnoreReturnValue @Override - List removeAll(@NullableDecl Object key); + List removeAll(@Nullable Object key); /** * {@inheritDoc} @@ -93,5 +93,5 @@ public interface ListMultimap extends Multimap { * empty {@code SetMultimap}. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); } diff --git a/guava/src/com/google/common/collect/Lists.java b/guava/src/com/google/common/collect/Lists.java index 12a7d2e7a8ad..a5256a6ddbe4 100644 --- a/guava/src/com/google/common/collect/Lists.java +++ b/guava/src/com/google/common/collect/Lists.java @@ -50,7 +50,7 @@ import java.util.RandomAccess; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Predicate; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@link List} instances. Also see this class's counterparts @@ -287,7 +287,7 @@ public static CopyOnWriteArrayList newCopyOnWriteArrayList( * @param rest an array of additional elements, possibly empty * @return an unmodifiable list containing the specified elements */ - public static List asList(@NullableDecl E first, E[] rest) { + public static List asList(@Nullable E first, E[] rest) { return new OnePlusArrayList<>(first, rest); } @@ -307,17 +307,17 @@ public static List asList(@NullableDecl E first, E[] rest) { * @param rest an array of additional elements, possibly empty * @return an unmodifiable list containing the specified elements */ - public static List asList(@NullableDecl E first, @NullableDecl E second, E[] rest) { + public static List asList(@Nullable E first, @Nullable E second, E[] rest) { return new TwoPlusArrayList<>(first, second, rest); } /** @see Lists#asList(Object, Object[]) */ private static class OnePlusArrayList extends AbstractList implements Serializable, RandomAccess { - @NullableDecl final E first; + @Nullable final E first; final E[] rest; - OnePlusArrayList(@NullableDecl E first, E[] rest) { + OnePlusArrayList(@Nullable E first, E[] rest) { this.first = first; this.rest = checkNotNull(rest); } @@ -340,11 +340,11 @@ public E get(int index) { /** @see Lists#asList(Object, Object, Object[]) */ private static class TwoPlusArrayList extends AbstractList implements Serializable, RandomAccess { - @NullableDecl final E first; - @NullableDecl final E second; + @Nullable final E first; + @Nullable final E second; final E[] rest; - TwoPlusArrayList(@NullableDecl E first, @NullableDecl E second, E[] rest) { + TwoPlusArrayList(@Nullable E first, @Nullable E second, E[] rest) { this.first = first; this.second = second; this.rest = checkNotNull(rest); @@ -732,12 +732,12 @@ private static final class StringAsImmutableList extends ImmutableList list) { } /** An implementation of {@link List#equals(Object)}. */ - static boolean equalsImpl(List thisList, @NullableDecl Object other) { + static boolean equalsImpl(List thisList, @Nullable Object other) { if (other == checkNotNull(thisList)) { return true; } @@ -1001,7 +1001,7 @@ static boolean addAllImpl(List list, int index, Iterable ele } /** An implementation of {@link List#indexOf(Object)}. */ - static int indexOfImpl(List list, @NullableDecl Object element) { + static int indexOfImpl(List list, @Nullable Object element) { if (list instanceof RandomAccess) { return indexOfRandomAccess(list, element); } else { @@ -1015,7 +1015,7 @@ static int indexOfImpl(List list, @NullableDecl Object element) { } } - private static int indexOfRandomAccess(List list, @NullableDecl Object element) { + private static int indexOfRandomAccess(List list, @Nullable Object element) { int size = list.size(); if (element == null) { for (int i = 0; i < size; i++) { @@ -1034,7 +1034,7 @@ private static int indexOfRandomAccess(List list, @NullableDecl Object elemen } /** An implementation of {@link List#lastIndexOf(Object)}. */ - static int lastIndexOfImpl(List list, @NullableDecl Object element) { + static int lastIndexOfImpl(List list, @Nullable Object element) { if (list instanceof RandomAccess) { return lastIndexOfRandomAccess(list, element); } else { @@ -1048,7 +1048,7 @@ static int lastIndexOfImpl(List list, @NullableDecl Object element) { } } - private static int lastIndexOfRandomAccess(List list, @NullableDecl Object element) { + private static int lastIndexOfRandomAccess(List list, @Nullable Object element) { if (element == null) { for (int i = list.size() - 1; i >= 0; i--) { if (list.get(i) == null) { diff --git a/guava/src/com/google/common/collect/MapDifference.java b/guava/src/com/google/common/collect/MapDifference.java index eda9cc9a7dc8..760473f5e507 100644 --- a/guava/src/com/google/common/collect/MapDifference.java +++ b/guava/src/com/google/common/collect/MapDifference.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An object representing the differences between two maps. @@ -65,7 +65,7 @@ public interface MapDifference { * #entriesDiffering()} of the two instances are equal. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); /** * Returns the hash code for this instance. This is defined as the hash code of @@ -96,7 +96,7 @@ interface ValueDifference { * {@link #rightValue()} values are also equal. */ @Override - boolean equals(@NullableDecl Object other); + boolean equals(@Nullable Object other); /** * The hash code equals the value {@code Arrays.asList(leftValue(), rightValue()).hashCode()}. diff --git a/guava/src/com/google/common/collect/MapMakerInternalMap.java b/guava/src/com/google/common/collect/MapMakerInternalMap.java index e43505185b61..54ead3944277 100644 --- a/guava/src/com/google/common/collect/MapMakerInternalMap.java +++ b/guava/src/com/google/common/collect/MapMakerInternalMap.java @@ -48,7 +48,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.locks.ReentrantLock; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * The concurrent hash map implementation built by {@link MapMaker}. @@ -292,13 +292,13 @@ interface InternalEntryHelper< /** * Returns a freshly created entry, typed at the {@code E} type, for the given {@code segment}. */ - E newEntry(S segment, K key, int hash, @NullableDecl E next); + E newEntry(S segment, K key, int hash, @Nullable E next); /** * Returns a freshly created entry, typed at the {@code E} type, for the given {@code segment}, * that is a copy of the given {@code entry}. */ - E copy(S segment, E entry, @NullableDecl E newNext); + E copy(S segment, E entry, @Nullable E newNext); /** * Sets the value of the given {@code entry} in the given {@code segment} to be the given {@code @@ -340,9 +340,9 @@ abstract static class AbstractStrongKeyEntry { final K key; final int hash; - @NullableDecl final E next; + @Nullable final E next; - AbstractStrongKeyEntry(K key, int hash, @NullableDecl E next) { + AbstractStrongKeyEntry(K key, int hash, @Nullable E next) { this.key = key; this.hash = hash; this.next = next; @@ -390,14 +390,14 @@ WeakValueReference unsetWeakValueReference() { static final class StrongKeyStrongValueEntry extends AbstractStrongKeyEntry> implements StrongValueEntry> { - @NullableDecl private volatile V value = null; + @Nullable private volatile V value = null; - StrongKeyStrongValueEntry(K key, int hash, @NullableDecl StrongKeyStrongValueEntry next) { + StrongKeyStrongValueEntry(K key, int hash, @Nullable StrongKeyStrongValueEntry next) { super(key, hash, next); } @Override - @NullableDecl + @Nullable public V getValue() { return value; } @@ -448,7 +448,7 @@ public StrongKeyStrongValueSegment newSegment( public StrongKeyStrongValueEntry copy( StrongKeyStrongValueSegment segment, StrongKeyStrongValueEntry entry, - @NullableDecl StrongKeyStrongValueEntry newNext) { + @Nullable StrongKeyStrongValueEntry newNext) { return entry.copy(newNext); } @@ -465,7 +465,7 @@ public StrongKeyStrongValueEntry newEntry( StrongKeyStrongValueSegment segment, K key, int hash, - @NullableDecl StrongKeyStrongValueEntry next) { + @Nullable StrongKeyStrongValueEntry next) { return new StrongKeyStrongValueEntry<>(key, hash, next); } } @@ -478,7 +478,7 @@ static final class StrongKeyWeakValueEntry private volatile WeakValueReference> valueReference = unsetWeakValueReference(); - StrongKeyWeakValueEntry(K key, int hash, @NullableDecl StrongKeyWeakValueEntry next) { + StrongKeyWeakValueEntry(K key, int hash, @Nullable StrongKeyWeakValueEntry next) { super(key, hash, next); } @@ -544,7 +544,7 @@ public StrongKeyWeakValueSegment newSegment( public StrongKeyWeakValueEntry copy( StrongKeyWeakValueSegment segment, StrongKeyWeakValueEntry entry, - @NullableDecl StrongKeyWeakValueEntry newNext) { + @Nullable StrongKeyWeakValueEntry newNext) { if (Segment.isCollected(entry)) { return null; } @@ -562,7 +562,7 @@ public StrongKeyWeakValueEntry newEntry( StrongKeyWeakValueSegment segment, K key, int hash, - @NullableDecl StrongKeyWeakValueEntry next) { + @Nullable StrongKeyWeakValueEntry next) { return new StrongKeyWeakValueEntry<>(key, hash, next); } } @@ -572,7 +572,7 @@ public StrongKeyWeakValueEntry newEntry( static final class StrongKeyDummyValueEntry extends AbstractStrongKeyEntry> implements StrongValueEntry> { - StrongKeyDummyValueEntry(K key, int hash, @NullableDecl StrongKeyDummyValueEntry next) { + StrongKeyDummyValueEntry(K key, int hash, @Nullable StrongKeyDummyValueEntry next) { super(key, hash, next); } @@ -624,7 +624,7 @@ public StrongKeyDummyValueSegment newSegment( public StrongKeyDummyValueEntry copy( StrongKeyDummyValueSegment segment, StrongKeyDummyValueEntry entry, - @NullableDecl StrongKeyDummyValueEntry newNext) { + @Nullable StrongKeyDummyValueEntry newNext) { return entry.copy(newNext); } @@ -637,7 +637,7 @@ public StrongKeyDummyValueEntry newEntry( StrongKeyDummyValueSegment segment, K key, int hash, - @NullableDecl StrongKeyDummyValueEntry next) { + @Nullable StrongKeyDummyValueEntry next) { return new StrongKeyDummyValueEntry(key, hash, next); } } @@ -647,9 +647,9 @@ public StrongKeyDummyValueEntry newEntry( abstract static class AbstractWeakKeyEntry> extends WeakReference implements InternalEntry { final int hash; - @NullableDecl final E next; + @Nullable final E next; - AbstractWeakKeyEntry(ReferenceQueue queue, K key, int hash, @NullableDecl E next) { + AbstractWeakKeyEntry(ReferenceQueue queue, K key, int hash, @Nullable E next) { super(key, queue); this.hash = hash; this.next = next; @@ -676,7 +676,7 @@ static final class WeakKeyDummyValueEntry extends AbstractWeakKeyEntry> implements StrongValueEntry> { WeakKeyDummyValueEntry( - ReferenceQueue queue, K key, int hash, @NullableDecl WeakKeyDummyValueEntry next) { + ReferenceQueue queue, K key, int hash, @Nullable WeakKeyDummyValueEntry next) { super(queue, key, hash, next); } @@ -728,7 +728,7 @@ public WeakKeyDummyValueSegment newSegment( public WeakKeyDummyValueEntry copy( WeakKeyDummyValueSegment segment, WeakKeyDummyValueEntry entry, - @NullableDecl WeakKeyDummyValueEntry newNext) { + @Nullable WeakKeyDummyValueEntry newNext) { if (entry.getKey() == null) { // key collected return null; @@ -745,7 +745,7 @@ public WeakKeyDummyValueEntry newEntry( WeakKeyDummyValueSegment segment, K key, int hash, - @NullableDecl WeakKeyDummyValueEntry next) { + @Nullable WeakKeyDummyValueEntry next) { return new WeakKeyDummyValueEntry(segment.queueForKeys, key, hash, next); } } @@ -755,18 +755,15 @@ public WeakKeyDummyValueEntry newEntry( static final class WeakKeyStrongValueEntry extends AbstractWeakKeyEntry> implements StrongValueEntry> { - @NullableDecl private volatile V value = null; + @Nullable private volatile V value = null; WeakKeyStrongValueEntry( - ReferenceQueue queue, - K key, - int hash, - @NullableDecl WeakKeyStrongValueEntry next) { + ReferenceQueue queue, K key, int hash, @Nullable WeakKeyStrongValueEntry next) { super(queue, key, hash, next); } @Override - @NullableDecl + @Nullable public V getValue() { return value; } @@ -817,7 +814,7 @@ public WeakKeyStrongValueSegment newSegment( public WeakKeyStrongValueEntry copy( WeakKeyStrongValueSegment segment, WeakKeyStrongValueEntry entry, - @NullableDecl WeakKeyStrongValueEntry newNext) { + @Nullable WeakKeyStrongValueEntry newNext) { if (entry.getKey() == null) { // key collected return null; @@ -836,7 +833,7 @@ public WeakKeyStrongValueEntry newEntry( WeakKeyStrongValueSegment segment, K key, int hash, - @NullableDecl WeakKeyStrongValueEntry next) { + @Nullable WeakKeyStrongValueEntry next) { return new WeakKeyStrongValueEntry<>(segment.queueForKeys, key, hash, next); } } @@ -850,7 +847,7 @@ static final class WeakKeyWeakValueEntry unsetWeakValueReference(); WeakKeyWeakValueEntry( - ReferenceQueue queue, K key, int hash, @NullableDecl WeakKeyWeakValueEntry next) { + ReferenceQueue queue, K key, int hash, @Nullable WeakKeyWeakValueEntry next) { super(queue, key, hash, next); } @@ -918,7 +915,7 @@ public WeakKeyWeakValueSegment newSegment( public WeakKeyWeakValueEntry copy( WeakKeyWeakValueSegment segment, WeakKeyWeakValueEntry entry, - @NullableDecl WeakKeyWeakValueEntry newNext) { + @Nullable WeakKeyWeakValueEntry newNext) { if (entry.getKey() == null) { // key collected return null; @@ -940,7 +937,7 @@ public WeakKeyWeakValueEntry newEntry( WeakKeyWeakValueSegment segment, K key, int hash, - @NullableDecl WeakKeyWeakValueEntry next) { + @Nullable WeakKeyWeakValueEntry next) { return new WeakKeyWeakValueEntry<>(segment.queueForKeys, key, hash, next); } } @@ -952,7 +949,7 @@ interface WeakValueReference> { * Returns the current value being referenced, or {@code null} if there is none (e.g. because * either it got collected, or {@link #clear} was called, or it wasn't set in the first place). */ - @NullableDecl + @Nullable V get(); /** Returns the entry which contains this {@link WeakValueReference}. */ @@ -1306,7 +1303,7 @@ void setTableEntryForTesting(int i, InternalEntry entry) { } /** Unsafely returns a copy of the given entry. */ - E copyForTesting(InternalEntry entry, @NullableDecl InternalEntry newNext) { + E copyForTesting(InternalEntry entry, @Nullable InternalEntry newNext) { return this.map.entryHelper.copy(self(), castForTesting(entry), castForTesting(newNext)); } @@ -1316,7 +1313,7 @@ void setValueForTesting(InternalEntry entry, V value) { } /** Unsafely returns a fresh entry. */ - E newEntryForTesting(K key, int hash, @NullableDecl InternalEntry next) { + E newEntryForTesting(K key, int hash, @Nullable InternalEntry next) { return this.map.entryHelper.newEntry(self(), key, hash, castForTesting(next)); } @@ -1334,7 +1331,7 @@ E removeFromChainForTesting(InternalEntry first, InternalEntry /** * Unsafely returns the value of the given entry if it's still live, or {@code null} otherwise. */ - @NullableDecl + @Nullable V getLiveValueForTesting(InternalEntry entry) { return getLiveValue(castForTesting(entry)); } @@ -1949,7 +1946,7 @@ static > boolean isCollected(E entry) { * Gets the value from an entry. Returns {@code null} if the entry is invalid or * partially-collected. */ - @NullableDecl + @Nullable V getLiveValue(E entry) { if (entry.getKey() == null) { tryDrainReferenceQueues(); @@ -2342,7 +2339,7 @@ public int size() { } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { if (key == null) { return null; } @@ -2354,7 +2351,7 @@ public V get(@NullableDecl Object key) { * Returns the internal entry for the specified key. The entry may be computing or partially * collected. Does not impact recency ordering. */ - E getEntry(@NullableDecl Object key) { + E getEntry(@Nullable Object key) { if (key == null) { return null; } @@ -2363,7 +2360,7 @@ E getEntry(@NullableDecl Object key) { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { if (key == null) { return false; } @@ -2372,7 +2369,7 @@ public boolean containsKey(@NullableDecl Object key) { } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { if (value == null) { return false; } @@ -2436,7 +2433,7 @@ public void putAll(Map m) { @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { if (key == null) { return null; } @@ -2446,7 +2443,7 @@ public V remove(@NullableDecl Object key) { @CanIgnoreReturnValue @Override - public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { + public boolean remove(@Nullable Object key, @Nullable Object value) { if (key == null || value == null) { return false; } @@ -2456,7 +2453,7 @@ public boolean remove(@NullableDecl Object key, @NullableDecl Object value) { @CanIgnoreReturnValue @Override - public boolean replace(K key, @NullableDecl V oldValue, V newValue) { + public boolean replace(K key, @Nullable V oldValue, V newValue) { checkNotNull(key); checkNotNull(newValue); if (oldValue == null) { @@ -2514,9 +2511,9 @@ abstract class HashIterator implements Iterator { int nextTableIndex; @MonotonicNonNullDecl Segment currentSegment; @MonotonicNonNullDecl AtomicReferenceArray currentTable; - @NullableDecl E nextEntry; - @NullableDecl WriteThroughEntry nextExternal; - @NullableDecl WriteThroughEntry lastReturned; + @Nullable E nextEntry; + @Nullable WriteThroughEntry nextExternal; + @Nullable WriteThroughEntry lastReturned; HashIterator() { nextSegmentIndex = segments.length - 1; @@ -2656,7 +2653,7 @@ public V getValue() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { // Cannot use key and value equivalence if (object instanceof Entry) { Entry that = (Entry) object; diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java index 3d2694398fb2..2c36408b3eb1 100644 --- a/guava/src/com/google/common/collect/Maps.java +++ b/guava/src/com/google/common/collect/Maps.java @@ -69,7 +69,7 @@ import java.util.function.Consumer; import java.util.stream.Collector; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@link Map} instances (including instances of {@link @@ -92,14 +92,14 @@ private Maps() {} private enum EntryFunction implements Function, Object> { KEY { @Override - @NullableDecl + @Nullable public Object apply(Entry entry) { return entry.getKey(); } }, VALUE { @Override - @NullableDecl + @Nullable public Object apply(Entry entry) { return entry.getValue(); } @@ -447,8 +447,7 @@ public static TreeMap newTreeMap(SortedMap map) { * @param comparator the comparator to sort the keys with * @return a new, empty {@code TreeMap} */ - public static TreeMap newTreeMap( - @NullableDecl Comparator comparator) { + public static TreeMap newTreeMap(@Nullable Comparator comparator) { // Ideally, the extra type parameter "C" shouldn't be necessary. It is a // work-around of a compiler type inference quirk that prevents the // following code from being compiled: @@ -696,14 +695,14 @@ public String toString() { } static class ValueDifferenceImpl implements MapDifference.ValueDifference { - @NullableDecl private final V left; - @NullableDecl private final V right; + @Nullable private final V left; + @Nullable private final V right; - static ValueDifference create(@NullableDecl V left, @NullableDecl V right) { + static ValueDifference create(@Nullable V left, @Nullable V right) { return new ValueDifferenceImpl(left, right); } - private ValueDifferenceImpl(@NullableDecl V left, @NullableDecl V right) { + private ValueDifferenceImpl(@Nullable V left, @Nullable V right) { this.left = left; this.right = right; } @@ -719,7 +718,7 @@ public V rightValue() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof MapDifference.ValueDifference) { MapDifference.ValueDifference that = (MapDifference.ValueDifference) object; return Objects.equal(this.left, that.leftValue()) @@ -776,7 +775,7 @@ public SortedMap entriesOnlyOnRight() { * ugly type-casting in one place. */ @SuppressWarnings("unchecked") - static Comparator orNaturalOrder(@NullableDecl Comparator comparator) { + static Comparator orNaturalOrder(@Nullable Comparator comparator) { if (comparator != null) { // can't use ? : because of javac bug 5080917 return comparator; } @@ -897,17 +896,17 @@ public int size() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return backingSet().contains(key); } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return getOrDefault(key, null); } @Override - public V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) { + public V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { if (Collections2.safeContains(backingSet(), key)) { @SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it K k = (K) key; @@ -918,7 +917,7 @@ public V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) { } @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { if (backingSet().remove(key)) { @SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it K k = (K) key; @@ -1052,14 +1051,14 @@ public Comparator comparator() { } @Override - @NullableDecl - public V get(@NullableDecl Object key) { + @Nullable + public V get(@Nullable Object key) { return getOrDefault(key, null); } @Override - @NullableDecl - public V getOrDefault(@NullableDecl Object key, @NullableDecl V defaultValue) { + @Nullable + public V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { if (Collections2.safeContains(set, key)) { @SuppressWarnings("unchecked") // unsafe, but Javadoc warns about it K k = (K) key; @@ -1380,7 +1379,7 @@ public static ImmutableMap fromProperties(Properties properties) * @param value the value to be associated with the returned entry */ @GwtCompatible(serializable = true) - public static Entry immutableEntry(@NullableDecl K key, @NullableDecl V value) { + public static Entry immutableEntry(@Nullable K key, @Nullable V value) { return new ImmutableEntry<>(key, value); } @@ -1476,7 +1475,7 @@ static class UnmodifiableEntrySet extends UnmodifiableEntries // See java.util.Collections.UnmodifiableEntrySet for details on attacks. @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return Sets.equalsImpl(this, object); } @@ -1525,7 +1524,7 @@ private static Y convert(BiMap bimap, X input) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof BiMapConverter) { BiMapConverter that = (BiMapConverter) object; return this.bimap.equals(that.bimap); @@ -1603,7 +1602,7 @@ private static class UnmodifiableBiMap extends ForwardingMap @MonotonicNonNullDecl @RetainedWith BiMap inverse; @MonotonicNonNullDecl transient Set values; - UnmodifiableBiMap(BiMap delegate, @NullableDecl BiMap inverse) { + UnmodifiableBiMap(BiMap delegate, @Nullable BiMap inverse) { unmodifiableMap = Collections.unmodifiableMap(delegate); this.delegate = delegate; this.inverse = inverse; @@ -1942,7 +1941,7 @@ public interface EntryTransformer { * @throws NullPointerException if the key or value is null and this transformer does not accept * null arguments */ - V2 transformEntry(@NullableDecl K key, @NullableDecl V1 value); + V2 transformEntry(@Nullable K key, @Nullable V1 value); } /** Views a function as an entry transformer that ignores the entry key. */ @@ -1962,7 +1961,7 @@ static Function asValueToValueFunction( checkNotNull(transformer); return new Function() { @Override - public V2 apply(@NullableDecl V1 v1) { + public V2 apply(@Nullable V1 v1) { return transformer.transformEntry(key, v1); } }; @@ -2031,16 +2030,16 @@ public boolean containsKey(Object key) { } @Override - @NullableDecl - public V2 get(@NullableDecl Object key) { + @Nullable + public V2 get(@Nullable Object key) { return getOrDefault(key, null); } // safe as long as the user followed the Warning in the javadoc @SuppressWarnings("unchecked") @Override - @NullableDecl - public V2 getOrDefault(@NullableDecl Object key, @NullableDecl V2 defaultValue) { + @Nullable + public V2 getOrDefault(@Nullable Object key, @Nullable V2 defaultValue) { V1 value = fromMap.get(key); return (value != null || fromMap.containsKey(key)) ? transformer.transformEntry((K) key, value) @@ -2250,8 +2249,8 @@ public NavigableMap tailMap(K fromKey, boolean inclusive) { return transformEntries(fromMap().tailMap(fromKey, inclusive), transformer); } - @NullableDecl - private Entry transformEntry(@NullableDecl Entry entry) { + @Nullable + private Entry transformEntry(@Nullable Entry entry) { return (entry == null) ? null : Maps.transformEntry(transformer, entry); } @@ -2709,7 +2708,7 @@ private abstract static class AbstractFilteredMap extends ViewCachingAbstr this.predicate = predicate; } - boolean apply(@NullableDecl Object key, @NullableDecl V value) { + boolean apply(@Nullable Object key, @Nullable V value) { // This method is called only when the key is in the map, implying that // key is a K. @SuppressWarnings("unchecked") @@ -3129,13 +3128,13 @@ public boolean isEmpty() { } @Override - @NullableDecl - public V get(@NullableDecl Object key) { + @Nullable + public V get(@Nullable Object key) { return filteredDelegate.get(key); } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return filteredDelegate.containsKey(key); } @@ -3145,7 +3144,7 @@ public V put(K key, V value) { } @Override - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { return filteredDelegate.remove(key); } @@ -3228,7 +3227,7 @@ BiMap unfiltered() { } @Override - public V forcePut(@NullableDecl K key, @NullableDecl V value) { + public V forcePut(@Nullable K key, @Nullable V value) { checkArgument(apply(key, value)); return unfiltered().forcePut(key, value); } @@ -3285,8 +3284,8 @@ public static NavigableMap unmodifiableNavigableMap( } } - @NullableDecl - private static Entry unmodifiableOrNull(@NullableDecl Entry entry) { + @Nullable + private static Entry unmodifiableOrNull(@Nullable Entry entry) { return (entry == null) ? null : Maps.unmodifiableEntry(entry); } @@ -3578,7 +3577,7 @@ public void clear() { * Delegates to {@link Map#get}. Returns {@code null} on {@code ClassCastException} and {@code * NullPointerException}. */ - static V safeGet(Map map, @NullableDecl Object key) { + static V safeGet(Map map, @Nullable Object key) { checkNotNull(map); try { return map.get(key); @@ -3614,12 +3613,12 @@ static V safeRemove(Map map, Object key) { } /** An admittedly inefficient implementation of {@link Map#containsKey}. */ - static boolean containsKeyImpl(Map map, @NullableDecl Object key) { + static boolean containsKeyImpl(Map map, @Nullable Object key) { return Iterators.contains(keyIterator(map.entrySet().iterator()), key); } /** An implementation of {@link Map#containsValue}. */ - static boolean containsValueImpl(Map map, @NullableDecl Object value) { + static boolean containsValueImpl(Map map, @Nullable Object value) { return Iterators.contains(valueIterator(map.entrySet().iterator()), value); } @@ -3745,13 +3744,13 @@ public void clear() { } } - @NullableDecl - static K keyOrNull(@NullableDecl Entry entry) { + @Nullable + static K keyOrNull(@Nullable Entry entry) { return (entry == null) ? null : entry.getKey(); } - @NullableDecl - static V valueOrNull(@NullableDecl Entry entry) { + @Nullable + static V valueOrNull(@Nullable Entry entry) { return (entry == null) ? null : entry.getValue(); } @@ -3958,7 +3957,7 @@ public boolean isEmpty() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { return map().containsValue(o); } diff --git a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java index 9d4e65ae9f34..fd871e9ce993 100644 --- a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java +++ b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java @@ -42,7 +42,7 @@ import java.util.PriorityQueue; import java.util.Queue; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A double-ended priority queue, which provides constant-time access to both its least element and @@ -754,7 +754,7 @@ private class QueueIterator implements Iterator { // either of them, up to the same multiplicity as the queue. @MonotonicNonNullDecl private Queue forgetMeNot; @MonotonicNonNullDecl private List skipMe; - @NullableDecl private E lastFromForgetMeNot; + @Nullable private E lastFromForgetMeNot; private boolean canRemove; @Override diff --git a/guava/src/com/google/common/collect/MoreCollectors.java b/guava/src/com/google/common/collect/MoreCollectors.java index 7eaa0b6633f9..3e6cdcad2d82 100644 --- a/guava/src/com/google/common/collect/MoreCollectors.java +++ b/guava/src/com/google/common/collect/MoreCollectors.java @@ -25,7 +25,7 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Collectors not present in {@code java.util.stream.Collectors} that are not otherwise associated @@ -91,8 +91,8 @@ public final class MoreCollectors { private static final class ToOptionalState { static final int MAX_EXTRAS = 4; - @NullableDecl Object element; - @NullableDecl List extras; + @Nullable Object element; + @Nullable List extras; ToOptionalState() { element = null; diff --git a/guava/src/com/google/common/collect/Multimap.java b/guava/src/com/google/common/collect/Multimap.java index f5bd5a993b3d..13256ba3c6db 100644 --- a/guava/src/com/google/common/collect/Multimap.java +++ b/guava/src/com/google/common/collect/Multimap.java @@ -27,7 +27,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.function.BiConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection that maps keys to values, similar to {@link Map}, but in which each key may be @@ -181,21 +181,20 @@ public interface Multimap { * Returns {@code true} if this multimap contains at least one key-value pair with the key {@code * key}. */ - boolean containsKey(@CompatibleWith("K") @NullableDecl Object key); + boolean containsKey(@CompatibleWith("K") @Nullable Object key); /** * Returns {@code true} if this multimap contains at least one key-value pair with the value * {@code value}. */ - boolean containsValue(@CompatibleWith("V") @NullableDecl Object value); + boolean containsValue(@CompatibleWith("V") @Nullable Object value); /** * Returns {@code true} if this multimap contains at least one key-value pair with the key {@code * key} and the value {@code value}. */ boolean containsEntry( - @CompatibleWith("K") @NullableDecl Object key, - @CompatibleWith("V") @NullableDecl Object value); + @CompatibleWith("K") @Nullable Object key, @CompatibleWith("V") @Nullable Object value); // Modification Operations @@ -210,7 +209,7 @@ boolean containsEntry( * multimap already contained the key-value pair and doesn't allow duplicates */ @CanIgnoreReturnValue - boolean put(@NullableDecl K key, @NullableDecl V value); + boolean put(@Nullable K key, @Nullable V value); /** * Removes a single key-value pair with the key {@code key} and the value {@code value} from this @@ -221,8 +220,7 @@ boolean containsEntry( */ @CanIgnoreReturnValue boolean remove( - @CompatibleWith("K") @NullableDecl Object key, - @CompatibleWith("V") @NullableDecl Object value); + @CompatibleWith("K") @Nullable Object key, @CompatibleWith("V") @Nullable Object value); // Bulk Operations @@ -241,7 +239,7 @@ boolean remove( * @return {@code true} if the multimap changed */ @CanIgnoreReturnValue - boolean putAll(@NullableDecl K key, Iterable values); + boolean putAll(@Nullable K key, Iterable values); /** * Stores all key-value pairs of {@code multimap} in this multimap, in the order returned by @@ -262,7 +260,7 @@ boolean remove( * no effect on the multimap. */ @CanIgnoreReturnValue - Collection replaceValues(@NullableDecl K key, Iterable values); + Collection replaceValues(@Nullable K key, Iterable values); /** * Removes all values associated with the key {@code key}. @@ -274,7 +272,7 @@ boolean remove( * modifiable, but updating it will have no effect on the multimap. */ @CanIgnoreReturnValue - Collection removeAll(@CompatibleWith("K") @NullableDecl Object key); + Collection removeAll(@CompatibleWith("K") @Nullable Object key); /** Removes all key-value pairs from the multimap, leaving it {@linkplain #isEmpty empty}. */ void clear(); @@ -288,7 +286,7 @@ boolean remove( * *

    Changes to the returned collection will update the underlying multimap, and vice versa. */ - Collection get(@NullableDecl K key); + Collection get(@Nullable K key); /** * Returns a view collection of all distinct keys contained in this multimap. Note that the @@ -370,7 +368,7 @@ default void forEach(BiConsumer action) { * multimaps are equal, because they both have empty {@link #asMap} views. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); /** * Returns the hash code for this multimap. diff --git a/guava/src/com/google/common/collect/Multimaps.java b/guava/src/com/google/common/collect/Multimaps.java index 6549a5d8b7bc..4650ef7406c2 100644 --- a/guava/src/com/google/common/collect/Multimaps.java +++ b/guava/src/com/google/common/collect/Multimaps.java @@ -53,7 +53,7 @@ import java.util.stream.Collector; import java.util.stream.Stream; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides static methods acting on or generating a {@code Multimap}. @@ -1737,7 +1737,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object element) { + public boolean contains(@Nullable Object element) { return multimap.containsKey(element); } @@ -1747,13 +1747,13 @@ public Iterator iterator() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { Collection values = Maps.safeGet(multimap.asMap(), element); return (values == null) ? 0 : values.size(); } @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { checkNonnegative(occurrences, "occurrences"); if (occurrences == 0) { return count(element); @@ -1804,7 +1804,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o instanceof Map.Entry) { Map.Entry entry = (Map.Entry) o; return multimap().containsEntry(entry.getKey(), entry.getValue()); @@ -1813,7 +1813,7 @@ public boolean contains(@NullableDecl Object o) { } @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { if (o instanceof Map.Entry) { Map.Entry entry = (Map.Entry) o; return multimap().remove(entry.getKey(), entry.getValue()); @@ -2194,7 +2194,7 @@ private static SetMultimap filterFiltered( return new FilteredEntrySetMultimap<>(multimap.unfiltered(), predicate); } - static boolean equalsImpl(Multimap multimap, @NullableDecl Object object) { + static boolean equalsImpl(Multimap multimap, @Nullable Object object) { if (object == multimap) { return true; } diff --git a/guava/src/com/google/common/collect/Multiset.java b/guava/src/com/google/common/collect/Multiset.java index a055ac93db68..7fe885b45a02 100644 --- a/guava/src/com/google/common/collect/Multiset.java +++ b/guava/src/com/google/common/collect/Multiset.java @@ -30,7 +30,7 @@ import java.util.Spliterator; import java.util.function.Consumer; import java.util.function.ObjIntConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection that supports order-independent equality, like {@link Set}, but may have duplicate @@ -107,7 +107,7 @@ public interface Multiset extends Collection { * @return the number of occurrences of the element in this multiset; possibly zero but never * negative */ - int count(@NullableDecl @CompatibleWith("E") Object element); + int count(@Nullable @CompatibleWith("E") Object element); // Bulk Operations @@ -130,7 +130,7 @@ public interface Multiset extends Collection { * return normally. */ @CanIgnoreReturnValue - int add(@NullableDecl E element, int occurrences); + int add(@Nullable E element, int occurrences); /** * Adds a single occurrence of the specified element to this multiset. @@ -168,7 +168,7 @@ public interface Multiset extends Collection { * @throws IllegalArgumentException if {@code occurrences} is negative */ @CanIgnoreReturnValue - int remove(@NullableDecl @CompatibleWith("E") Object element, int occurrences); + int remove(@Nullable @CompatibleWith("E") Object element, int occurrences); /** * Removes a single occurrence of the specified element from this multiset, if present. @@ -184,7 +184,7 @@ public interface Multiset extends Collection { */ @CanIgnoreReturnValue @Override - boolean remove(@NullableDecl Object element); + boolean remove(@Nullable Object element); /** * Adds or removes the necessary occurrences of an element such that the element attains the @@ -348,7 +348,7 @@ default void forEachEntry(ObjIntConsumer action) { */ @Override // TODO(kevinb): caveats about equivalence-relation? - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); /** * Returns the hash code for this multiset. This is defined as the sum of @@ -394,7 +394,7 @@ default void forEachEntry(ObjIntConsumer action) { * @return {@code true} if this multiset contains at least one occurrence of the element */ @Override - boolean contains(@NullableDecl Object element); + boolean contains(@Nullable Object element); /** * Returns {@code true} if this multiset contains at least one occurrence of each element in the diff --git a/guava/src/com/google/common/collect/Multisets.java b/guava/src/com/google/common/collect/Multisets.java index 9c5c9358109e..b04e9669f23f 100644 --- a/guava/src/com/google/common/collect/Multisets.java +++ b/guava/src/com/google/common/collect/Multisets.java @@ -41,7 +41,7 @@ import java.util.Spliterator; import java.util.stream.Collector; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides static utility methods for creating and working with {@link Multiset} instances. @@ -241,22 +241,22 @@ public static SortedMultiset unmodifiableSortedMultiset(SortedMultiset * @param n the count to be associated with the returned entry * @throws IllegalArgumentException if {@code n} is negative */ - public static Multiset.Entry immutableEntry(@NullableDecl E e, int n) { + public static Multiset.Entry immutableEntry(@Nullable E e, int n) { return new ImmutableEntry(e, n); } static class ImmutableEntry extends AbstractEntry implements Serializable { - @NullableDecl private final E element; + @Nullable private final E element; private final int count; - ImmutableEntry(@NullableDecl E element, int count) { + ImmutableEntry(@Nullable E element, int count) { this.element = element; this.count = count; checkNonnegative(count, "count"); } @Override - @NullableDecl + @Nullable public final E getElement() { return element; } @@ -352,7 +352,7 @@ Iterator> entryIterator() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { int count = unfiltered.count(element); if (count > 0) { @SuppressWarnings("unchecked") // element is equal to an E @@ -363,14 +363,14 @@ public int count(@NullableDecl Object element) { } @Override - public int add(@NullableDecl E element, int occurrences) { + public int add(@Nullable E element, int occurrences) { checkArgument( predicate.apply(element), "Element %s does not match predicate %s", element, predicate); return unfiltered.add(element, occurrences); } @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { checkNonnegative(occurrences, "occurrences"); if (occurrences == 0) { return count(element); @@ -412,7 +412,7 @@ public static Multiset union( return new ViewMultiset() { @Override - public boolean contains(@NullableDecl Object element) { + public boolean contains(@Nullable Object element) { return multiset1.contains(element) || multiset2.contains(element); } @@ -541,7 +541,7 @@ public static Multiset sum( // TODO(lowasser): consider making the entries live views return new ViewMultiset() { @Override - public boolean contains(@NullableDecl Object element) { + public boolean contains(@Nullable Object element) { return multiset1.contains(element) || multiset2.contains(element); } @@ -618,7 +618,7 @@ public static Multiset difference( // TODO(lowasser): consider making the entries live views return new ViewMultiset() { @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { int count1 = multiset1.count(element); return (count1 == 0) ? 0 : Math.max(0, count1 - multiset2.count(element)); } @@ -828,7 +828,7 @@ abstract static class AbstractEntry implements Multiset.Entry { * Multiset.Entry#equals}. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Multiset.Entry) { Multiset.Entry that = (Multiset.Entry) object; return this.getCount() == that.getCount() @@ -862,7 +862,7 @@ public String toString() { } /** An implementation of {@link Multiset#equals}. */ - static boolean equalsImpl(Multiset multiset, @NullableDecl Object object) { + static boolean equalsImpl(Multiset multiset, @Nullable Object object) { if (object == multiset) { return true; } @@ -1009,7 +1009,7 @@ abstract static class EntrySet extends Sets.ImprovedAbstractSet> { abstract Multiset multiset(); @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o instanceof Entry) { /* * The GWT compiler wrongly issues a warning here. diff --git a/guava/src/com/google/common/collect/NullsFirstOrdering.java b/guava/src/com/google/common/collect/NullsFirstOrdering.java index 21540360eb3b..5e1dfe9d06f6 100644 --- a/guava/src/com/google/common/collect/NullsFirstOrdering.java +++ b/guava/src/com/google/common/collect/NullsFirstOrdering.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering that treats {@code null} as less than all other values. */ @GwtCompatible(serializable = true) @@ -30,7 +30,7 @@ final class NullsFirstOrdering extends Ordering implements Serializable { } @Override - public int compare(@NullableDecl T left, @NullableDecl T right) { + public int compare(@Nullable T left, @Nullable T right) { if (left == right) { return 0; } @@ -61,7 +61,7 @@ public Ordering nullsLast() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/NullsLastOrdering.java b/guava/src/com/google/common/collect/NullsLastOrdering.java index 5dd8950c9f8a..a62e2197939d 100644 --- a/guava/src/com/google/common/collect/NullsLastOrdering.java +++ b/guava/src/com/google/common/collect/NullsLastOrdering.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering that treats {@code null} as greater than all other values. */ @GwtCompatible(serializable = true) @@ -30,7 +30,7 @@ final class NullsLastOrdering extends Ordering implements Serializable { } @Override - public int compare(@NullableDecl T left, @NullableDecl T right) { + public int compare(@Nullable T left, @Nullable T right) { if (left == right) { return 0; } @@ -61,7 +61,7 @@ public Ordering nullsLast() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/ObjectArrays.java b/guava/src/com/google/common/collect/ObjectArrays.java index e09fc69a3b85..cfc9a596c41d 100644 --- a/guava/src/com/google/common/collect/ObjectArrays.java +++ b/guava/src/com/google/common/collect/ObjectArrays.java @@ -24,7 +24,7 @@ import java.lang.reflect.Array; import java.util.Arrays; import java.util.Collection; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to object arrays. @@ -82,7 +82,7 @@ public static T[] concat(T[] first, T[] second, Class type) { * @return an array whose size is one larger than {@code array}, with {@code element} occupying * the first position, and the elements of {@code array} occupying the remaining elements. */ - public static T[] concat(@NullableDecl T element, T[] array) { + public static T[] concat(@Nullable T element, T[] array) { T[] result = newArray(array, array.length + 1); result[0] = element; System.arraycopy(array, 0, result, 1, array.length); @@ -97,7 +97,7 @@ public static T[] concat(@NullableDecl T element, T[] array) { * @return an array whose size is one larger than {@code array}, with the same contents as {@code * array}, plus {@code element} occupying the last position. */ - public static T[] concat(T[] array, @NullableDecl T element) { + public static T[] concat(T[] array, @Nullable T element) { T[] result = Arrays.copyOf(array, array.length + 1); result[array.length] = element; return result; diff --git a/guava/src/com/google/common/collect/Ordering.java b/guava/src/com/google/common/collect/Ordering.java index 2097bd81807e..775277ca8ce3 100644 --- a/guava/src/com/google/common/collect/Ordering.java +++ b/guava/src/com/google/common/collect/Ordering.java @@ -35,7 +35,7 @@ import java.util.SortedMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A comparator, with additional methods to support common operations. This is an "enriched" version @@ -524,10 +524,10 @@ public Ordering> lexicographical() { // Regular instance methods - // Override to add @NullableDecl + // Override to add @Nullable @CanIgnoreReturnValue // TODO(kak): Consider removing this @Override - public abstract int compare(@NullableDecl T left, @NullableDecl T right); + public abstract int compare(@Nullable T left, @Nullable T right); /** * Returns the least of the specified values according to this ordering. If there are multiple @@ -592,7 +592,7 @@ public E min(Iterable iterable) { * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this - public E min(@NullableDecl E a, @NullableDecl E b) { + public E min(@Nullable E a, @Nullable E b) { return (compare(a, b) <= 0) ? a : b; } @@ -611,7 +611,7 @@ public E min(@NullableDecl E a, @NullableDecl E b) { * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this - public E min(@NullableDecl E a, @NullableDecl E b, @NullableDecl E c, E... rest) { + public E min(@Nullable E a, @Nullable E b, @Nullable E c, E... rest) { E minSoFar = min(min(a, b), c); for (E r : rest) { @@ -684,7 +684,7 @@ public E max(Iterable iterable) { * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this - public E max(@NullableDecl E a, @NullableDecl E b) { + public E max(@Nullable E a, @Nullable E b) { return (compare(a, b) >= 0) ? a : b; } @@ -703,7 +703,7 @@ public E max(@NullableDecl E a, @NullableDecl E b) { * ordering. */ @CanIgnoreReturnValue // TODO(kak): Consider removing this - public E max(@NullableDecl E a, @NullableDecl E b, @NullableDecl E c, E... rest) { + public E max(@Nullable E a, @Nullable E b, @Nullable E c, E... rest) { E maxSoFar = max(max(a, b), c); for (E r : rest) { @@ -931,7 +931,7 @@ public boolean isStrictlyOrdered(Iterable iterable) { * @deprecated Use {@link Collections#binarySearch(List, Object, Comparator)} directly. */ @Deprecated - public int binarySearch(List sortedList, @NullableDecl T key) { + public int binarySearch(List sortedList, @Nullable T key) { return Collections.binarySearch(sortedList, key, this); } diff --git a/guava/src/com/google/common/collect/Range.java b/guava/src/com/google/common/collect/Range.java index d27b09e3d098..0c4be79b2406 100644 --- a/guava/src/com/google/common/collect/Range.java +++ b/guava/src/com/google/common/collect/Range.java @@ -27,7 +27,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A range (or "interval") defines the boundaries around a contiguous span of values of some @@ -617,7 +617,7 @@ public Range canonical(DiscreteDomain domain) { * {@code [3..3)}, {@code (3..3]}, {@code (4..4]} are all unequal. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Range) { Range other = (Range) object; return lowerBound.equals(other.lowerBound) && upperBound.equals(other.upperBound); diff --git a/guava/src/com/google/common/collect/RangeMap.java b/guava/src/com/google/common/collect/RangeMap.java index d1e5c31076be..13ec7f0d3ea5 100644 --- a/guava/src/com/google/common/collect/RangeMap.java +++ b/guava/src/com/google/common/collect/RangeMap.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A mapping from disjoint nonempty ranges to non-null values. Queries look up the value associated @@ -43,14 +43,14 @@ public interface RangeMap { *

    Specifically, if any range in this range map contains the specified key, the value * associated with that range is returned. */ - @NullableDecl + @Nullable V get(K key); /** * Returns the range containing this key and its associated value, if such a range is present in * the range map, or {@code null} otherwise. */ - @NullableDecl + @Nullable Entry, V> getEntry(K key); /** @@ -151,7 +151,7 @@ public interface RangeMap { * #asMapOfRanges()}. */ @Override - boolean equals(@NullableDecl Object o); + boolean equals(@Nullable Object o); /** Returns {@code asMapOfRanges().hashCode()}. */ @Override diff --git a/guava/src/com/google/common/collect/RangeSet.java b/guava/src/com/google/common/collect/RangeSet.java index 5b37c851fb61..dce3bd8cee4e 100644 --- a/guava/src/com/google/common/collect/RangeSet.java +++ b/guava/src/com/google/common/collect/RangeSet.java @@ -18,7 +18,7 @@ import com.google.common.annotations.GwtIncompatible; import java.util.NoSuchElementException; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A set comprising zero or more {@linkplain Range#isEmpty nonempty}, {@linkplain @@ -260,7 +260,7 @@ default void removeAll(Iterable> ranges) { * according to {@link Range#equals(Object)}. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); /** Returns {@code asRanges().hashCode()}. */ @Override diff --git a/guava/src/com/google/common/collect/RegularContiguousSet.java b/guava/src/com/google/common/collect/RegularContiguousSet.java index 8c989e25d7b7..a0b2501a58de 100644 --- a/guava/src/com/google/common/collect/RegularContiguousSet.java +++ b/guava/src/com/google/common/collect/RegularContiguousSet.java @@ -23,7 +23,7 @@ import com.google.common.annotations.GwtIncompatible; import java.io.Serializable; import java.util.Collection; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link ContiguousSet} that contains one or more elements. @@ -100,7 +100,7 @@ protected C computeNext(C previous) { }; } - private static boolean equalsOrThrow(Comparable left, @NullableDecl Comparable right) { + private static boolean equalsOrThrow(Comparable left, @Nullable Comparable right) { return right != null && Range.compareOrThrow(left, right) == 0; } @@ -146,7 +146,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { if (object == null) { return false; } @@ -195,7 +195,7 @@ public Range range(BoundType lowerBoundType, BoundType upperBoundType) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } else if (object instanceof RegularContiguousSet) { diff --git a/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/guava/src/com/google/common/collect/RegularImmutableBiMap.java index 5ffdf59c0db9..27c2bdb7a1e6 100644 --- a/guava/src/com/google/common/collect/RegularImmutableBiMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableBiMap.java @@ -32,7 +32,7 @@ import java.io.Serializable; import java.util.function.BiConsumer; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Bimap with zero or more mappings. @@ -125,7 +125,7 @@ private RegularImmutableBiMap( */ @CanIgnoreReturnValue private static int checkNoConflictInValueBucket( - Object value, Entry entry, @NullableDecl ImmutableMapEntry valueBucketHead) { + Object value, Entry entry, @Nullable ImmutableMapEntry valueBucketHead) { int bucketSize = 0; for (; valueBucketHead != null; valueBucketHead = valueBucketHead.getNextInValueBucket()) { checkNoConflict(!value.equals(valueBucketHead.getValue()), "value", entry, valueBucketHead); @@ -135,8 +135,8 @@ private static int checkNoConflictInValueBucket( } @Override - @NullableDecl - public V get(@NullableDecl Object key) { + @Nullable + public V get(@Nullable Object key) { return (keyTable == null) ? null : RegularImmutableMap.get(key, keyTable, mask); } @@ -210,7 +210,7 @@ public void forEach(BiConsumer action) { } @Override - public K get(@NullableDecl Object value) { + public K get(@Nullable Object value) { if (value == null || valueTable == null) { return null; } diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java index a75d7eaf764b..0c050c651ae5 100644 --- a/guava/src/com/google/common/collect/RegularImmutableMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableMap.java @@ -29,7 +29,7 @@ import com.google.j2objc.annotations.Weak; import java.io.Serializable; import java.util.function.BiConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link ImmutableMap} with two or more entries. @@ -99,7 +99,7 @@ static ImmutableMap fromEntryArray(int n, Entry[] entryArray) V value = entry.getValue(); checkEntryNotNull(key, value); int tableIndex = Hashing.smear(key.hashCode()) & mask; - @NullableDecl ImmutableMapEntry existing = table[tableIndex]; + @Nullable ImmutableMapEntry existing = table[tableIndex]; // prepend, not append, so the entries can be immutable ImmutableMapEntry newEntry = (existing == null) @@ -141,7 +141,7 @@ private RegularImmutableMap(Entry[] entries, ImmutableMapEntry[] tab */ @CanIgnoreReturnValue static int checkNoConflictInKeyBucket( - Object key, Entry entry, @NullableDecl ImmutableMapEntry keyBucketHead) { + Object key, Entry entry, @Nullable ImmutableMapEntry keyBucketHead) { int bucketSize = 0; for (; keyBucketHead != null; keyBucketHead = keyBucketHead.getNextInKeyBucket()) { checkNoConflict(!key.equals(keyBucketHead.getKey()), "key", entry, keyBucketHead); @@ -151,13 +151,12 @@ static int checkNoConflictInKeyBucket( } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return get(key, table, mask); } - @NullableDecl - static V get( - @NullableDecl Object key, @NullableDecl ImmutableMapEntry[] keyTable, int mask) { + @Nullable + static V get(@Nullable Object key, ImmutableMapEntry @Nullable [] keyTable, int mask) { if (key == null || keyTable == null) { return null; } diff --git a/guava/src/com/google/common/collect/RegularImmutableMultiset.java b/guava/src/com/google/common/collect/RegularImmutableMultiset.java index 54d84fbd0022..93843da61e06 100644 --- a/guava/src/com/google/common/collect/RegularImmutableMultiset.java +++ b/guava/src/com/google/common/collect/RegularImmutableMultiset.java @@ -24,7 +24,7 @@ import com.google.errorprone.annotations.concurrent.LazyInit; import java.util.Arrays; import java.util.Collection; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link ImmutableMultiset} with zero or more elements. @@ -116,7 +116,7 @@ private static boolean hashFloodingDetected(Multisets.ImmutableEntry[] hashTa @VisibleForTesting static final int MAX_HASH_BUCKET_LENGTH = 9; private final transient Multisets.ImmutableEntry[] entries; - @NullableDecl private final transient Multisets.ImmutableEntry[] hashTable; + private final transient Multisets.ImmutableEntry @Nullable [] hashTable; private final transient int size; private final transient int hashCode; @@ -155,7 +155,7 @@ boolean isPartialView() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { Multisets.ImmutableEntry[] hashTable = this.hashTable; if (element == null || hashTable == null) { return 0; diff --git a/guava/src/com/google/common/collect/RegularImmutableSet.java b/guava/src/com/google/common/collect/RegularImmutableSet.java index dfad6993b7e6..8fedbebb2c26 100644 --- a/guava/src/com/google/common/collect/RegularImmutableSet.java +++ b/guava/src/com/google/common/collect/RegularImmutableSet.java @@ -20,7 +20,7 @@ import com.google.common.annotations.VisibleForTesting; import java.util.Spliterator; import java.util.Spliterators; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link ImmutableSet} with two or more elements. @@ -48,7 +48,7 @@ final class RegularImmutableSet extends ImmutableSet { } @Override - public boolean contains(@NullableDecl Object target) { + public boolean contains(@Nullable Object target) { Object[] table = this.table; if (target == null || table == null) { return false; diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java b/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java index 8fce69a5bec0..3056d56f4f18 100644 --- a/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java +++ b/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java @@ -23,7 +23,7 @@ import com.google.common.primitives.Ints; import java.util.Comparator; import java.util.function.ObjIntConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable sorted multiset with one or more distinct elements. @@ -86,7 +86,7 @@ public Entry lastEntry() { } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { int index = elementSet.indexOf(element); return (index >= 0) ? getCount(index) : 0; } diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java index 1d5f01f29c4d..243df9bc17e4 100644 --- a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java @@ -28,7 +28,7 @@ import java.util.Set; import java.util.Spliterator; import java.util.function.Consumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable sorted set with one or more elements. TODO(jlevy): Consider separate class for a @@ -77,7 +77,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { try { return o != null && unsafeBinarySearch(o) >= 0; } catch (ClassCastException e) { @@ -152,7 +152,7 @@ int copyIntoArray(Object[] dst, int offset) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -282,7 +282,7 @@ RegularImmutableSortedSet getSubSet(int newFromIndex, int newToIndex) { } @Override - int indexOf(@NullableDecl Object target) { + int indexOf(@Nullable Object target) { if (target == null) { return -1; } diff --git a/guava/src/com/google/common/collect/RegularImmutableTable.java b/guava/src/com/google/common/collect/RegularImmutableTable.java index cb8981d78b82..935b74605d61 100644 --- a/guava/src/com/google/common/collect/RegularImmutableTable.java +++ b/guava/src/com/google/common/collect/RegularImmutableTable.java @@ -23,7 +23,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link ImmutableTable} holding an arbitrary number of cells. @@ -54,7 +54,7 @@ Cell get(int index) { } @Override - public boolean contains(@NullableDecl Object object) { + public boolean contains(@Nullable Object object) { if (object instanceof Cell) { Cell cell = (Cell) object; Object value = RegularImmutableTable.this.get(cell.getRowKey(), cell.getColumnKey()); @@ -96,8 +96,8 @@ boolean isPartialView() { static RegularImmutableTable forCells( List> cells, - @NullableDecl final Comparator rowComparator, - @NullableDecl final Comparator columnComparator) { + @Nullable final Comparator rowComparator, + @Nullable final Comparator columnComparator) { checkNotNull(cells); if (rowComparator != null || columnComparator != null) { /* @@ -134,8 +134,8 @@ static RegularImmutableTable forCells(Iterable> private static RegularImmutableTable forCellsInternal( Iterable> cells, - @NullableDecl Comparator rowComparator, - @NullableDecl Comparator columnComparator) { + @Nullable Comparator rowComparator, + @Nullable Comparator columnComparator) { Set rowSpaceBuilder = new LinkedHashSet<>(); Set columnSpaceBuilder = new LinkedHashSet<>(); ImmutableList> cellList = ImmutableList.copyOf(cells); diff --git a/guava/src/com/google/common/collect/ReverseOrdering.java b/guava/src/com/google/common/collect/ReverseOrdering.java index 9f65e5976034..ab9c3ac77864 100644 --- a/guava/src/com/google/common/collect/ReverseOrdering.java +++ b/guava/src/com/google/common/collect/ReverseOrdering.java @@ -21,7 +21,7 @@ import com.google.common.annotations.GwtCompatible; import java.io.Serializable; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** An ordering that uses the reverse of a given order. */ @GwtCompatible(serializable = true) @@ -91,7 +91,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/collect/SetMultimap.java b/guava/src/com/google/common/collect/SetMultimap.java index f2c6b57a2ad2..90e6e1b03144 100644 --- a/guava/src/com/google/common/collect/SetMultimap.java +++ b/guava/src/com/google/common/collect/SetMultimap.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@code Multimap} that cannot hold duplicate key-value pairs. Adding a key-value pair that's @@ -58,7 +58,7 @@ public interface SetMultimap extends Multimap { * interface. */ @Override - Set get(@NullableDecl K key); + Set get(@Nullable K key); /** * {@inheritDoc} @@ -69,7 +69,7 @@ public interface SetMultimap extends Multimap { */ @CanIgnoreReturnValue @Override - Set removeAll(@NullableDecl Object key); + Set removeAll(@Nullable Object key); /** * {@inheritDoc} @@ -114,5 +114,5 @@ public interface SetMultimap extends Multimap { * empty {@code ListMultimap}. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); } diff --git a/guava/src/com/google/common/collect/Sets.java b/guava/src/com/google/common/collect/Sets.java index 9d199ffeddd2..125ad5f7c0ff 100644 --- a/guava/src/com/google/common/collect/Sets.java +++ b/guava/src/com/google/common/collect/Sets.java @@ -52,7 +52,7 @@ import java.util.stream.Collector; import java.util.stream.Stream; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@link Set} instances. Also see this class's counterparts @@ -1141,7 +1141,7 @@ private static class FilteredSet extends FilteredCollection implements Set } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { return equalsImpl(this, object); } @@ -1208,13 +1208,13 @@ NavigableSet unfiltered() { } @Override - @NullableDecl + @Nullable public E lower(E e) { return Iterators.find(unfiltered().headSet(e, false).descendingIterator(), predicate, null); } @Override - @NullableDecl + @Nullable public E floor(E e) { return Iterators.find(unfiltered().headSet(e, true).descendingIterator(), predicate, null); } @@ -1431,7 +1431,7 @@ protected Collection> delegate() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { // Warning: this is broken if size() == 0, so it is critical that we // substitute an empty ImmutableSet to the user in place of this if (object instanceof CartesianSet) { @@ -1531,7 +1531,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { Integer index = inputSet.get(o); return index != null && (mask & (1 << index)) != 0; } @@ -1567,7 +1567,7 @@ protected Set get(final int setBits) { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (obj instanceof Set) { Set set = (Set) obj; return inputSet.keySet().containsAll(set); @@ -1576,7 +1576,7 @@ public boolean contains(@NullableDecl Object obj) { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof PowerSet) { PowerSet that = (PowerSet) obj; return inputSet.equals(that.inputSet); @@ -1636,7 +1636,7 @@ public static Set> combinations(Set set, final int size) { } return new AbstractSet>() { @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { if (o instanceof Set) { Set s = (Set) o; return s.size() == size && index.keySet().containsAll(s); @@ -1681,7 +1681,7 @@ protected Set computeNext() { final BitSet copy = (BitSet) bits.clone(); return new AbstractSet() { @Override - public boolean contains(@NullableDecl Object o) { + public boolean contains(@Nullable Object o) { Integer i = index.get(o); return i != null && copy.get(i); } @@ -1736,7 +1736,7 @@ static int hashCodeImpl(Set s) { } /** An implementation for {@link Set#equals(Object)}. */ - static boolean equalsImpl(Set s, @NullableDecl Object object) { + static boolean equalsImpl(Set s, @Nullable Object object) { if (s == object) { return true; } diff --git a/guava/src/com/google/common/collect/SingletonImmutableBiMap.java b/guava/src/com/google/common/collect/SingletonImmutableBiMap.java index f556464c333c..32376e07803b 100644 --- a/guava/src/com/google/common/collect/SingletonImmutableBiMap.java +++ b/guava/src/com/google/common/collect/SingletonImmutableBiMap.java @@ -23,7 +23,7 @@ import com.google.errorprone.annotations.concurrent.LazyInit; import com.google.j2objc.annotations.RetainedWith; import java.util.function.BiConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@link ImmutableMap} with exactly one entry. @@ -51,7 +51,7 @@ private SingletonImmutableBiMap(K singleKey, V singleValue, ImmutableBiMap } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { return singleKey.equals(key) ? singleValue : null; } @@ -66,12 +66,12 @@ public void forEach(BiConsumer action) { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return singleKey.equals(key); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return singleValue.equals(value); } diff --git a/guava/src/com/google/common/collect/SortedLists.java b/guava/src/com/google/common/collect/SortedLists.java index 67c5a3b8a2a8..339e7fce77a5 100644 --- a/guava/src/com/google/common/collect/SortedLists.java +++ b/guava/src/com/google/common/collect/SortedLists.java @@ -23,7 +23,7 @@ import java.util.Comparator; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static methods pertaining to sorted {@link List} instances. @@ -196,7 +196,7 @@ public static int binarySearch( public static int binarySearch( List list, Function keyFunction, - @NullableDecl K key, + @Nullable K key, KeyPresentBehavior presentBehavior, KeyAbsentBehavior absentBehavior) { return binarySearch( @@ -213,7 +213,7 @@ public static int binarySearch( public static int binarySearch( List list, Function keyFunction, - @NullableDecl K key, + @Nullable K key, Comparator keyComparator, KeyPresentBehavior presentBehavior, KeyAbsentBehavior absentBehavior) { @@ -246,7 +246,7 @@ public static int binarySearch( */ public static int binarySearch( List list, - @NullableDecl E key, + @Nullable E key, Comparator comparator, KeyPresentBehavior presentBehavior, KeyAbsentBehavior absentBehavior) { diff --git a/guava/src/com/google/common/collect/SortedMultisets.java b/guava/src/com/google/common/collect/SortedMultisets.java index 3c45c9f02e0f..a928959e9c30 100644 --- a/guava/src/com/google/common/collect/SortedMultisets.java +++ b/guava/src/com/google/common/collect/SortedMultisets.java @@ -28,7 +28,7 @@ import java.util.NavigableSet; import java.util.NoSuchElementException; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides static utility methods for creating and working with {@link SortedMultiset} instances. @@ -165,7 +165,7 @@ private static E getElementOrThrow(Entry entry) { return entry.getElement(); } - private static E getElementOrNull(@NullableDecl Entry entry) { + private static E getElementOrNull(@Nullable Entry entry) { return (entry == null) ? null : entry.getElement(); } } diff --git a/guava/src/com/google/common/collect/SortedSetMultimap.java b/guava/src/com/google/common/collect/SortedSetMultimap.java index ae7dd769b710..cefe6aad5d00 100644 --- a/guava/src/com/google/common/collect/SortedSetMultimap.java +++ b/guava/src/com/google/common/collect/SortedSetMultimap.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@code SetMultimap} whose set of values for a given key are kept sorted; that is, they comprise @@ -58,7 +58,7 @@ public interface SortedSetMultimap extends SetMultimap { * {@link Multimap} interface. */ @Override - SortedSet get(@NullableDecl K key); + SortedSet get(@Nullable K key); /** * Removes all values associated with a given key. @@ -69,7 +69,7 @@ public interface SortedSetMultimap extends SetMultimap { */ @CanIgnoreReturnValue @Override - SortedSet removeAll(@NullableDecl Object key); + SortedSet removeAll(@Nullable Object key); /** * Stores a collection of values with the same key, replacing any existing values for that key. diff --git a/guava/src/com/google/common/collect/StandardTable.java b/guava/src/com/google/common/collect/StandardTable.java index a814634f3d57..0b0c23af7690 100644 --- a/guava/src/com/google/common/collect/StandardTable.java +++ b/guava/src/com/google/common/collect/StandardTable.java @@ -43,7 +43,7 @@ import java.util.Spliterator; import java.util.Spliterators; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@link Table} implementation backed by a map that associates row keys with column key / value @@ -77,12 +77,12 @@ class StandardTable extends AbstractTable implements Serializa // Accessors @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return rowKey != null && columnKey != null && super.contains(rowKey, columnKey); } @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { if (columnKey == null) { return false; } @@ -95,17 +95,17 @@ public boolean containsColumn(@NullableDecl Object columnKey) { } @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { return rowKey != null && safeContainsKey(backingMap, rowKey); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return value != null && super.containsValue(value); } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { return (rowKey == null || columnKey == null) ? null : super.get(rowKey, columnKey); } @@ -150,7 +150,7 @@ public V put(R rowKey, C columnKey, V value) { @CanIgnoreReturnValue @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { if ((rowKey == null) || (columnKey == null)) { return null; } @@ -235,7 +235,7 @@ Iterator> cellIterator() { private class CellIterator implements Iterator> { final Iterator>> rowIterator = backingMap.entrySet().iterator(); - @NullableDecl Entry> rowEntry; + @Nullable Entry> rowEntry; Iterator> columnIterator = Iterators.emptyModifiableIterator(); @Override @@ -289,7 +289,7 @@ class Row extends IteratorBasedAbstractMap { this.rowKey = checkNotNull(rowKey); } - @NullableDecl Map backingRowMap; + @Nullable Map backingRowMap; Map backingRowMap() { return (backingRowMap == null || (backingRowMap.isEmpty() && backingMap.containsKey(rowKey))) diff --git a/guava/src/com/google/common/collect/Streams.java b/guava/src/com/google/common/collect/Streams.java index 94495770413d..d4b292999143 100644 --- a/guava/src/com/google/common/collect/Streams.java +++ b/guava/src/com/google/common/collect/Streams.java @@ -44,7 +44,7 @@ import java.util.stream.LongStream; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods related to {@code Stream} instances. @@ -373,14 +373,14 @@ public boolean tryAdvance(Consumer action) { .onClose(stream::close); } class Splitr extends MapWithIndexSpliterator, R, Splitr> implements Consumer { - @NullableDecl T holder; + @Nullable T holder; Splitr(Spliterator splitr, long index) { super(splitr, index); } @Override - public void accept(@NullableDecl T t) { + public void accept(@Nullable T t) { this.holder = t; } @@ -753,7 +753,7 @@ class OptionalState { boolean set = false; T value = null; - void set(@NullableDecl T value) { + void set(@Nullable T value) { this.set = true; this.value = value; } diff --git a/guava/src/com/google/common/collect/Synchronized.java b/guava/src/com/google/common/collect/Synchronized.java index be882bf96dc6..b89dff283d7b 100644 --- a/guava/src/com/google/common/collect/Synchronized.java +++ b/guava/src/com/google/common/collect/Synchronized.java @@ -49,7 +49,7 @@ import java.util.function.UnaryOperator; import java.util.stream.Stream; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Synchronized collection views. The returned synchronized collection views are serializable if the @@ -71,7 +71,7 @@ static class SynchronizedObject implements Serializable { final Object delegate; final Object mutex; - SynchronizedObject(Object delegate, @NullableDecl Object mutex) { + SynchronizedObject(Object delegate, @Nullable Object mutex) { this.delegate = checkNotNull(delegate); this.mutex = (mutex == null) ? this : mutex; } @@ -105,14 +105,13 @@ private void writeObject(ObjectOutputStream stream) throws IOException { private static final long serialVersionUID = 0; } - private static Collection collection( - Collection collection, @NullableDecl Object mutex) { + private static Collection collection(Collection collection, @Nullable Object mutex) { return new SynchronizedCollection(collection, mutex); } @VisibleForTesting static class SynchronizedCollection extends SynchronizedObject implements Collection { - private SynchronizedCollection(Collection delegate, @NullableDecl Object mutex) { + private SynchronizedCollection(Collection delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -250,13 +249,13 @@ public T[] toArray(T[] a) { } @VisibleForTesting - static Set set(Set set, @NullableDecl Object mutex) { + static Set set(Set set, @Nullable Object mutex) { return new SynchronizedSet(set, mutex); } static class SynchronizedSet extends SynchronizedCollection implements Set { - SynchronizedSet(Set delegate, @NullableDecl Object mutex) { + SynchronizedSet(Set delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -285,12 +284,12 @@ public int hashCode() { private static final long serialVersionUID = 0; } - private static SortedSet sortedSet(SortedSet set, @NullableDecl Object mutex) { + private static SortedSet sortedSet(SortedSet set, @Nullable Object mutex) { return new SynchronizedSortedSet(set, mutex); } static class SynchronizedSortedSet extends SynchronizedSet implements SortedSet { - SynchronizedSortedSet(SortedSet delegate, @NullableDecl Object mutex) { + SynchronizedSortedSet(SortedSet delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -344,14 +343,14 @@ public E last() { private static final long serialVersionUID = 0; } - private static List list(List list, @NullableDecl Object mutex) { + private static List list(List list, @Nullable Object mutex) { return (list instanceof RandomAccess) ? new SynchronizedRandomAccessList(list, mutex) : new SynchronizedList(list, mutex); } private static class SynchronizedList extends SynchronizedCollection implements List { - SynchronizedList(List delegate, @NullableDecl Object mutex) { + SynchronizedList(List delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -462,14 +461,14 @@ public int hashCode() { private static class SynchronizedRandomAccessList extends SynchronizedList implements RandomAccess { - SynchronizedRandomAccessList(List list, @NullableDecl Object mutex) { + SynchronizedRandomAccessList(List list, @Nullable Object mutex) { super(list, mutex); } private static final long serialVersionUID = 0; } - static Multiset multiset(Multiset multiset, @NullableDecl Object mutex) { + static Multiset multiset(Multiset multiset, @Nullable Object mutex) { if (multiset instanceof SynchronizedMultiset || multiset instanceof ImmutableMultiset) { return multiset; } @@ -481,7 +480,7 @@ private static class SynchronizedMultiset extends SynchronizedCollection @MonotonicNonNullDecl transient Set elementSet; @MonotonicNonNullDecl transient Set> entrySet; - SynchronizedMultiset(Multiset delegate, @NullableDecl Object mutex) { + SynchronizedMultiset(Multiset delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -565,7 +564,7 @@ public int hashCode() { private static final long serialVersionUID = 0; } - static Multimap multimap(Multimap multimap, @NullableDecl Object mutex) { + static Multimap multimap(Multimap multimap, @Nullable Object mutex) { if (multimap instanceof SynchronizedMultimap || multimap instanceof ImmutableMultimap) { return multimap; } @@ -586,7 +585,7 @@ Multimap delegate() { return (Multimap) super.delegate(); } - SynchronizedMultimap(Multimap delegate, @NullableDecl Object mutex) { + SynchronizedMultimap(Multimap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -759,7 +758,7 @@ public int hashCode() { } static ListMultimap listMultimap( - ListMultimap multimap, @NullableDecl Object mutex) { + ListMultimap multimap, @Nullable Object mutex) { if (multimap instanceof SynchronizedListMultimap || multimap instanceof ImmutableListMultimap) { return multimap; } @@ -768,7 +767,7 @@ static ListMultimap listMultimap( private static class SynchronizedListMultimap extends SynchronizedMultimap implements ListMultimap { - SynchronizedListMultimap(ListMultimap delegate, @NullableDecl Object mutex) { + SynchronizedListMultimap(ListMultimap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -801,8 +800,7 @@ public List replaceValues(K key, Iterable values) { private static final long serialVersionUID = 0; } - static SetMultimap setMultimap( - SetMultimap multimap, @NullableDecl Object mutex) { + static SetMultimap setMultimap(SetMultimap multimap, @Nullable Object mutex) { if (multimap instanceof SynchronizedSetMultimap || multimap instanceof ImmutableSetMultimap) { return multimap; } @@ -813,7 +811,7 @@ private static class SynchronizedSetMultimap extends SynchronizedMultimap< implements SetMultimap { @MonotonicNonNullDecl transient Set> entrySet; - SynchronizedSetMultimap(SetMultimap delegate, @NullableDecl Object mutex) { + SynchronizedSetMultimap(SetMultimap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -857,7 +855,7 @@ public Set> entries() { } static SortedSetMultimap sortedSetMultimap( - SortedSetMultimap multimap, @NullableDecl Object mutex) { + SortedSetMultimap multimap, @Nullable Object mutex) { if (multimap instanceof SynchronizedSortedSetMultimap) { return multimap; } @@ -866,7 +864,7 @@ static SortedSetMultimap sortedSetMultimap( private static class SynchronizedSortedSetMultimap extends SynchronizedSetMultimap implements SortedSetMultimap { - SynchronizedSortedSetMultimap(SortedSetMultimap delegate, @NullableDecl Object mutex) { + SynchronizedSortedSetMultimap(SortedSetMultimap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -907,7 +905,7 @@ public Comparator valueComparator() { } private static Collection typePreservingCollection( - Collection collection, @NullableDecl Object mutex) { + Collection collection, @Nullable Object mutex) { if (collection instanceof SortedSet) { return sortedSet((SortedSet) collection, mutex); } @@ -920,7 +918,7 @@ private static Collection typePreservingCollection( return collection(collection, mutex); } - private static Set typePreservingSet(Set set, @NullableDecl Object mutex) { + private static Set typePreservingSet(Set set, @Nullable Object mutex) { if (set instanceof SortedSet) { return sortedSet((SortedSet) set, mutex); } else { @@ -930,7 +928,7 @@ private static Set typePreservingSet(Set set, @NullableDecl Object mut private static class SynchronizedAsMapEntries extends SynchronizedSet>> { - SynchronizedAsMapEntries(Set>> delegate, @NullableDecl Object mutex) { + SynchronizedAsMapEntries(Set>> delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1021,7 +1019,7 @@ public boolean retainAll(Collection c) { } @VisibleForTesting - static Map map(Map map, @NullableDecl Object mutex) { + static Map map(Map map, @Nullable Object mutex) { return new SynchronizedMap<>(map, mutex); } @@ -1030,7 +1028,7 @@ private static class SynchronizedMap extends SynchronizedObject implements @MonotonicNonNullDecl transient Collection values; @MonotonicNonNullDecl transient Set> entrySet; - SynchronizedMap(Map delegate, @NullableDecl Object mutex) { + SynchronizedMap(Map delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1232,14 +1230,14 @@ public int hashCode() { private static final long serialVersionUID = 0; } - static SortedMap sortedMap(SortedMap sortedMap, @NullableDecl Object mutex) { + static SortedMap sortedMap(SortedMap sortedMap, @Nullable Object mutex) { return new SynchronizedSortedMap<>(sortedMap, mutex); } static class SynchronizedSortedMap extends SynchronizedMap implements SortedMap { - SynchronizedSortedMap(SortedMap delegate, @NullableDecl Object mutex) { + SynchronizedSortedMap(SortedMap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1293,7 +1291,7 @@ public SortedMap tailMap(K fromKey) { private static final long serialVersionUID = 0; } - static BiMap biMap(BiMap bimap, @NullableDecl Object mutex) { + static BiMap biMap(BiMap bimap, @Nullable Object mutex) { if (bimap instanceof SynchronizedBiMap || bimap instanceof ImmutableBiMap) { return bimap; } @@ -1307,7 +1305,7 @@ static class SynchronizedBiMap extends SynchronizedMap @MonotonicNonNullDecl @RetainedWith private transient BiMap inverse; private SynchronizedBiMap( - BiMap delegate, @NullableDecl Object mutex, @NullableDecl BiMap inverse) { + BiMap delegate, @Nullable Object mutex, @Nullable BiMap inverse) { super(delegate, mutex); this.inverse = inverse; } @@ -1351,7 +1349,7 @@ private static class SynchronizedAsMap extends SynchronizedMap>> asMapEntrySet; @MonotonicNonNullDecl transient Collection> asMapValues; - SynchronizedAsMap(Map> delegate, @NullableDecl Object mutex) { + SynchronizedAsMap(Map> delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1393,7 +1391,7 @@ public boolean containsValue(Object o) { } private static class SynchronizedAsMapValues extends SynchronizedCollection> { - SynchronizedAsMapValues(Collection> delegate, @NullableDecl Object mutex) { + SynchronizedAsMapValues(Collection> delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1415,7 +1413,7 @@ Collection transform(Collection from) { @VisibleForTesting static class SynchronizedNavigableSet extends SynchronizedSortedSet implements NavigableSet { - SynchronizedNavigableSet(NavigableSet delegate, @NullableDecl Object mutex) { + SynchronizedNavigableSet(NavigableSet delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1527,8 +1525,7 @@ public SortedSet tailSet(E fromElement) { } @GwtIncompatible // NavigableSet - static NavigableSet navigableSet( - NavigableSet navigableSet, @NullableDecl Object mutex) { + static NavigableSet navigableSet(NavigableSet navigableSet, @Nullable Object mutex) { return new SynchronizedNavigableSet(navigableSet, mutex); } @@ -1544,7 +1541,7 @@ static NavigableMap navigableMap(NavigableMap navigableMap) { @GwtIncompatible // NavigableMap static NavigableMap navigableMap( - NavigableMap navigableMap, @NullableDecl Object mutex) { + NavigableMap navigableMap, @Nullable Object mutex) { return new SynchronizedNavigableMap<>(navigableMap, mutex); } @@ -1553,7 +1550,7 @@ static NavigableMap navigableMap( static class SynchronizedNavigableMap extends SynchronizedSortedMap implements NavigableMap { - SynchronizedNavigableMap(NavigableMap delegate, @NullableDecl Object mutex) { + SynchronizedNavigableMap(NavigableMap delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1729,7 +1726,7 @@ public SortedMap tailMap(K fromKey) { @GwtIncompatible // works but is needed only for NavigableMap private static Entry nullableSynchronizedEntry( - @NullableDecl Entry entry, @NullableDecl Object mutex) { + @Nullable Entry entry, @Nullable Object mutex) { if (entry == null) { return null; } @@ -1739,7 +1736,7 @@ private static Entry nullableSynchronizedEntry( @GwtIncompatible // works but is needed only for NavigableMap private static class SynchronizedEntry extends SynchronizedObject implements Entry { - SynchronizedEntry(Entry delegate, @NullableDecl Object mutex) { + SynchronizedEntry(Entry delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1787,13 +1784,13 @@ public V setValue(V value) { private static final long serialVersionUID = 0; } - static Queue queue(Queue queue, @NullableDecl Object mutex) { + static Queue queue(Queue queue, @Nullable Object mutex) { return (queue instanceof SynchronizedQueue) ? queue : new SynchronizedQueue(queue, mutex); } private static class SynchronizedQueue extends SynchronizedCollection implements Queue { - SynchronizedQueue(Queue delegate, @NullableDecl Object mutex) { + SynchronizedQueue(Queue delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1840,13 +1837,13 @@ public E remove() { private static final long serialVersionUID = 0; } - static Deque deque(Deque deque, @NullableDecl Object mutex) { + static Deque deque(Deque deque, @Nullable Object mutex) { return new SynchronizedDeque(deque, mutex); } private static final class SynchronizedDeque extends SynchronizedQueue implements Deque { - SynchronizedDeque(Deque delegate, @NullableDecl Object mutex) { + SynchronizedDeque(Deque delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -1995,35 +1992,35 @@ Table delegate() { } @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { synchronized (mutex) { return delegate().contains(rowKey, columnKey); } } @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { synchronized (mutex) { return delegate().containsRow(rowKey); } } @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { synchronized (mutex) { return delegate().containsColumn(columnKey); } } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { synchronized (mutex) { return delegate().containsValue(value); } } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { synchronized (mutex) { return delegate().get(rowKey, columnKey); } @@ -2051,7 +2048,7 @@ public void clear() { } @Override - public V put(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) { + public V put(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) { synchronized (mutex) { return delegate().put(rowKey, columnKey, value); } @@ -2065,21 +2062,21 @@ public void putAll(Table table) { } @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { synchronized (mutex) { return delegate().remove(rowKey, columnKey); } } @Override - public Map row(@NullableDecl R rowKey) { + public Map row(@Nullable R rowKey) { synchronized (mutex) { return map(delegate().row(rowKey), mutex); } } @Override - public Map column(@NullableDecl C columnKey) { + public Map column(@Nullable C columnKey) { synchronized (mutex) { return map(delegate().column(columnKey), mutex); } @@ -2153,7 +2150,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } diff --git a/guava/src/com/google/common/collect/Table.java b/guava/src/com/google/common/collect/Table.java index 3da7c46e6112..9e29aa991251 100644 --- a/guava/src/com/google/common/collect/Table.java +++ b/guava/src/com/google/common/collect/Table.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection that associates an ordered pair of keys, called a row key and a column key, with a @@ -65,29 +65,29 @@ public interface Table { * @param columnKey key of column to search for */ boolean contains( - @NullableDecl @CompatibleWith("R") Object rowKey, - @NullableDecl @CompatibleWith("C") Object columnKey); + @Nullable @CompatibleWith("R") Object rowKey, + @Nullable @CompatibleWith("C") Object columnKey); /** * Returns {@code true} if the table contains a mapping with the specified row key. * * @param rowKey key of row to search for */ - boolean containsRow(@NullableDecl @CompatibleWith("R") Object rowKey); + boolean containsRow(@Nullable @CompatibleWith("R") Object rowKey); /** * Returns {@code true} if the table contains a mapping with the specified column. * * @param columnKey key of column to search for */ - boolean containsColumn(@NullableDecl @CompatibleWith("C") Object columnKey); + boolean containsColumn(@Nullable @CompatibleWith("C") Object columnKey); /** * Returns {@code true} if the table contains a mapping with the specified value. * * @param value value to search for */ - boolean containsValue(@NullableDecl @CompatibleWith("V") Object value); + boolean containsValue(@Nullable @CompatibleWith("V") Object value); /** * Returns the value corresponding to the given row and column keys, or {@code null} if no such @@ -97,8 +97,8 @@ boolean contains( * @param columnKey key of column to search for */ V get( - @NullableDecl @CompatibleWith("R") Object rowKey, - @NullableDecl @CompatibleWith("C") Object columnKey); + @Nullable @CompatibleWith("R") Object rowKey, + @Nullable @CompatibleWith("C") Object columnKey); /** Returns {@code true} if the table contains no mappings. */ boolean isEmpty(); @@ -111,7 +111,7 @@ V get( * cell views, as returned by {@link #cellSet}, are equal. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); /** * Returns the hash code for this table. The hash code of a table is defined as the hash code of @@ -136,7 +136,7 @@ V get( * for the keys */ @CanIgnoreReturnValue - @NullableDecl + @Nullable V put(R rowKey, C columnKey, V value); /** @@ -155,10 +155,10 @@ V get( * @return the value previously associated with the keys, or {@code null} if no such value existed */ @CanIgnoreReturnValue - @NullableDecl + @Nullable V remove( - @NullableDecl @CompatibleWith("R") Object rowKey, - @NullableDecl @CompatibleWith("C") Object columnKey); + @Nullable @CompatibleWith("R") Object rowKey, + @Nullable @CompatibleWith("C") Object columnKey); // Views @@ -252,15 +252,15 @@ V remove( */ interface Cell { /** Returns the row key of this cell. */ - @NullableDecl + @Nullable R getRowKey(); /** Returns the column key of this cell. */ - @NullableDecl + @Nullable C getColumnKey(); /** Returns the value of this cell. */ - @NullableDecl + @Nullable V getValue(); /** @@ -268,7 +268,7 @@ interface Cell { * equal row keys, column keys, and values. */ @Override - boolean equals(@NullableDecl Object obj); + boolean equals(@Nullable Object obj); /** * Returns the hash code of this cell. diff --git a/guava/src/com/google/common/collect/Tables.java b/guava/src/com/google/common/collect/Tables.java index 0c975ce86e0d..db91616f7c57 100644 --- a/guava/src/com/google/common/collect/Tables.java +++ b/guava/src/com/google/common/collect/Tables.java @@ -36,7 +36,7 @@ import java.util.Spliterator; import java.util.function.BinaryOperator; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides static methods that involve a {@code Table}. @@ -146,16 +146,16 @@ private static void merge( * @param value the value to be associated with the returned cell */ public static Cell immutableCell( - @NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) { + @Nullable R rowKey, @Nullable C columnKey, @Nullable V value) { return new ImmutableCell<>(rowKey, columnKey, value); } static final class ImmutableCell extends AbstractCell implements Serializable { - @NullableDecl private final R rowKey; - @NullableDecl private final C columnKey; - @NullableDecl private final V value; + @Nullable private final R rowKey; + @Nullable private final C columnKey; + @Nullable private final V value; - ImmutableCell(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) { + ImmutableCell(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) { this.rowKey = rowKey; this.columnKey = columnKey; this.value = value; @@ -254,27 +254,27 @@ public Map> columnMap() { } @Override - public boolean contains(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return original.contains(columnKey, rowKey); } @Override - public boolean containsColumn(@NullableDecl Object columnKey) { + public boolean containsColumn(@Nullable Object columnKey) { return original.containsRow(columnKey); } @Override - public boolean containsRow(@NullableDecl Object rowKey) { + public boolean containsRow(@Nullable Object rowKey) { return original.containsColumn(rowKey); } @Override - public boolean containsValue(@NullableDecl Object value) { + public boolean containsValue(@Nullable Object value) { return original.containsValue(value); } @Override - public V get(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V get(@Nullable Object rowKey, @Nullable Object columnKey) { return original.get(columnKey, rowKey); } @@ -289,7 +289,7 @@ public void putAll(Table table) { } @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { return original.remove(columnKey, rowKey); } @@ -574,7 +574,7 @@ public void clear() { } @Override - public Map column(@NullableDecl C columnKey) { + public Map column(@Nullable C columnKey) { return Collections.unmodifiableMap(super.column(columnKey)); } @@ -590,7 +590,7 @@ public Map> columnMap() { } @Override - public V put(@NullableDecl R rowKey, @NullableDecl C columnKey, @NullableDecl V value) { + public V put(@Nullable R rowKey, @Nullable C columnKey, @Nullable V value) { throw new UnsupportedOperationException(); } @@ -600,12 +600,12 @@ public void putAll(Table table) { } @Override - public V remove(@NullableDecl Object rowKey, @NullableDecl Object columnKey) { + public V remove(@Nullable Object rowKey, @Nullable Object columnKey) { throw new UnsupportedOperationException(); } @Override - public Map row(@NullableDecl R rowKey) { + public Map row(@Nullable R rowKey) { return Collections.unmodifiableMap(super.row(rowKey)); } @@ -723,7 +723,7 @@ public static Table synchronizedTable(Table table) { return Synchronized.table(table, null); } - static boolean equalsImpl(Table table, @NullableDecl Object obj) { + static boolean equalsImpl(Table table, @Nullable Object obj) { if (obj == table) { return true; } else if (obj instanceof Table) { diff --git a/guava/src/com/google/common/collect/TopKSelector.java b/guava/src/com/google/common/collect/TopKSelector.java index 0805d7e5e8b3..2f173ed4dd8d 100644 --- a/guava/src/com/google/common/collect/TopKSelector.java +++ b/guava/src/com/google/common/collect/TopKSelector.java @@ -28,7 +28,7 @@ import java.util.Iterator; import java.util.List; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An accumulator that selects the "top" {@code k} elements added to it, relative to a provided @@ -110,7 +110,7 @@ public static TopKSelector greatest(int k, Comparator comparat * The largest of the lowest k elements we've seen so far relative to this comparator. If * bufferSize ≥ k, then we can ignore any elements greater than this value. */ - @NullableDecl private T threshold; + @Nullable private T threshold; private TopKSelector(Comparator comparator, int k) { this.comparator = checkNotNull(comparator, "comparator"); @@ -125,7 +125,7 @@ private TopKSelector(Comparator comparator, int k) { * Adds {@code elem} as a candidate for the top {@code k} elements. This operation takes amortized * O(1) time. */ - public void offer(@NullableDecl T elem) { + public void offer(@Nullable T elem) { if (k == 0) { return; } else if (bufferSize == 0) { diff --git a/guava/src/com/google/common/collect/TreeBasedTable.java b/guava/src/com/google/common/collect/TreeBasedTable.java index 598f7ae110ad..2993b6654442 100644 --- a/guava/src/com/google/common/collect/TreeBasedTable.java +++ b/guava/src/com/google/common/collect/TreeBasedTable.java @@ -31,7 +31,7 @@ import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@code Table} whose row keys and column keys are ordered by their natural @@ -169,14 +169,14 @@ public SortedMap row(R rowKey) { } private class TreeRow extends Row implements SortedMap { - @NullableDecl final C lowerBound; - @NullableDecl final C upperBound; + @Nullable final C lowerBound; + @Nullable final C upperBound; TreeRow(R rowKey) { this(rowKey, null, null); } - TreeRow(R rowKey, @NullableDecl C lowerBound, @NullableDecl C upperBound) { + TreeRow(R rowKey, @Nullable C lowerBound, @Nullable C upperBound) { super(rowKey); this.lowerBound = lowerBound; this.upperBound = upperBound; @@ -201,7 +201,7 @@ int compare(Object a, Object b) { return cmp.compare(a, b); } - boolean rangeContains(@NullableDecl Object o) { + boolean rangeContains(@Nullable Object o) { return o != null && (lowerBound == null || compare(lowerBound, o) <= 0) && (upperBound == null || compare(upperBound, o) > 0); @@ -243,7 +243,7 @@ public C lastKey() { return backingRowMap().lastKey(); } - @NullableDecl transient SortedMap wholeRow; + @Nullable transient SortedMap wholeRow; /* * If the row was previously empty, we check if there's a new row here every @@ -327,7 +327,7 @@ public Iterator apply(Map input) { comparator); return new AbstractIterator() { - @NullableDecl C lastValue; + @Nullable C lastValue; @Override protected C computeNext() { diff --git a/guava/src/com/google/common/collect/TreeMultimap.java b/guava/src/com/google/common/collect/TreeMultimap.java index 3dcaebdf28ee..9a36126c94f9 100644 --- a/guava/src/com/google/common/collect/TreeMultimap.java +++ b/guava/src/com/google/common/collect/TreeMultimap.java @@ -31,7 +31,7 @@ import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@code Multimap} whose keys and values are ordered by their natural ordering or @@ -138,7 +138,7 @@ SortedSet createCollection() { } @Override - Collection createCollection(@NullableDecl K key) { + Collection createCollection(@Nullable K key) { if (key == null) { keyComparator().compare(key, key); } @@ -163,7 +163,7 @@ public Comparator valueComparator() { /** @since 14.0 (present with return type {@code SortedSet} since 2.0) */ @Override @GwtIncompatible // NavigableSet - public NavigableSet get(@NullableDecl K key) { + public NavigableSet get(@Nullable K key) { return (NavigableSet) super.get(key); } diff --git a/guava/src/com/google/common/collect/TreeMultiset.java b/guava/src/com/google/common/collect/TreeMultiset.java index a3526c99a1de..c9d31e2239f4 100644 --- a/guava/src/com/google/common/collect/TreeMultiset.java +++ b/guava/src/com/google/common/collect/TreeMultiset.java @@ -36,7 +36,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.function.ObjIntConsumer; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A multiset which maintains the ordering of its elements, according to either their natural order @@ -87,7 +87,7 @@ public static TreeMultiset create() { * indicates that the elements' natural ordering should be used. */ @SuppressWarnings("unchecked") - public static TreeMultiset create(@NullableDecl Comparator comparator) { + public static TreeMultiset create(@Nullable Comparator comparator) { return (comparator == null) ? new TreeMultiset((Comparator) Ordering.natural()) : new TreeMultiset(comparator); @@ -136,7 +136,7 @@ int nodeAggregate(AvlNode node) { } @Override - long treeAggregate(@NullableDecl AvlNode root) { + long treeAggregate(@Nullable AvlNode root) { return (root == null) ? 0 : root.totalCount; } }, @@ -147,14 +147,14 @@ int nodeAggregate(AvlNode node) { } @Override - long treeAggregate(@NullableDecl AvlNode root) { + long treeAggregate(@Nullable AvlNode root) { return (root == null) ? 0 : root.distinctElements; } }; abstract int nodeAggregate(AvlNode node); - abstract long treeAggregate(@NullableDecl AvlNode root); + abstract long treeAggregate(@Nullable AvlNode root); } private long aggregateForEntries(Aggregate aggr) { @@ -169,7 +169,7 @@ private long aggregateForEntries(Aggregate aggr) { return total; } - private long aggregateBelowRange(Aggregate aggr, @NullableDecl AvlNode node) { + private long aggregateBelowRange(Aggregate aggr, @Nullable AvlNode node) { if (node == null) { return 0; } @@ -192,7 +192,7 @@ private long aggregateBelowRange(Aggregate aggr, @NullableDecl AvlNode node) } } - private long aggregateAboveRange(Aggregate aggr, @NullableDecl AvlNode node) { + private long aggregateAboveRange(Aggregate aggr, @Nullable AvlNode node) { if (node == null) { return 0; } @@ -225,12 +225,12 @@ int distinctElements() { return Ints.saturatedCast(aggregateForEntries(Aggregate.DISTINCT)); } - static int distinctElements(@NullableDecl AvlNode node) { + static int distinctElements(@Nullable AvlNode node) { return (node == null) ? 0 : node.distinctElements; } @Override - public int count(@NullableDecl Object element) { + public int count(@Nullable Object element) { try { @SuppressWarnings("unchecked") E e = (E) element; @@ -246,7 +246,7 @@ public int count(@NullableDecl Object element) { @CanIgnoreReturnValue @Override - public int add(@NullableDecl E element, int occurrences) { + public int add(@Nullable E element, int occurrences) { checkNonnegative(occurrences, "occurrences"); if (occurrences == 0) { return count(element); @@ -268,7 +268,7 @@ public int add(@NullableDecl E element, int occurrences) { @CanIgnoreReturnValue @Override - public int remove(@NullableDecl Object element, int occurrences) { + public int remove(@Nullable Object element, int occurrences) { checkNonnegative(occurrences, "occurrences"); if (occurrences == 0) { return count(element); @@ -292,7 +292,7 @@ public int remove(@NullableDecl Object element, int occurrences) { @CanIgnoreReturnValue @Override - public int setCount(@NullableDecl E element, int count) { + public int setCount(@Nullable E element, int count) { checkNonnegative(count, "count"); if (!range.contains(element)) { checkArgument(count == 0); @@ -314,7 +314,7 @@ public int setCount(@NullableDecl E element, int count) { @CanIgnoreReturnValue @Override - public boolean setCount(@NullableDecl E element, int oldCount, int newCount) { + public boolean setCount(@Nullable E element, int oldCount, int newCount) { checkNonnegative(newCount, "newCount"); checkNonnegative(oldCount, "oldCount"); checkArgument(range.contains(element)); @@ -380,7 +380,7 @@ public int getCount() { } /** Returns the first node in the tree that is in range. */ - @NullableDecl + @Nullable private AvlNode firstNode() { AvlNode root = rootReference.get(); if (root == null) { @@ -403,7 +403,7 @@ && comparator().compare(endpoint, node.getElement()) == 0) { return (node == header || !range.contains(node.getElement())) ? null : node; } - @NullableDecl + @Nullable private AvlNode lastNode() { AvlNode root = rootReference.get(); if (root == null) { @@ -435,7 +435,7 @@ Iterator elementIterator() { Iterator> entryIterator() { return new Iterator>() { AvlNode current = firstNode(); - @NullableDecl Entry prevEntry; + @Nullable Entry prevEntry; @Override public boolean hasNext() { @@ -531,7 +531,7 @@ public Iterator iterator() { } @Override - public SortedMultiset headMultiset(@NullableDecl E upperBound, BoundType boundType) { + public SortedMultiset headMultiset(@Nullable E upperBound, BoundType boundType) { return new TreeMultiset( rootReference, range.intersect(GeneralRange.upTo(comparator(), upperBound, boundType)), @@ -539,7 +539,7 @@ public SortedMultiset headMultiset(@NullableDecl E upperBound, BoundType boun } @Override - public SortedMultiset tailMultiset(@NullableDecl E lowerBound, BoundType boundType) { + public SortedMultiset tailMultiset(@Nullable E lowerBound, BoundType boundType) { return new TreeMultiset( rootReference, range.intersect(GeneralRange.downTo(comparator(), lowerBound, boundType)), @@ -547,14 +547,14 @@ public SortedMultiset tailMultiset(@NullableDecl E lowerBound, BoundType boun } private static final class Reference { - @NullableDecl private T value; + @Nullable private T value; - @NullableDecl + @Nullable public T get() { return value; } - public void checkAndSet(@NullableDecl T expected, T newValue) { + public void checkAndSet(@Nullable T expected, T newValue) { if (value != expected) { throw new ConcurrentModificationException(); } @@ -567,7 +567,7 @@ void clear() { } private static final class AvlNode { - @NullableDecl private final E elem; + @Nullable private final E elem; // elemCount is 0 iff this node has been deleted. private int elemCount; @@ -575,12 +575,12 @@ private static final class AvlNode { private int distinctElements; private long totalCount; private int height; - @NullableDecl private AvlNode left; - @NullableDecl private AvlNode right; - @NullableDecl private AvlNode pred; - @NullableDecl private AvlNode succ; + @Nullable private AvlNode left; + @Nullable private AvlNode right; + @Nullable private AvlNode pred; + @Nullable private AvlNode succ; - AvlNode(@NullableDecl E elem, int elemCount) { + AvlNode(@Nullable E elem, int elemCount) { checkArgument(elemCount > 0); this.elem = elem; this.elemCount = elemCount; @@ -620,7 +620,7 @@ private AvlNode addLeftChild(E e, int count) { return this; } - AvlNode add(Comparator comparator, @NullableDecl E e, int count, int[] result) { + AvlNode add(Comparator comparator, @Nullable E e, int count, int[] result) { /* * It speeds things up considerably to unconditionally add count to totalCount here, * but that destroys failure atomicity in the case of count overflow. =( @@ -665,8 +665,7 @@ AvlNode add(Comparator comparator, @NullableDecl E e, int count, i return this; } - AvlNode remove( - Comparator comparator, @NullableDecl E e, int count, int[] result) { + AvlNode remove(Comparator comparator, @Nullable E e, int count, int[] result) { int cmp = comparator.compare(e, elem); if (cmp < 0) { AvlNode initLeft = left; @@ -717,8 +716,7 @@ AvlNode remove( } } - AvlNode setCount( - Comparator comparator, @NullableDecl E e, int count, int[] result) { + AvlNode setCount(Comparator comparator, @Nullable E e, int count, int[] result) { int cmp = comparator.compare(e, elem); if (cmp < 0) { AvlNode initLeft = left; @@ -768,7 +766,7 @@ AvlNode setCount( AvlNode setCount( Comparator comparator, - @NullableDecl E e, + @Nullable E e, int expectedCount, int newCount, int[] result) { @@ -940,15 +938,15 @@ private AvlNode rotateRight() { return newTop; } - private static long totalCount(@NullableDecl AvlNode node) { + private static long totalCount(@Nullable AvlNode node) { return (node == null) ? 0 : node.totalCount; } - private static int height(@NullableDecl AvlNode node) { + private static int height(@Nullable AvlNode node) { return (node == null) ? 0 : node.height; } - @NullableDecl + @Nullable private AvlNode ceiling(Comparator comparator, E e) { int cmp = comparator.compare(e, elem); if (cmp < 0) { @@ -960,7 +958,7 @@ private AvlNode ceiling(Comparator comparator, E e) { } } - @NullableDecl + @Nullable private AvlNode floor(Comparator comparator, E e) { int cmp = comparator.compare(e, elem); if (cmp > 0) { diff --git a/guava/src/com/google/common/collect/TreeRangeMap.java b/guava/src/com/google/common/collect/TreeRangeMap.java index 391284c90201..07b66fe4f6f5 100644 --- a/guava/src/com/google/common/collect/TreeRangeMap.java +++ b/guava/src/com/google/common/collect/TreeRangeMap.java @@ -37,7 +37,7 @@ import java.util.NavigableMap; import java.util.NoSuchElementException; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@code RangeMap} based on a {@code TreeMap}, supporting all optional @@ -100,14 +100,14 @@ Cut getUpperBound() { } @Override - @NullableDecl + @Nullable public V get(K key) { Entry, V> entry = getEntry(key); return (entry == null) ? null : entry.getValue(); } @Override - @NullableDecl + @Nullable public Entry, V> getEntry(K key) { Entry, RangeMapEntry> mapEntry = entriesByLowerBound.floorEntry(Cut.belowValue(key)); @@ -155,7 +155,7 @@ private Range coalescedRange(Range range, V value) { /** Returns the range that spans the given range and entry, if the entry can be coalesced. */ private static Range coalesce( - Range range, V value, @NullableDecl Entry, RangeMapEntry> entry) { + Range range, V value, @Nullable Entry, RangeMapEntry> entry) { if (entry != null && entry.getValue().getKey().isConnected(range) && entry.getValue().getValue().equals(value)) { @@ -261,12 +261,12 @@ private final class AsMapOfRanges extends IteratorBasedAbstractMap, V> } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { if (key instanceof Range) { Range range = (Range) key; RangeMapEntry rangeMapEntry = entriesByLowerBound.get(range.lowerBound); @@ -305,13 +305,13 @@ private RangeMap emptySubRangeMap() { private static final RangeMap EMPTY_SUB_RANGE_MAP = new RangeMap() { @Override - @NullableDecl + @Nullable public Object get(Comparable key) { return null; } @Override - @NullableDecl + @Nullable public Entry getEntry(Comparable key) { return null; } @@ -377,13 +377,13 @@ private class SubRangeMap implements RangeMap { } @Override - @NullableDecl + @Nullable public V get(K key) { return subRange.contains(key) ? TreeRangeMap.this.get(key) : null; } @Override - @NullableDecl + @Nullable public Entry, V> getEntry(K key) { if (subRange.contains(key)) { Entry, V> entry = TreeRangeMap.this.getEntry(key); @@ -515,7 +515,7 @@ protected Entry, V> computeNext() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof RangeMap) { RangeMap rangeMap = (RangeMap) o; return asMapOfRanges().equals(rangeMap.asMapOfRanges()); @@ -607,7 +607,7 @@ private boolean removeEntryIf(Predicate, V>> predicate) { public Set> keySet() { return new Maps.KeySet, V>(SubRangeMapAsMap.this) { @Override - public boolean remove(@NullableDecl Object o) { + public boolean remove(@Nullable Object o) { return SubRangeMapAsMap.this.remove(o) != null; } @@ -693,7 +693,7 @@ public boolean retainAll(Collection c) { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof RangeMap) { RangeMap rangeMap = (RangeMap) o; return asMapOfRanges().equals(rangeMap.asMapOfRanges()); diff --git a/guava/src/com/google/common/collect/TreeRangeSet.java b/guava/src/com/google/common/collect/TreeRangeSet.java index 4ef092e22d50..0d3fb130c6b5 100644 --- a/guava/src/com/google/common/collect/TreeRangeSet.java +++ b/guava/src/com/google/common/collect/TreeRangeSet.java @@ -31,7 +31,7 @@ import java.util.Set; import java.util.TreeMap; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link RangeSet} backed by a {@link TreeMap}. @@ -113,13 +113,13 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { return Sets.equalsImpl(this, o); } } @Override - @NullableDecl + @Nullable public Range rangeContaining(C value) { checkNotNull(value); Entry, Range> floorEntry = rangesByLowerBound.floorEntry(Cut.belowValue(value)); @@ -153,7 +153,7 @@ public boolean encloses(Range range) { return floorEntry != null && floorEntry.getValue().encloses(range); } - @NullableDecl + @Nullable private Range rangeEnclosing(Range range) { checkNotNull(range); Entry, Range> floorEntry = rangesByLowerBound.floorEntry(range.lowerBound); @@ -333,12 +333,12 @@ public Comparator> comparator() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @Override - public Range get(@NullableDecl Object key) { + public Range get(@Nullable Object key) { if (key instanceof Cut) { try { @SuppressWarnings("unchecked") // we catch CCEs @@ -625,7 +625,7 @@ public int size() { } @Override - @NullableDecl + @Nullable public Range get(Object key) { if (key instanceof Cut) { try { @@ -738,13 +738,13 @@ public Comparator> comparator() { } @Override - public boolean containsKey(@NullableDecl Object key) { + public boolean containsKey(@Nullable Object key) { return get(key) != null; } @Override - @NullableDecl - public Range get(@NullableDecl Object key) { + @Nullable + public Range get(@Nullable Object key) { if (key instanceof Cut) { try { @SuppressWarnings("unchecked") // we catch CCE's @@ -881,7 +881,7 @@ public boolean encloses(Range range) { } @Override - @NullableDecl + @Nullable public Range rangeContaining(C value) { if (!restriction.contains(value)) { return null; diff --git a/guava/src/com/google/common/graph/AbstractBaseGraph.java b/guava/src/com/google/common/graph/AbstractBaseGraph.java index d32bffc774bb..53606f1dafa6 100644 --- a/guava/src/com/google/common/graph/AbstractBaseGraph.java +++ b/guava/src/com/google/common/graph/AbstractBaseGraph.java @@ -29,7 +29,7 @@ import com.google.common.primitives.Ints; import java.util.AbstractSet; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of {@link BaseGraph}. @@ -84,7 +84,7 @@ public boolean remove(Object o) { // Graph. @SuppressWarnings("unchecked") @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (!(obj instanceof EndpointPair)) { return false; } @@ -186,7 +186,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (!(obj instanceof EndpointPair)) { return false; } @@ -227,7 +227,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (!(obj instanceof EndpointPair)) { return false; } diff --git a/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java b/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java index 1cba34fbe407..2bed9c3d36e0 100644 --- a/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java +++ b/guava/src/com/google/common/graph/AbstractDirectedNetworkConnections.java @@ -30,7 +30,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A base implementation of {@link NetworkConnections} for directed networks. @@ -79,7 +79,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { return inEdgeMap.containsKey(obj) || outEdgeMap.containsKey(obj); } }; diff --git a/guava/src/com/google/common/graph/AbstractGraph.java b/guava/src/com/google/common/graph/AbstractGraph.java index fc71345ff6a6..986c94b91d82 100644 --- a/guava/src/com/google/common/graph/AbstractGraph.java +++ b/guava/src/com/google/common/graph/AbstractGraph.java @@ -17,7 +17,7 @@ package com.google.common.graph; import com.google.common.annotations.Beta; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of {@link Graph}. It is recommended to extend this @@ -31,7 +31,7 @@ public abstract class AbstractGraph extends AbstractBaseGraph implements Graph { @Override - public final boolean equals(@NullableDecl Object obj) { + public final boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/graph/AbstractNetwork.java b/guava/src/com/google/common/graph/AbstractNetwork.java index b857276183ac..085a60006ff7 100644 --- a/guava/src/com/google/common/graph/AbstractNetwork.java +++ b/guava/src/com/google/common/graph/AbstractNetwork.java @@ -32,7 +32,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of {@link Network}. It is recommended to extend @@ -87,7 +87,7 @@ public int size() { // Network. @SuppressWarnings("unchecked") @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { if (!(obj instanceof EndpointPair)) { return false; } @@ -192,7 +192,7 @@ public Optional edgeConnecting(N nodeU, N nodeV) { } @Override - @NullableDecl + @Nullable public E edgeConnectingOrNull(N nodeU, N nodeV) { return edgeConnecting(nodeU, nodeV).orElse(null); } @@ -203,7 +203,7 @@ public boolean hasEdgeConnecting(N nodeU, N nodeV) { } @Override - public final boolean equals(@NullableDecl Object obj) { + public final boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/graph/AbstractValueGraph.java b/guava/src/com/google/common/graph/AbstractValueGraph.java index e133c70f34a1..c46b6ac982df 100644 --- a/guava/src/com/google/common/graph/AbstractValueGraph.java +++ b/guava/src/com/google/common/graph/AbstractValueGraph.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * This class provides a skeletal implementation of {@link ValueGraph}. It is recommended to extend @@ -106,7 +106,7 @@ public Optional edgeValue(N nodeU, N nodeV) { } @Override - public final boolean equals(@NullableDecl Object obj) { + public final boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/graph/ConfigurableNetwork.java b/guava/src/com/google/common/graph/ConfigurableNetwork.java index 7d08df198939..3d2679d86313 100644 --- a/guava/src/com/google/common/graph/ConfigurableNetwork.java +++ b/guava/src/com/google/common/graph/ConfigurableNetwork.java @@ -27,7 +27,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Configurable implementation of {@link Network} that supports the options supplied by {@link @@ -192,11 +192,11 @@ protected final N checkedReferenceNode(E edge) { return referenceNode; } - protected final boolean containsNode(@NullableDecl N node) { + protected final boolean containsNode(@Nullable N node) { return nodeConnections.containsKey(node); } - protected final boolean containsEdge(@NullableDecl E edge) { + protected final boolean containsEdge(@Nullable E edge) { return edgeToReferenceNode.containsKey(edge); } } diff --git a/guava/src/com/google/common/graph/ConfigurableValueGraph.java b/guava/src/com/google/common/graph/ConfigurableValueGraph.java index fc1eaf344c2b..25f5e49f0569 100644 --- a/guava/src/com/google/common/graph/ConfigurableValueGraph.java +++ b/guava/src/com/google/common/graph/ConfigurableValueGraph.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Configurable implementation of {@link ValueGraph} that supports the options supplied by {@link @@ -123,8 +123,8 @@ public boolean hasEdgeConnecting(N nodeU, N nodeV) { } @Override - @NullableDecl - public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) { + @Nullable + public V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) { checkNotNull(nodeU); checkNotNull(nodeV); GraphConnections connectionsU = nodeConnections.get(nodeU); @@ -146,7 +146,7 @@ protected final GraphConnections checkedConnections(N node) { return connections; } - protected final boolean containsNode(@NullableDecl N node) { + protected final boolean containsNode(@Nullable N node) { return nodeConnections.containsKey(node); } } diff --git a/guava/src/com/google/common/graph/DirectedGraphConnections.java b/guava/src/com/google/common/graph/DirectedGraphConnections.java index d8686a8393d4..0c86a75aa1f8 100644 --- a/guava/src/com/google/common/graph/DirectedGraphConnections.java +++ b/guava/src/com/google/common/graph/DirectedGraphConnections.java @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link GraphConnections} for directed graphs. @@ -126,7 +126,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { return isPredecessor(adjacentNodeValues.get(obj)); } }; @@ -158,7 +158,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object obj) { + public boolean contains(@Nullable Object obj) { return isSuccessor(adjacentNodeValues.get(obj)); } }; @@ -241,11 +241,11 @@ public V addSuccessor(N node, V value) { } } - private static boolean isPredecessor(@NullableDecl Object value) { + private static boolean isPredecessor(@Nullable Object value) { return (value == PRED) || (value instanceof PredAndSucc); } - private static boolean isSuccessor(@NullableDecl Object value) { + private static boolean isSuccessor(@Nullable Object value) { return (value != PRED) && (value != null); } } diff --git a/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java b/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java index e1ed3cc4d923..583c6139c867 100644 --- a/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java +++ b/guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link NetworkConnections} for directed networks with parallel edges. @@ -139,8 +139,8 @@ public void addOutEdge(E edge, N node) { } } - @NullableDecl - private static T getReference(@NullableDecl Reference reference) { + @Nullable + private static T getReference(@Nullable Reference reference) { return (reference == null) ? null : reference.get(); } } diff --git a/guava/src/com/google/common/graph/EdgesConnecting.java b/guava/src/com/google/common/graph/EdgesConnecting.java index d62eefaee59e..bfdbd011b3a5 100644 --- a/guava/src/com/google/common/graph/EdgesConnecting.java +++ b/guava/src/com/google/common/graph/EdgesConnecting.java @@ -23,7 +23,7 @@ import com.google.common.collect.UnmodifiableIterator; import java.util.AbstractSet; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A class to represent the set of edges connecting an (implicit) origin node to a target node. @@ -58,12 +58,12 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object edge) { + public boolean contains(@Nullable Object edge) { E connectingEdge = getConnectingEdge(); return (connectingEdge != null && connectingEdge.equals(edge)); } - @NullableDecl + @Nullable private E getConnectingEdge() { return nodeToOutEdge.get(targetNode); } diff --git a/guava/src/com/google/common/graph/ElementOrder.java b/guava/src/com/google/common/graph/ElementOrder.java index 9847f5991dec..cf8f932bd587 100644 --- a/guava/src/com/google/common/graph/ElementOrder.java +++ b/guava/src/com/google/common/graph/ElementOrder.java @@ -28,7 +28,7 @@ import com.google.errorprone.annotations.Immutable; import java.util.Comparator; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Used to represent the order of elements in a data structure that supports different options for @@ -50,7 +50,7 @@ public final class ElementOrder { private final Type type; @SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable! - @NullableDecl + @Nullable private final Comparator comparator; /** @@ -68,7 +68,7 @@ public enum Type { SORTED } - private ElementOrder(Type type, @NullableDecl Comparator comparator) { + private ElementOrder(Type type, @Nullable Comparator comparator) { this.type = checkNotNull(type); this.comparator = comparator; checkState((type == Type.SORTED) == (comparator != null)); @@ -117,7 +117,7 @@ public Comparator comparator() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/graph/EndpointPair.java b/guava/src/com/google/common/graph/EndpointPair.java index 7caa43bb4888..c87663474188 100644 --- a/guava/src/com/google/common/graph/EndpointPair.java +++ b/guava/src/com/google/common/graph/EndpointPair.java @@ -24,7 +24,7 @@ import com.google.common.collect.Iterators; import com.google.common.collect.UnmodifiableIterator; import com.google.errorprone.annotations.Immutable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable pair representing the two endpoints of an edge in a graph. The {@link EndpointPair} @@ -132,7 +132,7 @@ public final UnmodifiableIterator iterator() { * ordered {@link EndpointPair} is never equal to an unordered {@link EndpointPair}. */ @Override - public abstract boolean equals(@NullableDecl Object obj); + public abstract boolean equals(@Nullable Object obj); /** * The hashcode of an ordered {@link EndpointPair} is equal to {@code Objects.hashCode(source(), @@ -163,7 +163,7 @@ public boolean isOrdered() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } @@ -211,7 +211,7 @@ public boolean isOrdered() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/guava/src/com/google/common/graph/ForwardingValueGraph.java b/guava/src/com/google/common/graph/ForwardingValueGraph.java index f5c1602bb09c..f998023a8d49 100644 --- a/guava/src/com/google/common/graph/ForwardingValueGraph.java +++ b/guava/src/com/google/common/graph/ForwardingValueGraph.java @@ -18,7 +18,7 @@ import java.util.Optional; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A class to allow {@link ValueGraph} implementations to be backed by a provided delegate. This is @@ -101,8 +101,8 @@ public Optional edgeValue(N nodeU, N nodeV) { } @Override - @NullableDecl - public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) { + @Nullable + public V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) { return delegate().edgeValueOrDefault(nodeU, nodeV, defaultValue); } } diff --git a/guava/src/com/google/common/graph/Graph.java b/guava/src/com/google/common/graph/Graph.java index b980b18b1804..915da8567e73 100644 --- a/guava/src/com/google/common/graph/Graph.java +++ b/guava/src/com/google/common/graph/Graph.java @@ -18,7 +18,7 @@ import com.google.common.annotations.Beta; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An interface for extends BaseGraph { *

    A reference implementation of this is provided by {@link AbstractGraph#equals(Object)}. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); /** * Returns the hash code for this graph. The hash code of a graph is defined as the hash code of diff --git a/guava/src/com/google/common/graph/GraphConnections.java b/guava/src/com/google/common/graph/GraphConnections.java index 98cc8129f316..e4b3aa78adac 100644 --- a/guava/src/com/google/common/graph/GraphConnections.java +++ b/guava/src/com/google/common/graph/GraphConnections.java @@ -18,7 +18,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An interface for representing and manipulating an origin node's adjacent nodes and edge values in @@ -40,7 +40,7 @@ interface GraphConnections { * Returns the value associated with the edge connecting the origin node to {@code node}, or null * if there is no such edge. */ - @NullableDecl + @Nullable V value(N node); /** Remove {@code node} from the set of predecessors. */ diff --git a/guava/src/com/google/common/graph/Graphs.java b/guava/src/com/google/common/graph/Graphs.java index f07c52788efa..69e9c7f20646 100644 --- a/guava/src/com/google/common/graph/Graphs.java +++ b/guava/src/com/google/common/graph/Graphs.java @@ -33,7 +33,7 @@ import java.util.Optional; import java.util.Queue; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods for {@link Graph}, {@link ValueGraph}, and {@link Network} instances. @@ -99,10 +99,7 @@ public static boolean hasCycle(Network network) { * cycle in the graph. */ private static boolean subgraphHasCycle( - Graph graph, - Map visitedNodes, - N node, - @NullableDecl N previousNode) { + Graph graph, Map visitedNodes, N node, @Nullable N previousNode) { NodeVisitState state = visitedNodes.get(node); if (state == NodeVisitState.COMPLETE) { return false; @@ -129,7 +126,7 @@ && subgraphHasCycle(graph, visitedNodes, nextNode, node)) { * from B to A). */ private static boolean canTraverseWithoutReusingEdge( - Graph graph, Object nextNode, @NullableDecl Object previousNode) { + Graph graph, Object nextNode, @Nullable Object previousNode) { if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) { return true; } @@ -347,8 +344,8 @@ public Optional edgeValue(N nodeU, N nodeV) { } @Override - @NullableDecl - public V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue) { + @Nullable + public V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue) { return delegate().edgeValueOrDefault(nodeV, nodeU, defaultValue); // transpose } } diff --git a/guava/src/com/google/common/graph/MapIteratorCache.java b/guava/src/com/google/common/graph/MapIteratorCache.java index 5aa117f0cf88..0777c402d74d 100644 --- a/guava/src/com/google/common/graph/MapIteratorCache.java +++ b/guava/src/com/google/common/graph/MapIteratorCache.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A map-like data structure that wraps a backing map and caches values while iterating through @@ -47,20 +47,20 @@ class MapIteratorCache { // Per JDK: "the behavior of a map entry is undefined if the backing map has been modified after // the entry was returned by the iterator, except through the setValue operation on the map entry" // As such, this field must be cleared before every map mutation. - @NullableDecl private transient Entry entrySetCache; + @Nullable private transient Entry entrySetCache; MapIteratorCache(Map backingMap) { this.backingMap = checkNotNull(backingMap); } @CanIgnoreReturnValue - public V put(@NullableDecl K key, @NullableDecl V value) { + public V put(@Nullable K key, @Nullable V value) { clearCache(); return backingMap.put(key, value); } @CanIgnoreReturnValue - public V remove(@NullableDecl Object key) { + public V remove(@Nullable Object key) { clearCache(); return backingMap.remove(key); } @@ -70,16 +70,16 @@ public void clear() { backingMap.clear(); } - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); } - public final V getWithoutCaching(@NullableDecl Object key) { + public final V getWithoutCaching(@Nullable Object key) { return backingMap.get(key); } - public final boolean containsKey(@NullableDecl Object key) { + public final boolean containsKey(@Nullable Object key) { return getIfCached(key) != null || backingMap.containsKey(key); } @@ -110,7 +110,7 @@ public int size() { } @Override - public boolean contains(@NullableDecl Object key) { + public boolean contains(@Nullable Object key) { return containsKey(key); } }; @@ -118,7 +118,7 @@ public boolean contains(@NullableDecl Object key) { // Internal methods ('protected' is still package-visible, but treat as only subclass-visible) - protected V getIfCached(@NullableDecl Object key) { + protected V getIfCached(@Nullable Object key) { Entry entry = entrySetCache; // store local reference for thread-safety // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. diff --git a/guava/src/com/google/common/graph/MapRetrievalCache.java b/guava/src/com/google/common/graph/MapRetrievalCache.java index 5a52b8636ede..625867bfc29e 100644 --- a/guava/src/com/google/common/graph/MapRetrievalCache.java +++ b/guava/src/com/google/common/graph/MapRetrievalCache.java @@ -17,7 +17,7 @@ package com.google.common.graph; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link MapIteratorCache} that adds additional caching. In addition to the caching provided by @@ -26,8 +26,8 @@ * @author James Sexton */ class MapRetrievalCache extends MapIteratorCache { - @NullableDecl private transient CacheEntry cacheEntry1; - @NullableDecl private transient CacheEntry cacheEntry2; + @Nullable private transient CacheEntry cacheEntry1; + @Nullable private transient CacheEntry cacheEntry2; MapRetrievalCache(Map backingMap) { super(backingMap); @@ -35,7 +35,7 @@ class MapRetrievalCache extends MapIteratorCache { @SuppressWarnings("unchecked") // Safe because we only cast if key is found in map. @Override - public V get(@NullableDecl Object key) { + public V get(@Nullable Object key) { V value = getIfCached(key); if (value != null) { return value; @@ -51,7 +51,7 @@ public V get(@NullableDecl Object key) { // Internal methods ('protected' is still package-visible, but treat as only subclass-visible) @Override - protected V getIfCached(@NullableDecl Object key) { + protected V getIfCached(@Nullable Object key) { V value = super.getIfCached(key); if (value != null) { return value; diff --git a/guava/src/com/google/common/graph/MultiEdgesConnecting.java b/guava/src/com/google/common/graph/MultiEdgesConnecting.java index 916c6dd09a9e..5bddfbbdf202 100644 --- a/guava/src/com/google/common/graph/MultiEdgesConnecting.java +++ b/guava/src/com/google/common/graph/MultiEdgesConnecting.java @@ -24,7 +24,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A class to represent the set of edges connecting an (implicit) origin node to a target node. @@ -63,7 +63,7 @@ protected E computeNext() { } @Override - public boolean contains(@NullableDecl Object edge) { + public boolean contains(@Nullable Object edge) { return targetNode.equals(outEdgeToNode.get(edge)); } } diff --git a/guava/src/com/google/common/graph/Network.java b/guava/src/com/google/common/graph/Network.java index 3acd32ebc4d6..414b610af425 100644 --- a/guava/src/com/google/common/graph/Network.java +++ b/guava/src/com/google/common/graph/Network.java @@ -19,7 +19,7 @@ import com.google.common.annotations.Beta; import java.util.Optional; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An interface for extends SuccessorsFunction, PredecessorsFuncti * network * @since 23.0 */ - @NullableDecl + @Nullable E edgeConnectingOrNull(N nodeU, N nodeV); /** @@ -350,7 +350,7 @@ public interface Network extends SuccessorsFunction, PredecessorsFuncti *

    A reference implementation of this is provided by {@link AbstractNetwork#equals(Object)}. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); /** * Returns the hash code for this network. The hash code of a network is defined as the hash code diff --git a/guava/src/com/google/common/graph/Traverser.java b/guava/src/com/google/common/graph/Traverser.java index 9db2431dacd3..00331ad52a8e 100644 --- a/guava/src/com/google/common/graph/Traverser.java +++ b/guava/src/com/google/common/graph/Traverser.java @@ -30,7 +30,7 @@ import java.util.Iterator; import java.util.Queue; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An object that can traverse the nodes that are reachable from a specified (set of) start node(s) @@ -471,10 +471,10 @@ NodeAndSuccessors withSuccessors(N node) { /** A simple tuple of a node and a partially iterated {@link Iterator} of its successors. */ private final class NodeAndSuccessors { - @NullableDecl final N node; + @Nullable final N node; final Iterator successorIterator; - NodeAndSuccessors(@NullableDecl N node, Iterable successors) { + NodeAndSuccessors(@Nullable N node, Iterable successors) { this.node = node; this.successorIterator = successors.iterator(); } @@ -644,10 +644,10 @@ NodeAndChildren withChildren(N node) { /** A simple tuple of a node and a partially iterated {@link Iterator} of its children. */ private final class NodeAndChildren { - @NullableDecl final N node; + @Nullable final N node; final Iterator childIterator; - NodeAndChildren(@NullableDecl N node, Iterable children) { + NodeAndChildren(@Nullable N node, Iterable children) { this.node = node; this.childIterator = children.iterator(); } diff --git a/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java b/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java index a3913799a11d..83f4306fc580 100644 --- a/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java +++ b/guava/src/com/google/common/graph/UndirectedMultiNetworkConnections.java @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An implementation of {@link NetworkConnections} for undirected networks with parallel edges. @@ -115,8 +115,8 @@ public void addOutEdge(E edge, N node) { } } - @NullableDecl - private static T getReference(@NullableDecl Reference reference) { + @Nullable + private static T getReference(@Nullable Reference reference) { return (reference == null) ? null : reference.get(); } } diff --git a/guava/src/com/google/common/graph/ValueGraph.java b/guava/src/com/google/common/graph/ValueGraph.java index 1acd44270bce..1573483b6119 100644 --- a/guava/src/com/google/common/graph/ValueGraph.java +++ b/guava/src/com/google/common/graph/ValueGraph.java @@ -19,7 +19,7 @@ import com.google.common.annotations.Beta; import java.util.Optional; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An interface for extends BaseGraph { * @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not an element of this * graph */ - @NullableDecl - V edgeValueOrDefault(N nodeU, N nodeV, @NullableDecl V defaultValue); + @Nullable + V edgeValueOrDefault(N nodeU, N nodeV, @Nullable V defaultValue); // // ValueGraph identity @@ -295,7 +295,7 @@ public interface ValueGraph extends BaseGraph { *

    A reference implementation of this is provided by {@link AbstractValueGraph#equals(Object)}. */ @Override - boolean equals(@NullableDecl Object object); + boolean equals(@Nullable Object object); /** * Returns the hash code for this graph. The hash code of a graph is defined as the hash code of a diff --git a/guava/src/com/google/common/hash/BloomFilter.java b/guava/src/com/google/common/hash/BloomFilter.java index 89b3c794135e..6624be00f448 100644 --- a/guava/src/com/google/common/hash/BloomFilter.java +++ b/guava/src/com/google/common/hash/BloomFilter.java @@ -34,7 +34,7 @@ import java.io.Serializable; import java.math.RoundingMode; import java.util.stream.Collector; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A Bloom filter for instances of {@code T}. A Bloom filter offers an approximate containment test @@ -269,7 +269,7 @@ public void putAll(BloomFilter that) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/hash/BloomFilterStrategies.java b/guava/src/com/google/common/hash/BloomFilterStrategies.java index bae0f31d5244..874ea1e63f84 100644 --- a/guava/src/com/google/common/hash/BloomFilterStrategies.java +++ b/guava/src/com/google/common/hash/BloomFilterStrategies.java @@ -22,7 +22,7 @@ import java.math.RoundingMode; import java.util.Arrays; import java.util.concurrent.atomic.AtomicLongArray; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Collections of strategies of generating the k * log(M) bits required for an element to be mapped @@ -266,7 +266,7 @@ void putAll(LockFreeBitArray other) { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof LockFreeBitArray) { LockFreeBitArray lockFreeBitArray = (LockFreeBitArray) o; // TODO(lowasser): avoid allocation here diff --git a/guava/src/com/google/common/hash/Funnels.java b/guava/src/com/google/common/hash/Funnels.java index 9bb48337bc8b..a95769e91347 100644 --- a/guava/src/com/google/common/hash/Funnels.java +++ b/guava/src/com/google/common/hash/Funnels.java @@ -19,7 +19,7 @@ import java.io.OutputStream; import java.io.Serializable; import java.nio.charset.Charset; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Funnels for common types. All implementations are serializable. @@ -100,7 +100,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof StringCharsetFunnel) { StringCharsetFunnel funnel = (StringCharsetFunnel) o; return this.charset.equals(funnel.charset); @@ -183,7 +183,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof SequentialFunnel) { SequentialFunnel funnel = (SequentialFunnel) o; return elementFunnel.equals(funnel.elementFunnel); diff --git a/guava/src/com/google/common/hash/HashCode.java b/guava/src/com/google/common/hash/HashCode.java index 560e41ad85ca..b6a5ff8f0b52 100644 --- a/guava/src/com/google/common/hash/HashCode.java +++ b/guava/src/com/google/common/hash/HashCode.java @@ -24,7 +24,7 @@ import com.google.common.primitives.UnsignedInts; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.Serializable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable hash code of arbitrary bit length. @@ -369,7 +369,7 @@ private static int decode(char ch) { * to protect against timing attacks. */ @Override - public final boolean equals(@NullableDecl Object object) { + public final boolean equals(@Nullable Object object) { if (object instanceof HashCode) { HashCode that = (HashCode) object; return bits() == that.bits() && equalsSameBits(that); diff --git a/guava/src/com/google/common/hash/Hashing.java b/guava/src/com/google/common/hash/Hashing.java index 3acccae4103f..cbb9388563ba 100644 --- a/guava/src/com/google/common/hash/Hashing.java +++ b/guava/src/com/google/common/hash/Hashing.java @@ -28,7 +28,7 @@ import java.util.zip.CRC32; import java.util.zip.Checksum; import javax.crypto.spec.SecretKeySpec; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static methods to obtain {@link HashFunction} instances, and other static hashing-related @@ -642,7 +642,7 @@ public int bits() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof ConcatenatedHashFunction) { ConcatenatedHashFunction other = (ConcatenatedHashFunction) object; return Arrays.equals(functions, other.functions); diff --git a/guava/src/com/google/common/hash/Murmur3_128HashFunction.java b/guava/src/com/google/common/hash/Murmur3_128HashFunction.java index 83e60e73d2d5..a365ad86da40 100644 --- a/guava/src/com/google/common/hash/Murmur3_128HashFunction.java +++ b/guava/src/com/google/common/hash/Murmur3_128HashFunction.java @@ -31,7 +31,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * See MurmurHash3_x64_128 in the @@ -70,7 +70,7 @@ public String toString() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof Murmur3_128HashFunction) { Murmur3_128HashFunction other = (Murmur3_128HashFunction) object; return seed == other.seed; diff --git a/guava/src/com/google/common/hash/Murmur3_32HashFunction.java b/guava/src/com/google/common/hash/Murmur3_32HashFunction.java index 373117e9614e..4a21383022e3 100644 --- a/guava/src/com/google/common/hash/Murmur3_32HashFunction.java +++ b/guava/src/com/google/common/hash/Murmur3_32HashFunction.java @@ -39,7 +39,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * See MurmurHash3_x86_32 in C register(@NullableDecl C closeable) { + public C register(@Nullable C closeable) { if (closeable != null) { stack.addFirst(closeable); } diff --git a/guava/src/com/google/common/io/FileBackedOutputStream.java b/guava/src/com/google/common/io/FileBackedOutputStream.java index e3031101a2ae..0f10a0c29a51 100644 --- a/guava/src/com/google/common/io/FileBackedOutputStream.java +++ b/guava/src/com/google/common/io/FileBackedOutputStream.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An {@link OutputStream} that starts buffering to a byte array, but switches to file buffering @@ -46,7 +46,7 @@ public final class FileBackedOutputStream extends OutputStream { private OutputStream out; private MemoryOutput memory; - @NullableDecl private File file; + @Nullable private File file; /** ByteArrayOutputStream that exposes its internals. */ private static class MemoryOutput extends ByteArrayOutputStream { diff --git a/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java b/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java index 187ab23c173d..7d0780571511 100644 --- a/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java +++ b/guava/src/com/google/common/io/InsecureRecursiveDeleteException.java @@ -21,7 +21,7 @@ import com.google.j2objc.annotations.J2ObjCIncompatible; import java.nio.file.FileSystemException; import java.nio.file.SecureDirectoryStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Exception indicating that a recursive delete can't be performed because the file system does not @@ -40,7 +40,7 @@ @J2ObjCIncompatible // java.nio.file public final class InsecureRecursiveDeleteException extends FileSystemException { - public InsecureRecursiveDeleteException(@NullableDecl String file) { + public InsecureRecursiveDeleteException(@Nullable String file) { super(file, null, "unable to guarantee security of recursive delete"); } } diff --git a/guava/src/com/google/common/io/LineReader.java b/guava/src/com/google/common/io/LineReader.java index 8514a2985727..c4b8e25abfc4 100644 --- a/guava/src/com/google/common/io/LineReader.java +++ b/guava/src/com/google/common/io/LineReader.java @@ -25,7 +25,7 @@ import java.nio.CharBuffer; import java.util.LinkedList; import java.util.Queue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A class for reading lines of text. Provides the same functionality as {@link @@ -39,7 +39,7 @@ @GwtIncompatible public final class LineReader { private final Readable readable; - @NullableDecl private final Reader reader; + @Nullable private final Reader reader; private final CharBuffer cbuf = createBuffer(); private final char[] buf = cbuf.array(); diff --git a/guava/src/com/google/common/io/MoreFiles.java b/guava/src/com/google/common/io/MoreFiles.java index 022455e5e95b..e8c87cd90c6a 100644 --- a/guava/src/com/google/common/io/MoreFiles.java +++ b/guava/src/com/google/common/io/MoreFiles.java @@ -54,7 +54,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utilities for use with {@link Path} instances, intended to complement {@link Files}. @@ -611,7 +611,7 @@ public static void deleteDirectoryContents(Path path, RecursiveDeleteOption... o * Secure recursive delete using {@code SecureDirectoryStream}. Returns a collection of exceptions * that occurred or null if no exceptions were thrown. */ - @NullableDecl + @Nullable private static Collection deleteRecursivelySecure( SecureDirectoryStream dir, Path path) { Collection exceptions = null; @@ -640,7 +640,7 @@ private static Collection deleteRecursivelySecure( * Secure method for deleting the contents of a directory using {@code SecureDirectoryStream}. * Returns a collection of exceptions that occurred or null if no exceptions were thrown. */ - @NullableDecl + @Nullable private static Collection deleteDirectoryContentsSecure( SecureDirectoryStream dir) { Collection exceptions = null; @@ -659,7 +659,7 @@ private static Collection deleteDirectoryContentsSecure( * Insecure recursive delete for file systems that don't support {@code SecureDirectoryStream}. * Returns a collection of exceptions that occurred or null if no exceptions were thrown. */ - @NullableDecl + @Nullable private static Collection deleteRecursivelyInsecure(Path path) { Collection exceptions = null; try { @@ -686,7 +686,7 @@ private static Collection deleteRecursivelyInsecure(Path path) { * support {@code SecureDirectoryStream}. Returns a collection of exceptions that occurred or null * if no exceptions were thrown. */ - @NullableDecl + @Nullable private static Collection deleteDirectoryContentsInsecure( DirectoryStream dir) { Collection exceptions = null; @@ -706,7 +706,7 @@ private static Collection deleteDirectoryContentsInsecure( * path, this is simple. Otherwise, we need to do some trickier things. Returns null if the path * is a root or is the empty path. */ - @NullableDecl + @Nullable private static Path getParentPath(Path path) { Path parent = path.getParent(); @@ -753,7 +753,7 @@ private static void checkAllowsInsecure(Path path, RecursiveDeleteOption[] optio * the collection. */ private static Collection addException( - @NullableDecl Collection exceptions, IOException e) { + @Nullable Collection exceptions, IOException e) { if (exceptions == null) { exceptions = new ArrayList<>(); // don't need Set semantics } @@ -766,10 +766,9 @@ private static Collection addException( * null, the other collection is returned. Otherwise, the elements of {@code other} are added to * {@code exceptions} and {@code exceptions} is returned. */ - @NullableDecl + @Nullable private static Collection concat( - @NullableDecl Collection exceptions, - @NullableDecl Collection other) { + @Nullable Collection exceptions, @Nullable Collection other) { if (exceptions == null) { return other; } else if (other != null) { diff --git a/guava/src/com/google/common/io/MultiInputStream.java b/guava/src/com/google/common/io/MultiInputStream.java index bae8e391964a..d1ec9095ccb8 100644 --- a/guava/src/com/google/common/io/MultiInputStream.java +++ b/guava/src/com/google/common/io/MultiInputStream.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An {@link InputStream} that concatenates multiple substreams. At most one stream will be open at @@ -33,7 +33,7 @@ final class MultiInputStream extends InputStream { private Iterator it; - @NullableDecl private InputStream in; + @Nullable private InputStream in; /** * Creates a new instance. @@ -90,7 +90,7 @@ public int read() throws IOException { } @Override - public int read(@NullableDecl byte[] b, int off, int len) throws IOException { + public int read(byte @Nullable [] b, int off, int len) throws IOException { while (in != null) { int result = in.read(b, off, len); if (result != -1) { diff --git a/guava/src/com/google/common/io/MultiReader.java b/guava/src/com/google/common/io/MultiReader.java index d075727ef08f..0c2aee068469 100644 --- a/guava/src/com/google/common/io/MultiReader.java +++ b/guava/src/com/google/common/io/MultiReader.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.io.Reader; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Reader} that concatenates multiple readers. @@ -30,7 +30,7 @@ @GwtIncompatible class MultiReader extends Reader { private final Iterator it; - @NullableDecl private Reader current; + @Nullable private Reader current; MultiReader(Iterator readers) throws IOException { this.it = readers; @@ -46,7 +46,7 @@ private void advance() throws IOException { } @Override - public int read(@NullableDecl char[] cbuf, int off, int len) throws IOException { + public int read(char @Nullable [] cbuf, int off, int len) throws IOException { if (current == null) { return -1; } diff --git a/guava/src/com/google/common/io/PatternFilenameFilter.java b/guava/src/com/google/common/io/PatternFilenameFilter.java index 43e4f30154fa..4058e7d29602 100644 --- a/guava/src/com/google/common/io/PatternFilenameFilter.java +++ b/guava/src/com/google/common/io/PatternFilenameFilter.java @@ -21,7 +21,7 @@ import java.io.FilenameFilter; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * File name filter that only accepts files matching a regular expression. This class is thread-safe @@ -56,7 +56,7 @@ public PatternFilenameFilter(Pattern pattern) { } @Override - public boolean accept(@NullableDecl File dir, String fileName) { + public boolean accept(@Nullable File dir, String fileName) { return pattern.matcher(fileName).matches(); } } diff --git a/guava/src/com/google/common/math/MathPreconditions.java b/guava/src/com/google/common/math/MathPreconditions.java index 5c39e17c72da..231dcbb8496c 100644 --- a/guava/src/com/google/common/math/MathPreconditions.java +++ b/guava/src/com/google/common/math/MathPreconditions.java @@ -17,7 +17,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.math.BigInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A collection of preconditions for math functions. @@ -27,49 +27,49 @@ @GwtCompatible @CanIgnoreReturnValue final class MathPreconditions { - static int checkPositive(@NullableDecl String role, int x) { + static int checkPositive(@Nullable String role, int x) { if (x <= 0) { throw new IllegalArgumentException(role + " (" + x + ") must be > 0"); } return x; } - static long checkPositive(@NullableDecl String role, long x) { + static long checkPositive(@Nullable String role, long x) { if (x <= 0) { throw new IllegalArgumentException(role + " (" + x + ") must be > 0"); } return x; } - static BigInteger checkPositive(@NullableDecl String role, BigInteger x) { + static BigInteger checkPositive(@Nullable String role, BigInteger x) { if (x.signum() <= 0) { throw new IllegalArgumentException(role + " (" + x + ") must be > 0"); } return x; } - static int checkNonNegative(@NullableDecl String role, int x) { + static int checkNonNegative(@Nullable String role, int x) { if (x < 0) { throw new IllegalArgumentException(role + " (" + x + ") must be >= 0"); } return x; } - static long checkNonNegative(@NullableDecl String role, long x) { + static long checkNonNegative(@Nullable String role, long x) { if (x < 0) { throw new IllegalArgumentException(role + " (" + x + ") must be >= 0"); } return x; } - static BigInteger checkNonNegative(@NullableDecl String role, BigInteger x) { + static BigInteger checkNonNegative(@Nullable String role, BigInteger x) { if (x.signum() < 0) { throw new IllegalArgumentException(role + " (" + x + ") must be >= 0"); } return x; } - static double checkNonNegative(@NullableDecl String role, double x) { + static double checkNonNegative(@Nullable String role, double x) { if (!(x >= 0)) { // not x < 0, to work with NaN. throw new IllegalArgumentException(role + " (" + x + ") must be >= 0"); } diff --git a/guava/src/com/google/common/math/PairedStats.java b/guava/src/com/google/common/math/PairedStats.java index 19ad8c49cea6..a07072bf6052 100644 --- a/guava/src/com/google/common/math/PairedStats.java +++ b/guava/src/com/google/common/math/PairedStats.java @@ -28,7 +28,7 @@ import java.io.Serializable; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable value object capturing some basic statistics about a collection of paired double @@ -213,7 +213,7 @@ public LinearTransformation leastSquaresFit() { * guarantees {@code strictfp}-like semantics.) */ @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == null) { return false; } diff --git a/guava/src/com/google/common/math/Stats.java b/guava/src/com/google/common/math/Stats.java index 69469b12b847..273bb8e6a9e3 100644 --- a/guava/src/com/google/common/math/Stats.java +++ b/guava/src/com/google/common/math/Stats.java @@ -32,7 +32,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Iterator; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A bundle of statistical summary values -- sum, count, mean/average, min and max, and several @@ -339,7 +339,7 @@ public double max() { * {@code strictfp}-like semantics.) */ @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == null) { return false; } diff --git a/guava/src/com/google/common/primitives/Booleans.java b/guava/src/com/google/common/primitives/Booleans.java index 787766db87e1..11ce0623dd5d 100644 --- a/guava/src/com/google/common/primitives/Booleans.java +++ b/guava/src/com/google/common/primitives/Booleans.java @@ -29,7 +29,7 @@ import java.util.Comparator; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code boolean} primitives, that are not already found in @@ -458,7 +458,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/Bytes.java b/guava/src/com/google/common/primitives/Bytes.java index 1071a0e7b896..dd8aea0d02db 100644 --- a/guava/src/com/google/common/primitives/Bytes.java +++ b/guava/src/com/google/common/primitives/Bytes.java @@ -27,7 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code byte} primitives, that are not already found in @@ -319,7 +319,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/Chars.java b/guava/src/com/google/common/primitives/Chars.java index 0ab1f71ec854..9bd6e4e22fa0 100644 --- a/guava/src/com/google/common/primitives/Chars.java +++ b/guava/src/com/google/common/primitives/Chars.java @@ -30,7 +30,7 @@ import java.util.Comparator; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code char} primitives, that are not already found in @@ -589,7 +589,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/Doubles.java b/guava/src/com/google/common/primitives/Doubles.java index 919bf0c88e0e..7df81fe7ff1f 100644 --- a/guava/src/com/google/common/primitives/Doubles.java +++ b/guava/src/com/google/common/primitives/Doubles.java @@ -36,7 +36,7 @@ import java.util.Spliterator; import java.util.Spliterators; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code double} primitives, that are not already found in @@ -601,7 +601,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -682,7 +682,7 @@ private static Pattern fpPattern() { * @since 14.0 */ @Beta - @NullableDecl + @Nullable @GwtIncompatible // regular expressions public static Double tryParse(String string) { if (FLOATING_POINT_PATTERN.matcher(string).matches()) { diff --git a/guava/src/com/google/common/primitives/Floats.java b/guava/src/com/google/common/primitives/Floats.java index c35f32efe81a..701b5767613f 100644 --- a/guava/src/com/google/common/primitives/Floats.java +++ b/guava/src/com/google/common/primitives/Floats.java @@ -33,7 +33,7 @@ import java.util.Comparator; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code float} primitives, that are not already found in @@ -586,7 +586,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -649,7 +649,7 @@ float[] toFloatArray() { * @since 14.0 */ @Beta - @NullableDecl + @Nullable @GwtIncompatible // regular expressions public static Float tryParse(String string) { if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) { diff --git a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java index c3dcdc8e49bf..f8a56e03315f 100644 --- a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java +++ b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java @@ -33,7 +33,7 @@ import java.util.Spliterators; import java.util.function.DoubleConsumer; import java.util.stream.DoubleStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable array of {@code double} values, with an API resembling {@link List}. @@ -512,7 +512,7 @@ public Spliterator spliterator() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof AsList) { AsList that = (AsList) object; return this.parent.equals(that.parent); @@ -552,7 +552,7 @@ public String toString() { * values as this one, in the same order. Values are compared as if by {@link Double#equals}. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/ImmutableIntArray.java b/guava/src/com/google/common/primitives/ImmutableIntArray.java index a514286533f1..6480b58b3733 100644 --- a/guava/src/com/google/common/primitives/ImmutableIntArray.java +++ b/guava/src/com/google/common/primitives/ImmutableIntArray.java @@ -33,7 +33,7 @@ import java.util.Spliterators; import java.util.function.IntConsumer; import java.util.stream.IntStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable array of {@code int} values, with an API resembling {@link List}. @@ -507,7 +507,7 @@ public Spliterator spliterator() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof AsList) { AsList that = (AsList) object; return this.parent.equals(that.parent); @@ -547,7 +547,7 @@ public String toString() { * values as this one, in the same order. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/ImmutableLongArray.java b/guava/src/com/google/common/primitives/ImmutableLongArray.java index b1b146c9b82c..399aa185349f 100644 --- a/guava/src/com/google/common/primitives/ImmutableLongArray.java +++ b/guava/src/com/google/common/primitives/ImmutableLongArray.java @@ -33,7 +33,7 @@ import java.util.Spliterators; import java.util.function.LongConsumer; import java.util.stream.LongStream; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An immutable array of {@code long} values, with an API resembling {@link List}. @@ -509,7 +509,7 @@ public Spliterator spliterator() { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object instanceof AsList) { AsList that = (AsList) object; return this.parent.equals(that.parent); @@ -549,7 +549,7 @@ public String toString() { * values as this one, in the same order. */ @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/Ints.java b/guava/src/com/google/common/primitives/Ints.java index 175d7260753b..2b4ced08d87a 100644 --- a/guava/src/com/google/common/primitives/Ints.java +++ b/guava/src/com/google/common/primitives/Ints.java @@ -32,7 +32,7 @@ import java.util.RandomAccess; import java.util.Spliterator; import java.util.Spliterators; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code int} primitives, that are not already found in either @@ -644,7 +644,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } @@ -707,7 +707,7 @@ int[] toIntArray() { * @since 11.0 */ @Beta - @NullableDecl + @Nullable public static Integer tryParse(String string) { return tryParse(string, 10); } @@ -732,7 +732,7 @@ public static Integer tryParse(String string) { * @since 19.0 */ @Beta - @NullableDecl + @Nullable public static Integer tryParse(String string, int radix) { Long result = Longs.tryParse(string, radix); if (result == null || result.longValue() != result.intValue()) { diff --git a/guava/src/com/google/common/primitives/Longs.java b/guava/src/com/google/common/primitives/Longs.java index a33d4b03efdc..5e0ce239c28e 100644 --- a/guava/src/com/google/common/primitives/Longs.java +++ b/guava/src/com/google/common/primitives/Longs.java @@ -32,7 +32,7 @@ import java.util.RandomAccess; import java.util.Spliterator; import java.util.Spliterators; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code long} primitives, that are not already found in @@ -362,7 +362,7 @@ static int digit(char c) { * @since 14.0 */ @Beta - @NullableDecl + @Nullable public static Long tryParse(String string) { return tryParse(string, 10); } @@ -387,7 +387,7 @@ public static Long tryParse(String string) { * @since 19.0 */ @Beta - @NullableDecl + @Nullable public static Long tryParse(String string, int radix) { if (checkNotNull(string).isEmpty()) { return null; @@ -743,7 +743,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/Shorts.java b/guava/src/com/google/common/primitives/Shorts.java index 18309cda6b72..e0e727ebf7ad 100644 --- a/guava/src/com/google/common/primitives/Shorts.java +++ b/guava/src/com/google/common/primitives/Shorts.java @@ -31,7 +31,7 @@ import java.util.Comparator; import java.util.List; import java.util.RandomAccess; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to {@code short} primitives, that are not already found in @@ -588,13 +588,13 @@ public Short get(int index) { } @Override - public boolean contains(@NullableDecl Object target) { + public boolean contains(@Nullable Object target) { // Overridden to prevent a ton of boxing return (target instanceof Short) && Shorts.indexOf(array, (Short) target, start, end) != -1; } @Override - public int indexOf(@NullableDecl Object target) { + public int indexOf(@Nullable Object target) { // Overridden to prevent a ton of boxing if (target instanceof Short) { int i = Shorts.indexOf(array, (Short) target, start, end); @@ -606,7 +606,7 @@ public int indexOf(@NullableDecl Object target) { } @Override - public int lastIndexOf(@NullableDecl Object target) { + public int lastIndexOf(@Nullable Object target) { // Overridden to prevent a ton of boxing if (target instanceof Short) { int i = Shorts.lastIndexOf(array, (Short) target, start, end); @@ -637,7 +637,7 @@ public List subList(int fromIndex, int toIndex) { } @Override - public boolean equals(@NullableDecl Object object) { + public boolean equals(@Nullable Object object) { if (object == this) { return true; } diff --git a/guava/src/com/google/common/primitives/UnsignedInteger.java b/guava/src/com/google/common/primitives/UnsignedInteger.java index 74740e9b92cf..1796ac137881 100644 --- a/guava/src/com/google/common/primitives/UnsignedInteger.java +++ b/guava/src/com/google/common/primitives/UnsignedInteger.java @@ -23,7 +23,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import java.math.BigInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A wrapper class for unsigned {@code int} values, supporting arithmetic operations. @@ -226,7 +226,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof UnsignedInteger) { UnsignedInteger other = (UnsignedInteger) obj; return value == other.value; diff --git a/guava/src/com/google/common/primitives/UnsignedLong.java b/guava/src/com/google/common/primitives/UnsignedLong.java index 448579071d25..07f785b657ca 100644 --- a/guava/src/com/google/common/primitives/UnsignedLong.java +++ b/guava/src/com/google/common/primitives/UnsignedLong.java @@ -21,7 +21,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.Serializable; import java.math.BigInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A wrapper class for unsigned {@code long} values, supporting arithmetic operations. @@ -238,7 +238,7 @@ public int hashCode() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof UnsignedLong) { UnsignedLong other = (UnsignedLong) obj; return value == other.value; diff --git a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java index 67655da9c1d3..45aea776f9cc 100644 --- a/guava/src/com/google/common/reflect/AbstractInvocationHandler.java +++ b/guava/src/com/google/common/reflect/AbstractInvocationHandler.java @@ -19,7 +19,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Abstract implementation of {@link InvocationHandler} that handles {@link Object#equals}, {@link @@ -59,7 +59,7 @@ public abstract class AbstractInvocationHandler implements InvocationHandler { * */ @Override - public final Object invoke(Object proxy, Method method, @NullableDecl Object[] args) + public final Object invoke(Object proxy, Method method, Object @Nullable [] args) throws Throwable { if (args == null) { args = NO_ARGS; diff --git a/guava/src/com/google/common/reflect/ClassPath.java b/guava/src/com/google/common/reflect/ClassPath.java index 495d3f6bb29c..fe8a6d2d8ae6 100644 --- a/guava/src/com/google/common/reflect/ClassPath.java +++ b/guava/src/com/google/common/reflect/ClassPath.java @@ -54,7 +54,7 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Scans the source of a {@link ClassLoader} and finds all loadable classes and resources. @@ -414,8 +414,7 @@ private void scanJar(File file, ClassLoader classloader) throws IOException { * and an empty set will be returned. */ @VisibleForTesting - static ImmutableSet getClassPathFromManifest( - File jarFile, @NullableDecl Manifest manifest) { + static ImmutableSet getClassPathFromManifest(File jarFile, @Nullable Manifest manifest) { if (manifest == null) { return ImmutableSet.of(); } diff --git a/guava/src/com/google/common/reflect/Element.java b/guava/src/com/google/common/reflect/Element.java index e2b9652353be..c63c09aaff31 100644 --- a/guava/src/com/google/common/reflect/Element.java +++ b/guava/src/com/google/common/reflect/Element.java @@ -23,7 +23,7 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Represents either a {@link Field}, a {@link Method} or a {@link Constructor}. Provides @@ -158,7 +158,7 @@ final boolean isTransient() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof Element) { Element that = (Element) obj; return getOwnerType().equals(that.getOwnerType()) && member.equals(that.member); diff --git a/guava/src/com/google/common/reflect/Invokable.java b/guava/src/com/google/common/reflect/Invokable.java index c8440ed99ff3..e0a9ab509b2d 100644 --- a/guava/src/com/google/common/reflect/Invokable.java +++ b/guava/src/com/google/common/reflect/Invokable.java @@ -31,7 +31,7 @@ import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.Arrays; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Wrapper around either a {@link Method} or a {@link Constructor}. Convenience API is provided to @@ -97,7 +97,7 @@ public static Invokable from(Constructor constructor) { // All subclasses are owned by us and we'll make sure to get the R type right. @SuppressWarnings("unchecked") @CanIgnoreReturnValue - public final R invoke(@NullableDecl T receiver, Object... args) + public final R invoke(@Nullable T receiver, Object... args) throws InvocationTargetException, IllegalAccessException { return (R) invokeInternal(receiver, checkNotNull(args)); } @@ -177,7 +177,7 @@ public TypeToken getOwnerType() { return (TypeToken) TypeToken.of(getDeclaringClass()); } - abstract Object invokeInternal(@NullableDecl Object receiver, Object[] args) + abstract Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, IllegalAccessException; abstract Type[] getGenericParameterTypes(); @@ -203,7 +203,7 @@ static class MethodInvokable extends Invokable { } @Override - final Object invokeInternal(@NullableDecl Object receiver, Object[] args) + final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, IllegalAccessException { return method.invoke(receiver, args); } @@ -267,7 +267,7 @@ static class ConstructorInvokable extends Invokable { } @Override - final Object invokeInternal(@NullableDecl Object receiver, Object[] args) + final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, IllegalAccessException { try { return constructor.newInstance(args); diff --git a/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java b/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java index d3541b6ac8dd..90c00d9e1d9e 100644 --- a/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java +++ b/guava/src/com/google/common/reflect/MutableTypeToInstanceMap.java @@ -27,7 +27,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A mutable type-to-instance map. See also {@link ImmutableTypeToInstanceMap}. @@ -41,29 +41,29 @@ public final class MutableTypeToInstanceMap extends ForwardingMap, B> backingMap = Maps.newHashMap(); - @NullableDecl + @Nullable @Override public T getInstance(Class type) { return trustedGet(TypeToken.of(type)); } - @NullableDecl + @Nullable @Override public T getInstance(TypeToken type) { return trustedGet(type.rejectTypeVariables()); } - @NullableDecl + @Nullable @Override @CanIgnoreReturnValue - public T putInstance(Class type, @NullableDecl T value) { + public T putInstance(Class type, @Nullable T value) { return trustedPut(TypeToken.of(type), value); } - @NullableDecl + @Nullable @Override @CanIgnoreReturnValue - public T putInstance(TypeToken type, @NullableDecl T value) { + public T putInstance(TypeToken type, @Nullable T value) { return trustedPut(type.rejectTypeVariables(), value); } @@ -103,13 +103,13 @@ protected Map, B> delegate() { } @SuppressWarnings("unchecked") // value could not get in if not a T - @NullableDecl - private T trustedPut(TypeToken type, @NullableDecl T value) { + @Nullable + private T trustedPut(TypeToken type, @Nullable T value) { return (T) backingMap.put(type, value); } @SuppressWarnings("unchecked") // value could not get in if not a T - @NullableDecl + @Nullable private T trustedGet(TypeToken type) { return (T) backingMap.get(type); } diff --git a/guava/src/com/google/common/reflect/Parameter.java b/guava/src/com/google/common/reflect/Parameter.java index 6b4b26145164..313449608093 100644 --- a/guava/src/com/google/common/reflect/Parameter.java +++ b/guava/src/com/google/common/reflect/Parameter.java @@ -22,7 +22,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedType; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Represents a method or constructor parameter. @@ -68,7 +68,7 @@ public boolean isAnnotationPresent(Class annotationType) { } @Override - @NullableDecl + @Nullable public A getAnnotation(Class annotationType) { checkNotNull(annotationType); for (Annotation annotation : annotations) { @@ -99,7 +99,7 @@ public Annotation[] getDeclaredAnnotations() { /** @since 18.0 */ // @Override on JDK8 - @NullableDecl + @Nullable public A getDeclaredAnnotation(Class annotationType) { checkNotNull(annotationType); return FluentIterable.from(annotations).filter(annotationType).first().orNull(); @@ -118,7 +118,7 @@ public AnnotatedType getAnnotatedType() { } @Override - public boolean equals(@NullableDecl Object obj) { + public boolean equals(@Nullable Object obj) { if (obj instanceof Parameter) { Parameter that = (Parameter) obj; return position == that.position && declaration.equals(that.declaration); diff --git a/guava/src/com/google/common/reflect/TypeParameter.java b/guava/src/com/google/common/reflect/TypeParameter.java index 283494107d93..586c912ae857 100644 --- a/guava/src/com/google/common/reflect/TypeParameter.java +++ b/guava/src/com/google/common/reflect/TypeParameter.java @@ -19,7 +19,7 @@ import com.google.common.annotations.Beta; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Captures a free type variable that can be used in {@link TypeToken#where}. For example: @@ -51,7 +51,7 @@ public final int hashCode() { } @Override - public final boolean equals(@NullableDecl Object o) { + public final boolean equals(@Nullable Object o) { if (o instanceof TypeParameter) { TypeParameter that = (TypeParameter) o; return typeVariable.equals(that.typeVariable); diff --git a/guava/src/com/google/common/reflect/TypeResolver.java b/guava/src/com/google/common/reflect/TypeResolver.java index b5880f537533..4d0b41a9da70 100644 --- a/guava/src/com/google/common/reflect/TypeResolver.java +++ b/guava/src/com/google/common/reflect/TypeResolver.java @@ -35,7 +35,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An object of this class encapsulates type mappings from type variables. Mappings are established @@ -528,7 +528,7 @@ private WildcardCapturer notForTypeVariable() { return new WildcardCapturer(id); } - private Type captureNullable(@NullableDecl Type type) { + private Type captureNullable(@Nullable Type type) { if (type == null) { return null; } diff --git a/guava/src/com/google/common/reflect/TypeToInstanceMap.java b/guava/src/com/google/common/reflect/TypeToInstanceMap.java index 91e0e3addb95..667c326b8f84 100644 --- a/guava/src/com/google/common/reflect/TypeToInstanceMap.java +++ b/guava/src/com/google/common/reflect/TypeToInstanceMap.java @@ -17,7 +17,7 @@ import com.google.common.annotations.Beta; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Map; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A map, each entry of which maps a {@link TypeToken} to an instance of that type. In addition to @@ -49,7 +49,7 @@ public interface TypeToInstanceMap extends Map, B> { *

    {@code getInstance(Foo.class)} is equivalent to {@code * getInstance(TypeToken.of(Foo.class))}. */ - @NullableDecl + @Nullable T getInstance(Class type); /** @@ -57,7 +57,7 @@ public interface TypeToInstanceMap extends Map, B> { * present. This will only return a value that was bound to this specific type, not a value that * may have been bound to a subtype. */ - @NullableDecl + @Nullable T getInstance(TypeToken type); /** @@ -70,9 +70,9 @@ public interface TypeToInstanceMap extends Map, B> { * @return the value previously associated with this class (possibly {@code null}), or {@code * null} if there was no previous entry. */ - @NullableDecl + @Nullable @CanIgnoreReturnValue - T putInstance(Class type, @NullableDecl T value); + T putInstance(Class type, @Nullable T value); /** * Maps the specified type to the specified value. Does not associate this value with any @@ -81,7 +81,7 @@ public interface TypeToInstanceMap extends Map, B> { * @return the value previously associated with this type (possibly {@code null}), or {@code null} * if there was no previous entry. */ - @NullableDecl + @Nullable @CanIgnoreReturnValue - T putInstance(TypeToken type, @NullableDecl T value); + T putInstance(TypeToken type, @Nullable T value); } diff --git a/guava/src/com/google/common/reflect/TypeToken.java b/guava/src/com/google/common/reflect/TypeToken.java index 698777c83831..fecf435597c5 100644 --- a/guava/src/com/google/common/reflect/TypeToken.java +++ b/guava/src/com/google/common/reflect/TypeToken.java @@ -47,7 +47,7 @@ import java.util.Map; import java.util.Set; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link Type} with generics. @@ -289,7 +289,7 @@ private TypeToken resolveSupertype(Type type) { * if the bound is a class or extends from a class. This means that the returned type could be a * type variable too. */ - @NullableDecl + @Nullable final TypeToken getGenericSuperclass() { if (runtimeType instanceof TypeVariable) { // First bound is always the super class, if one exists. @@ -308,7 +308,7 @@ final TypeToken getGenericSuperclass() { return superToken; } - @NullableDecl + @Nullable private TypeToken boundAsSuperclass(Type bound) { TypeToken token = of(bound); if (token.getRawType().isInterface()) { @@ -561,7 +561,7 @@ public final TypeToken unwrap() { * Returns the array component type if this type represents an array ({@code int[]}, {@code T[]}, * {@code []>} etc.), or else {@code null} is returned. */ - @NullableDecl + @Nullable public final TypeToken getComponentType() { Type componentType = Types.getComponentType(runtimeType); if (componentType == null) { @@ -820,7 +820,7 @@ public boolean apply(TypeToken type) { * Returns true if {@code o} is another {@code TypeToken} that represents the same {@link Type}. */ @Override - public boolean equals(@NullableDecl Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof TypeToken) { TypeToken that = (TypeToken) o; return runtimeType.equals(that.runtimeType); @@ -1133,7 +1133,7 @@ private boolean isOwnedBySubtypeOf(Type supertype) { * Returns the owner type of a {@link ParameterizedType} or enclosing class of a {@link Class}, or * null otherwise. */ - @NullableDecl + @Nullable private Type getOwnerTypeIfPresent() { if (runtimeType instanceof ParameterizedType) { return ((ParameterizedType) runtimeType).getOwnerType(); @@ -1310,7 +1310,7 @@ Iterable> getInterfaces(TypeToken type) { return type.getGenericInterfaces(); } - @NullableDecl + @Nullable @Override TypeToken getSuperclass(TypeToken type) { return type.getGenericSuperclass(); @@ -1329,7 +1329,7 @@ Iterable> getInterfaces(Class type) { return Arrays.asList(type.getInterfaces()); } - @NullableDecl + @Nullable @Override Class getSuperclass(Class type) { return type.getSuperclass(); @@ -1412,7 +1412,7 @@ public int compare(K left, K right) { abstract Iterable getInterfaces(K type); - @NullableDecl + @Nullable abstract K getSuperclass(K type); private static class ForwardingTypeCollector extends TypeCollector { diff --git a/guava/src/com/google/common/reflect/Types.java b/guava/src/com/google/common/reflect/Types.java index 6dd022529d3a..9ebe797e8748 100644 --- a/guava/src/com/google/common/reflect/Types.java +++ b/guava/src/com/google/common/reflect/Types.java @@ -44,7 +44,7 @@ import java.util.Collection; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Utilities for working with {@link Type}. @@ -86,7 +86,7 @@ static Type newArrayType(Type componentType) { * {@code ownerType}. */ static ParameterizedType newParameterizedTypeWithOwner( - @NullableDecl Type ownerType, Class rawType, Type... arguments) { + @Nullable Type ownerType, Class rawType, Type... arguments) { if (ownerType == null) { return newParameterizedType(rawType, arguments); } @@ -105,14 +105,14 @@ static ParameterizedType newParameterizedType(Class rawType, Type... argument /** Decides what owner type to use for constructing {@link ParameterizedType} from a raw class. */ private enum ClassOwnership { OWNED_BY_ENCLOSING_CLASS { - @NullableDecl + @Nullable @Override Class getOwnerType(Class rawType) { return rawType.getEnclosingClass(); } }, LOCAL_CLASS_HAS_NO_OWNER { - @NullableDecl + @Nullable @Override Class getOwnerType(Class rawType) { if (rawType.isLocalClass()) { @@ -123,7 +123,7 @@ Class getOwnerType(Class rawType) { } }; - @NullableDecl + @Nullable abstract Class getOwnerType(Class rawType); static final ClassOwnership JVM_BEHAVIOR = detectJvmBehavior(); @@ -172,7 +172,7 @@ static String toString(Type type) { return (type instanceof Class) ? ((Class) type).getName() : type.toString(); } - @NullableDecl + @Nullable static Type getComponentType(Type type) { checkNotNull(type); final AtomicReference result = new AtomicReference<>(); @@ -204,7 +204,7 @@ void visitClass(Class t) { * Returns {@code ? extends X} if any of {@code bounds} is a subtype of {@code X[]}; or null * otherwise. */ - @NullableDecl + @Nullable private static Type subtypeOfComponentType(Type[] bounds) { for (Type bound : bounds) { Type componentType = getComponentType(bound); @@ -260,11 +260,11 @@ public boolean equals(Object obj) { private static final class ParameterizedTypeImpl implements ParameterizedType, Serializable { - @NullableDecl private final Type ownerType; + @Nullable private final Type ownerType; private final ImmutableList argumentsList; private final Class rawType; - ParameterizedTypeImpl(@NullableDecl Type ownerType, Class rawType, Type[] typeArguments) { + ParameterizedTypeImpl(@Nullable Type ownerType, Class rawType, Type[] typeArguments) { checkNotNull(rawType); checkArgument(typeArguments.length == rawType.getTypeParameters().length); disallowPrimitiveType(typeArguments, "type parameter"); diff --git a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java index 2043460ac756..eb99d37c50a7 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java @@ -24,7 +24,7 @@ import com.google.errorprone.annotations.ForOverride; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Implementations of {@code Futures.catching*}. */ @GwtCompatible @@ -54,9 +54,9 @@ static ListenableFuture create( * In certain circumstances, this field might theoretically not be visible to an afterDone() call * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture. */ - @NullableDecl ListenableFuture inputFuture; - @NullableDecl Class exceptionType; - @NullableDecl F fallback; + @Nullable ListenableFuture inputFuture; + @Nullable Class exceptionType; + @Nullable F fallback; AbstractCatchingFuture( ListenableFuture inputFuture, Class exceptionType, F fallback) { @@ -141,12 +141,12 @@ protected String pendingToString() { /** Template method for subtypes to actually run the fallback. */ @ForOverride - @NullableDecl + @Nullable abstract T doFallback(F fallback, X throwable) throws Exception; /** Template method for subtypes to actually set the result. */ @ForOverride - abstract void setResult(@NullableDecl T result); + abstract void setResult(@Nullable T result); @Override protected final void afterDone() { @@ -201,13 +201,13 @@ private static final class CatchingFuture } @Override - @NullableDecl + @Nullable V doFallback(Function fallback, X cause) throws Exception { return fallback.apply(cause); } @Override - void setResult(@NullableDecl V result) { + void setResult(@Nullable V result) { set(result); } } diff --git a/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java index 7c44aae6ae88..5dd45120ed45 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java @@ -41,7 +41,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * An abstract implementation of {@link ListenableFuture}, intended for advanced users only. More @@ -170,8 +170,8 @@ public final boolean cancel(boolean mayInterruptIfRunning) { private static final class Waiter { static final Waiter TOMBSTONE = new Waiter(false /* ignored param */); - @NullableDecl volatile Thread thread; - @NullableDecl volatile Waiter next; + @Nullable volatile Thread thread; + @Nullable volatile Waiter next; /** * Constructor for the TOMBSTONE, avoids use of ATOMIC_HELPER in case this class is loaded @@ -248,7 +248,7 @@ private static final class Listener { final Executor executor; // writes to next are made visible by subsequent CAS's on the listeners field - @NullableDecl Listener next; + @Nullable Listener next; Listener(Runnable task, Executor executor) { this.task = task; @@ -293,9 +293,9 @@ private static final class Cancellation { } final boolean wasInterrupted; - @NullableDecl final Throwable cause; + @Nullable final Throwable cause; - Cancellation(boolean wasInterrupted, @NullableDecl Throwable cause) { + Cancellation(boolean wasInterrupted, @Nullable Throwable cause) { this.wasInterrupted = wasInterrupted; this.cause = cause; } @@ -341,13 +341,13 @@ public void run() { * argument. * */ - @NullableDecl private volatile Object value; + @Nullable private volatile Object value; /** All listeners. */ - @NullableDecl private volatile Listener listeners; + @Nullable private volatile Listener listeners; /** All waiting threads. */ - @NullableDecl private volatile Waiter waiters; + @Nullable private volatile Waiter waiters; /** Constructor for use by subclasses. */ protected AbstractFuture() {} @@ -683,7 +683,7 @@ public void addListener(Runnable listener, Executor executor) { * @return true if the attempt was accepted, completing the {@code Future} */ @CanIgnoreReturnValue - protected boolean set(@NullableDecl V value) { + protected boolean set(@Nullable V value) { Object valueToSet = value == null ? NULL : value; if (ATOMIC_HELPER.casValue(this, null, valueToSet)) { complete(this); @@ -900,7 +900,7 @@ final Throwable trustedGetException() { * If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts) * the given future (if available). */ - final void maybePropagateCancellationTo(@NullableDecl Future related) { + final void maybePropagateCancellationTo(@Nullable Future related) { if (related != null & isCancelled()) { related.cancel(wasInterrupted()); } @@ -978,7 +978,7 @@ public String toString() { * @return null if an explanation cannot be provided because the future is done. * @since 23.0 */ - @NullableDecl + @Nullable protected String pendingToString() { Object localValue = value; if (localValue instanceof SetFuture) { @@ -1233,7 +1233,7 @@ boolean casValue(AbstractFuture future, Object expect, Object update) { } private static CancellationException cancellationExceptionWithCause( - @NullableDecl String message, @NullableDecl Throwable cause) { + @Nullable String message, @Nullable Throwable cause) { CancellationException exception = new CancellationException(message); exception.initCause(cause); return exception; diff --git a/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java b/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java index 22157bab2371..960f40e8ffab 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractListeningExecutorService.java @@ -20,7 +20,7 @@ import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.Callable; import java.util.concurrent.RunnableFuture; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Abstract {@link ListeningExecutorService} implementation that creates {@link ListenableFuture} @@ -57,7 +57,7 @@ public ListenableFuture submit(Runnable task) { } @Override - public ListenableFuture submit(Runnable task, @NullableDecl T result) { + public ListenableFuture submit(Runnable task, @Nullable T result) { return (ListenableFuture) super.submit(task, result); } diff --git a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java index 2548f48c30e9..82cac8e50c11 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java @@ -36,7 +36,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Base class for services that can implement {@link #startUp} and {@link #shutDown} but while in @@ -466,7 +466,7 @@ private class ReschedulableCallable extends ForwardingFuture implements Ca /** The future that represents the next execution of this task. */ @GuardedBy("lock") - @NullableDecl + @Nullable private Future currentFuture; ReschedulableCallable( diff --git a/guava/src/com/google/common/util/concurrent/AbstractService.java b/guava/src/com/google/common/util/concurrent/AbstractService.java index fadbc2b28e7f..375a677ae082 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractService.java @@ -35,7 +35,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Base class for implementing services that can handle {@link #doStart} and {@link #doStop} @@ -551,14 +551,14 @@ private static final class StateSnapshot { * The exception that caused this service to fail. This will be {@code null} unless the service * has failed. */ - @NullableDecl final Throwable failure; + @Nullable final Throwable failure; StateSnapshot(State internalState) { this(internalState, false, null); } StateSnapshot( - State internalState, boolean shutdownWhenStartupFinishes, @NullableDecl Throwable failure) { + State internalState, boolean shutdownWhenStartupFinishes, @Nullable Throwable failure) { checkArgument( !shutdownWhenStartupFinishes || internalState == STARTING, "shutdownWhenStartupFinishes can only be set if state is STARTING. Got %s instead.", diff --git a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java index 986a0831e02a..a4fbc504bd22 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java @@ -25,7 +25,7 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Implementations of {@code Futures.transform*}. */ @GwtCompatible @@ -53,8 +53,8 @@ static ListenableFuture create( * In certain circumstances, this field might theoretically not be visible to an afterDone() call * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture. */ - @NullableDecl ListenableFuture inputFuture; - @NullableDecl F function; + @Nullable ListenableFuture inputFuture; + @Nullable F function; AbstractTransformFuture(ListenableFuture inputFuture, F function) { this.inputFuture = checkNotNull(inputFuture); @@ -162,12 +162,12 @@ public final void run() { /** Template method for subtypes to actually run the transform. */ @ForOverride - @NullableDecl - abstract T doTransform(F function, @NullableDecl I result) throws Exception; + @Nullable + abstract T doTransform(F function, @Nullable I result) throws Exception; /** Template method for subtypes to actually set the result. */ @ForOverride - abstract void setResult(@NullableDecl T result); + abstract void setResult(@Nullable T result); @Override protected final void afterDone() { @@ -207,7 +207,7 @@ private static final class AsyncTransformFuture @Override ListenableFuture doTransform( - AsyncFunction function, @NullableDecl I input) throws Exception { + AsyncFunction function, @Nullable I input) throws Exception { ListenableFuture outputFuture = function.apply(input); checkNotNull( outputFuture, @@ -234,14 +234,14 @@ private static final class TransformFuture } @Override - @NullableDecl - O doTransform(Function function, @NullableDecl I input) { + @Nullable + O doTransform(Function function, @Nullable I input) { return function.apply(input); // TODO(lukes): move the UndeclaredThrowable catch block here? } @Override - void setResult(@NullableDecl O result) { + void setResult(@Nullable O result) { set(result); } } diff --git a/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/guava/src/com/google/common/util/concurrent/AggregateFuture.java index 03c217bdb513..b514de84ec26 100644 --- a/guava/src/com/google/common/util/concurrent/AggregateFuture.java +++ b/guava/src/com/google/common/util/concurrent/AggregateFuture.java @@ -28,7 +28,7 @@ import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A future made up of a collection of sub-futures. @@ -44,7 +44,7 @@ abstract class AggregateFuture extends AbstractFuture.TrustedFu * In certain circumstances, this field might theoretically not be visible to an afterDone() call * triggered by cancel(). For details, see the comments on the fields of TimeoutFuture. */ - @NullableDecl private RunningState runningState; + @Nullable private RunningState runningState; @Override protected final void afterDone() { @@ -278,8 +278,7 @@ void releaseResourcesAfterFailure() { *

    If {@code allMustSucceed} is true, called as each future completes; otherwise, called for * each future when all futures complete. */ - abstract void collectOneValue( - boolean allMustSucceed, int index, @NullableDecl InputT returnValue); + abstract void collectOneValue(boolean allMustSucceed, int index, @Nullable InputT returnValue); abstract void handleAllCompleted(); diff --git a/guava/src/com/google/common/util/concurrent/AsyncFunction.java b/guava/src/com/google/common/util/concurrent/AsyncFunction.java index f33aea4993ed..bae9bce3a021 100644 --- a/guava/src/com/google/common/util/concurrent/AsyncFunction.java +++ b/guava/src/com/google/common/util/concurrent/AsyncFunction.java @@ -16,7 +16,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.concurrent.Future; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Transforms a value, possibly asynchronously. For an example usage and more information, see @@ -35,5 +35,5 @@ public interface AsyncFunction { * *

    Throwing an exception from this method is equivalent to returning a failing {@code Future}. */ - ListenableFuture apply(@NullableDecl I input) throws Exception; + ListenableFuture apply(@Nullable I input) throws Exception; } diff --git a/guava/src/com/google/common/util/concurrent/Atomics.java b/guava/src/com/google/common/util/concurrent/Atomics.java index f6aafb743120..191da95bd397 100644 --- a/guava/src/com/google/common/util/concurrent/Atomics.java +++ b/guava/src/com/google/common/util/concurrent/Atomics.java @@ -17,7 +17,7 @@ import com.google.common.annotations.GwtIncompatible; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReferenceArray; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to classes in the {@code java.util.concurrent.atomic} package. @@ -44,7 +44,7 @@ public static AtomicReference newReference() { * @param initialValue the initial value * @return a new {@code AtomicReference} with the given initial value */ - public static AtomicReference newReference(@NullableDecl V initialValue) { + public static AtomicReference newReference(@Nullable V initialValue) { return new AtomicReference(initialValue); } diff --git a/guava/src/com/google/common/util/concurrent/Callables.java b/guava/src/com/google/common/util/concurrent/Callables.java index 18f1a26e0f08..505a9abc0250 100644 --- a/guava/src/com/google/common/util/concurrent/Callables.java +++ b/guava/src/com/google/common/util/concurrent/Callables.java @@ -21,7 +21,7 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Supplier; import java.util.concurrent.Callable; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to the {@link Callable} interface. @@ -34,7 +34,7 @@ public final class Callables { private Callables() {} /** Creates a {@code Callable} which immediately returns a preset value each time it is called. */ - public static Callable returning(@NullableDecl final T value) { + public static Callable returning(@Nullable final T value) { return new Callable() { @Override public T call() { diff --git a/guava/src/com/google/common/util/concurrent/CollectionFuture.java b/guava/src/com/google/common/util/concurrent/CollectionFuture.java index 97476d59b2d1..b1412d8dc0c7 100644 --- a/guava/src/com/google/common/util/concurrent/CollectionFuture.java +++ b/guava/src/com/google/common/util/concurrent/CollectionFuture.java @@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import java.util.List; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Aggregate future that collects (stores) results of each future. */ @GwtCompatible(emulated = true) @@ -50,7 +50,7 @@ abstract class CollectionFutureRunningState extends RunningState { } @Override - final void collectOneValue(boolean allMustSucceed, int index, @NullableDecl V returnValue) { + final void collectOneValue(boolean allMustSucceed, int index, @Nullable V returnValue) { List> localValues = values; if (localValues != null) { diff --git a/guava/src/com/google/common/util/concurrent/CombinedFuture.java b/guava/src/com/google/common/util/concurrent/CombinedFuture.java index 361fca4eb102..35b1e69be5f9 100644 --- a/guava/src/com/google/common/util/concurrent/CombinedFuture.java +++ b/guava/src/com/google/common/util/concurrent/CombinedFuture.java @@ -25,7 +25,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Aggregate future that computes its value by calling a callable. */ @GwtCompatible @@ -64,7 +64,7 @@ private final class CombinedFutureRunningState extends RunningState { } @Override - void collectOneValue(boolean allMustSucceed, int index, @NullableDecl Object returnValue) {} + void collectOneValue(boolean allMustSucceed, int index, @Nullable Object returnValue) {} @Override void handleAllCompleted() { diff --git a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java index d6ea486e3a26..3802715cbcf9 100644 --- a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java +++ b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java @@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * The {@code CycleDetectingLockFactory} creates {@link ReentrantLock} instances and {@link @@ -674,7 +674,7 @@ void checkAcquiredLock(Policy policy, LockGraphNode acquiredLock) { * @return If a path was found, a chained {@link ExampleStackTrace} illustrating the path to the * {@code lock}, or {@code null} if no path was found. */ - @NullableDecl + @Nullable private ExampleStackTrace findPathTo(LockGraphNode node, Set seen) { if (!seen.add(this)) { return null; // Already traversed this node. diff --git a/guava/src/com/google/common/util/concurrent/ExecutionError.java b/guava/src/com/google/common/util/concurrent/ExecutionError.java index dd25efb13de2..7663c15ef0f8 100644 --- a/guava/src/com/google/common/util/concurrent/ExecutionError.java +++ b/guava/src/com/google/common/util/concurrent/ExecutionError.java @@ -15,7 +15,7 @@ package com.google.common.util.concurrent; import com.google.common.annotations.GwtCompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * {@link Error} variant of {@link java.util.concurrent.ExecutionException}. As with {@code @@ -33,17 +33,17 @@ public class ExecutionError extends Error { protected ExecutionError() {} /** Creates a new instance with the given detail message. */ - protected ExecutionError(@NullableDecl String message) { + protected ExecutionError(@Nullable String message) { super(message); } /** Creates a new instance with the given detail message and cause. */ - public ExecutionError(@NullableDecl String message, @NullableDecl Error cause) { + public ExecutionError(@Nullable String message, @Nullable Error cause) { super(message, cause); } /** Creates a new instance with the given cause. */ - public ExecutionError(@NullableDecl Error cause) { + public ExecutionError(@Nullable Error cause) { super(cause); } diff --git a/guava/src/com/google/common/util/concurrent/ExecutionList.java b/guava/src/com/google/common/util/concurrent/ExecutionList.java index 30a0ca8a58da..f813a637417c 100644 --- a/guava/src/com/google/common/util/concurrent/ExecutionList.java +++ b/guava/src/com/google/common/util/concurrent/ExecutionList.java @@ -21,7 +21,7 @@ import java.util.concurrent.Executor; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A support class for {@code ListenableFuture} implementations to manage their listeners. An @@ -49,7 +49,8 @@ public final class ExecutionList { * RunnableExecutorPair#next} field. */ @GuardedBy("this") - @NullableDecl private RunnableExecutorPair runnables; + @Nullable + private RunnableExecutorPair runnables; @GuardedBy("this") private boolean executed; @@ -153,7 +154,7 @@ private static void executeListener(Runnable runnable, Executor executor) { private static final class RunnableExecutorPair { final Runnable runnable; final Executor executor; - @NullableDecl RunnableExecutorPair next; + @Nullable RunnableExecutorPair next; RunnableExecutorPair(Runnable runnable, Executor executor, RunnableExecutorPair next) { this.runnable = runnable; diff --git a/guava/src/com/google/common/util/concurrent/FutureCallback.java b/guava/src/com/google/common/util/concurrent/FutureCallback.java index a10f71bbabae..b18047751469 100644 --- a/guava/src/com/google/common/util/concurrent/FutureCallback.java +++ b/guava/src/com/google/common/util/concurrent/FutureCallback.java @@ -17,7 +17,7 @@ import com.google.common.annotations.GwtCompatible; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A callback for accepting the results of a {@link java.util.concurrent.Future} computation @@ -31,7 +31,7 @@ @GwtCompatible public interface FutureCallback { /** Invoked with the result of the {@code Future} computation when it is successful. */ - void onSuccess(@NullableDecl V result); + void onSuccess(@Nullable V result); /** * Invoked when a {@code Future} computation fails or is canceled. diff --git a/guava/src/com/google/common/util/concurrent/Futures.java b/guava/src/com/google/common/util/concurrent/Futures.java index 43c1a86480ed..b0e1db9a4094 100644 --- a/guava/src/com/google/common/util/concurrent/Futures.java +++ b/guava/src/com/google/common/util/concurrent/Futures.java @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Static utility methods pertaining to the {@link Future} interface. @@ -159,7 +159,7 @@ public static CheckedFuture makeChecked( * getters just return the value. This {@code Future} can't be canceled or timed out and its * {@code isDone()} method always returns {@code true}. */ - public static ListenableFuture immediateFuture(@NullableDecl V value) { + public static ListenableFuture immediateFuture(@Nullable V value) { if (value == null) { // This cast is safe because null is assignable to V for all V (i.e. it is covariant) @SuppressWarnings({"unchecked", "rawtypes"}) @@ -189,7 +189,7 @@ public static ListenableFuture immediateFuture(@NullableDecl V value) { @Deprecated @GwtIncompatible // TODO public static CheckedFuture immediateCheckedFuture( - @NullableDecl V value) { + @Nullable V value) { return new ImmediateSuccessfulCheckedFuture<>(value); } diff --git a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java index bdf174323094..33fc7316e35c 100644 --- a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java +++ b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java @@ -35,7 +35,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** Static methods used to implement {@link Futures#getChecked(Future, Class)}. */ @@ -226,7 +226,7 @@ private static X newWithCause(Class exceptionClass, Thr @SuppressWarnings({"unchecked", "rawtypes"}) List> constructors = (List) Arrays.asList(exceptionClass.getConstructors()); for (Constructor constructor : preferringStrings(constructors)) { - @NullableDecl X instance = newFromConstructor(constructor, cause); + @Nullable X instance = newFromConstructor(constructor, cause); if (instance != null) { if (instance.getCause() == null) { instance.initCause(cause); @@ -257,7 +257,7 @@ public Boolean apply(Constructor input) { }) .reverse(); - @NullableDecl + @Nullable private static X newFromConstructor(Constructor constructor, Throwable cause) { Class[] paramTypes = constructor.getParameterTypes(); Object[] params = new Object[paramTypes.length]; diff --git a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java index 506cd3b52027..590360e5478c 100644 --- a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java +++ b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Implementations of {@code Futures.immediate*}. */ @GwtCompatible(emulated = true) @@ -73,9 +73,9 @@ public boolean isDone() { static class ImmediateSuccessfulFuture extends ImmediateFuture { static final ImmediateSuccessfulFuture NULL = new ImmediateSuccessfulFuture<>(null); - @NullableDecl private final V value; + @Nullable private final V value; - ImmediateSuccessfulFuture(@NullableDecl V value) { + ImmediateSuccessfulFuture(@Nullable V value) { this.value = value; } @@ -95,9 +95,9 @@ public String toString() { @GwtIncompatible // TODO static class ImmediateSuccessfulCheckedFuture extends ImmediateFuture implements CheckedFuture { - @NullableDecl private final V value; + @Nullable private final V value; - ImmediateSuccessfulCheckedFuture(@NullableDecl V value) { + ImmediateSuccessfulCheckedFuture(@Nullable V value) { this.value = value; } diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index 362c96e0a8cc..444592616fe2 100644 --- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -17,7 +17,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.j2objc.annotations.ReflectionSupport; import java.util.concurrent.atomic.AtomicReference; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; @GwtCompatible(emulated = true) @ReflectionSupport(value = ReflectionSupport.Level.FULL) @@ -98,7 +98,7 @@ public final void run() { * Any interruption that happens as a result of calling interruptTask will arrive before this * method is called. Complete Futures here. */ - abstract void afterRanInterruptibly(@NullableDecl T result, @NullableDecl Throwable error); + abstract void afterRanInterruptibly(@Nullable T result, @Nullable Throwable error); final void interruptTask() { // Since the Thread is replaced by DONE before run() invokes listeners or returns, if we succeed diff --git a/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java b/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java index db516c37aea0..ee7e861d49ad 100644 --- a/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java +++ b/guava/src/com/google/common/util/concurrent/ListenableFutureTask.java @@ -18,7 +18,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.FutureTask; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link FutureTask} that also implements the {@link ListenableFuture} interface. Unlike {@code @@ -63,7 +63,7 @@ public static ListenableFutureTask create(Callable callable) { * ListenableFutureTask.create(runnable, null)} * @since 10.0 */ - public static ListenableFutureTask create(Runnable runnable, @NullableDecl V result) { + public static ListenableFutureTask create(Runnable runnable, @Nullable V result) { return new ListenableFutureTask(runnable, result); } @@ -71,7 +71,7 @@ public static ListenableFutureTask create(Runnable runnable, @NullableDec super(callable); } - ListenableFutureTask(Runnable runnable, @NullableDecl V result) { + ListenableFutureTask(Runnable runnable, @Nullable V result) { super(runnable, result); } diff --git a/guava/src/com/google/common/util/concurrent/Monitor.java b/guava/src/com/google/common/util/concurrent/Monitor.java index 9117d8ce8ccc..34490a6e843b 100644 --- a/guava/src/com/google/common/util/concurrent/Monitor.java +++ b/guava/src/com/google/common/util/concurrent/Monitor.java @@ -25,7 +25,7 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; import java.util.function.BooleanSupplier; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A synchronization abstraction supporting waiting on arbitrary boolean conditions. @@ -320,7 +320,8 @@ public abstract static class Guard { /** The next active guard */ @GuardedBy("monitor.lock") - @NullableDecl Guard next; + @Nullable + Guard next; protected Guard(Monitor monitor) { this.monitor = checkNotNull(monitor, "monitor"); diff --git a/guava/src/com/google/common/util/concurrent/Platform.java b/guava/src/com/google/common/util/concurrent/Platform.java index 94e6700fd031..f27bfb383ae0 100644 --- a/guava/src/com/google/common/util/concurrent/Platform.java +++ b/guava/src/com/google/common/util/concurrent/Platform.java @@ -15,13 +15,13 @@ package com.google.common.util.concurrent; import com.google.common.annotations.GwtCompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** Methods factored out so that they can be emulated differently in GWT. */ @GwtCompatible(emulated = true) final class Platform { static boolean isInstanceOfThrowableClass( - @NullableDecl Throwable t, Class expectedClass) { + @Nullable Throwable t, Class expectedClass) { return expectedClass.isInstance(t); } diff --git a/guava/src/com/google/common/util/concurrent/SettableFuture.java b/guava/src/com/google/common/util/concurrent/SettableFuture.java index 3c8b90fbded0..b8e9491b4c64 100644 --- a/guava/src/com/google/common/util/concurrent/SettableFuture.java +++ b/guava/src/com/google/common/util/concurrent/SettableFuture.java @@ -17,7 +17,7 @@ import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link ListenableFuture} whose result can be set by a {@link #set(Object)}, {@link @@ -44,7 +44,7 @@ public static SettableFuture create() { @CanIgnoreReturnValue @Override - public boolean set(@NullableDecl V value) { + public boolean set(@Nullable V value) { return super.set(value); } diff --git a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java index f9093e65ae20..be23be9de78a 100644 --- a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java +++ b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java @@ -23,7 +23,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Implementation of {@code Futures#withTimeout}. @@ -70,8 +70,8 @@ static ListenableFuture create( * write-barriers). */ - @NullableDecl private ListenableFuture delegateRef; - @NullableDecl private Future timer; + @Nullable private ListenableFuture delegateRef; + @Nullable private Future timer; private TimeoutFuture(ListenableFuture delegate) { this.delegateRef = Preconditions.checkNotNull(delegate); @@ -79,7 +79,7 @@ private TimeoutFuture(ListenableFuture delegate) { /** A runnable that is called when the delegate or the timer completes. */ private static final class Fire implements Runnable { - @NullableDecl TimeoutFuture timeoutFutureRef; + @Nullable TimeoutFuture timeoutFutureRef; Fire(TimeoutFuture timeoutFuture) { this.timeoutFutureRef = timeoutFuture; diff --git a/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java b/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java index 49a4e04e5a19..52bea9900243 100644 --- a/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java +++ b/guava/src/com/google/common/util/concurrent/TrustedListenableFutureTask.java @@ -21,7 +21,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executors; import java.util.concurrent.RunnableFuture; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link RunnableFuture} that also implements the {@link ListenableFuture} interface. @@ -50,7 +50,7 @@ static TrustedListenableFutureTask create(Callable callable) { * result, consider using constructions of the form: {@code ListenableFuture f = * ListenableFutureTask.create(runnable, null)} */ - static TrustedListenableFutureTask create(Runnable runnable, @NullableDecl V result) { + static TrustedListenableFutureTask create(Runnable runnable, @Nullable V result) { return new TrustedListenableFutureTask(Executors.callable(runnable, result)); } diff --git a/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java b/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java index 3dde73745f30..c6c57d3b71d8 100644 --- a/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java +++ b/guava/src/com/google/common/util/concurrent/UncheckedExecutionException.java @@ -15,7 +15,7 @@ package com.google.common.util.concurrent; import com.google.common.annotations.GwtCompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with {@code @@ -38,17 +38,17 @@ public class UncheckedExecutionException extends RuntimeException { protected UncheckedExecutionException() {} /** Creates a new instance with the given detail message. */ - protected UncheckedExecutionException(@NullableDecl String message) { + protected UncheckedExecutionException(@Nullable String message) { super(message); } /** Creates a new instance with the given detail message and cause. */ - public UncheckedExecutionException(@NullableDecl String message, @NullableDecl Throwable cause) { + public UncheckedExecutionException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } /** Creates a new instance with the given cause. */ - public UncheckedExecutionException(@NullableDecl Throwable cause) { + public UncheckedExecutionException(@Nullable Throwable cause) { super(cause); } diff --git a/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java b/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java index a09a97057f00..04fddf451d52 100644 --- a/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java +++ b/guava/src/com/google/common/util/concurrent/UncheckedTimeoutException.java @@ -15,7 +15,7 @@ package com.google.common.util.concurrent; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; +import org.checkerframework.checker.nullness.qual.Nullable; /** * Unchecked version of {@link java.util.concurrent.TimeoutException}. @@ -27,15 +27,15 @@ public class UncheckedTimeoutException extends RuntimeException { public UncheckedTimeoutException() {} - public UncheckedTimeoutException(@NullableDecl String message) { + public UncheckedTimeoutException(@Nullable String message) { super(message); } - public UncheckedTimeoutException(@NullableDecl Throwable cause) { + public UncheckedTimeoutException(@Nullable Throwable cause) { super(cause); } - public UncheckedTimeoutException(@NullableDecl String message, @NullableDecl Throwable cause) { + public UncheckedTimeoutException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } diff --git a/pom.xml b/pom.xml index 04ab5f200fd3..d91d7b7ad579 100644 --- a/pom.xml +++ b/pom.xml @@ -224,6 +224,11 @@ checker-compat-qual 2.0.0 + + org.checkerframework + checker-qual + 2.0.0 + com.google.errorprone error_prone_annotations